sugarforever / chat-ollama

ChatOllama is an open source chatbot based on LLMs. It supports a wide range of language models, and knowledge base management.
MIT License
2.6k stars 409 forks source link

Docker部署初始化数据库失败 Segmentation fault #340

Open cmacro opened 5 months ago

cmacro commented 5 months ago

请求帮助:

使用docker部署时出现 Segmentation fault 无法正常使用。

这是第一次部署,按照docker视频部署方案中删除 rm -rf ~/.chatollama目录和docker de 2个volume,重新拉取build无效。 访问 http://localhost:3000 界面刷新几次可以出来功能不可用,查看sqlite3库没有生成任何数据表。

环境

黑果 Version 14.0 (23A344)
2.5 GHz 13th Gen Intel(R) Core(TM) i5-13490F
AMD Radeon RX 6600 8 GB
64 GB 3200 MHz DDR4

使用数据库初始化命令错误信息

➜  chat-ollama git:(main) docker compose exec chatollama npx prisma migrate dev
Segmentation fault
➜  chat-ollama git:(main) docker compose exec chatollama npx prisma migrate dev
Prisma schema loaded from prisma/schema.prisma
Datasource "sqlite": SQLite database "chatollama.sqlite" at "file:/app/sqlite/chatollama.sqlite"

Segmentation fault

➜  chat-ollama git:(main) ls -la  ~/.chatollama
total 0
drwxr-xr-x   2 moguf  staff    64 Apr 23 21:47 .
drwxr-x---+ 61 moguf  staff  1952 Apr 23 22:20 ..

➜  chat-ollama git:(main) docker-compose ps
NAME                       IMAGE                         COMMAND                  SERVICE      CREATED          STATUS          PORTS
chat-ollama-chatollama-1   0001coder/chatollama:latest   "docker-entrypoint.s…"   chatollama   36 minutes ago   Up 31 minutes   0.0.0.0:3000->3000/tcp
chat-ollama-chromadb-1     chromadb/chroma               "/docker_entrypoint.…"   chromadb     36 minutes ago   Up 31 minutes   0.0.0.0:8000->8000/tcp
chat-ollama-redis-1        redis:latest                  "docker-entrypoint.s…"   redis        36 minutes ago   Up 31 minutes   6379/tcp

docker compose up 的信息

[+] Running 0/0
 ⠋ chatollama Pulling                                                                                                        0.0s 
error getting credentials - err: exit status 1, out: ``
➜  chat-ollama git:(main) docker compose up                                                                                      
[+] Running 1/1
 ✔ chatollama Pulled                                                                                                         2.3s 
[+] Running 3/0
 ✔ Container chat-ollama-chatollama-1  Created                                                                               0.0s 
 ✔ Container chat-ollama-chromadb-1    Created                                                                               0.0s 
 ✔ Container chat-ollama-redis-1       Created                                                                               0.0s 
Attaching to chatollama-1, chromadb-1, redis-1
redis-1       | 1:C 23 Apr 2024 13:51:42.826 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-1       | 1:C 23 Apr 2024 13:51:42.826 * Redis version=7.2.4, bits=64, commit=00000000, modified=0, pid=1, just started
redis-1       | 1:C 23 Apr 2024 13:51:42.826 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis-1       | 1:M 23 Apr 2024 13:51:42.826 * monotonic clock: POSIX clock_gettime
redis-1       | 1:M 23 Apr 2024 13:51:42.826 * Running mode=standalone, port=6379.
redis-1       | 1:M 23 Apr 2024 13:51:42.827 * Server initialized
redis-1       | 1:M 23 Apr 2024 13:51:42.827 * Loading RDB produced by version 7.2.4
redis-1       | 1:M 23 Apr 2024 13:51:42.827 * RDB age 108 seconds
redis-1       | 1:M 23 Apr 2024 13:51:42.827 * RDB memory usage when created 0.83 Mb
redis-1       | 1:M 23 Apr 2024 13:51:42.827 * Done loading RDB, keys loaded: 0, keys expired: 0.
redis-1       | 1:M 23 Apr 2024 13:51:42.827 * DB loaded from disk: 0.000 seconds
redis-1       | 1:M 23 Apr 2024 13:51:42.827 * Ready to accept connections tcp
chromadb-1    | Starting 'uvicorn chromadb.app:app' with args: --workers 1 --host 0.0.0.0 --port 8000 --proxy-headers --log-config chromadb/log_config.yml --timeout-keep-alive 30
chatollama-1  | 
chatollama-1  | > nuxt-app@ prisma-migrate /app
chatollama-1  | > prisma migrate dev
chatollama-1  | 
chromadb-1    | DEBUG:    [23-04-2024 13:51:43] Registering provider: token_config
chromadb-1    | DEBUG:    [23-04-2024 13:51:43] Registering provider: user_token_config
chromadb-1    | DEBUG:    [23-04-2024 13:51:43] Registering provider: token
chromadb-1    | DEBUG:    [23-04-2024 13:51:43] Registering provider: token
chatollama-1  | Segmentation fault
chatollama-1  |  ELIFECYCLE  Command failed with exit code 139.
chatollama-1  | Listening on http://[::]:3000
chromadb-1    | WARNING:  [23-04-2024 13:51:43] chroma_server_nofile is set to 65535, but this is less than current soft limit of 1048576. chroma_server_nofile will not be set.
chromadb-1    | INFO:     [23-04-2024 13:51:43] Anonymized telemetry enabled. See                     https://docs.trychroma.com/telemetry for more information.
chromadb-1    | DEBUG:    [23-04-2024 13:51:43] Starting component System
chromadb-1    | DEBUG:    [23-04-2024 13:51:43] Starting component OpenTelemetryClient
chromadb-1    | DEBUG:    [23-04-2024 13:51:43] Starting component SimpleAssignmentPolicy
chromadb-1    | DEBUG:    [23-04-2024 13:51:43] Starting component SqliteDB
chromadb-1    | DEBUG:    [23-04-2024 13:51:43] Starting component QuotaEnforcer
chromadb-1    | DEBUG:    [23-04-2024 13:51:43] Starting component Posthog
chromadb-1    | DEBUG:    [23-04-2024 13:51:43] Starting component LocalSegmentManager
chromadb-1    | DEBUG:    [23-04-2024 13:51:43] Starting component SegmentAPI
chromadb-1    | INFO:     [23-04-2024 13:51:43] Started server process [1]
chromadb-1    | INFO:     [23-04-2024 13:51:43] Waiting for application startup.
chromadb-1    | INFO:     [23-04-2024 13:51:43] Application startup complete.
chromadb-1    | INFO:     [23-04-2024 13:51:43] Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
zhanghongnian commented 5 months ago

删除数据库所在映射操作很怪,可以发下视频链接吗

也可以尝试 docker-compose down && docker-compose up 清除容器再次启动看看

sugarforever commented 5 months ago
ELIFECYCLE  Command failed with exit code 139

看起来像是prisma migrate阶段出现的短错误。

我拉取了最新的docker镜像。

[+] Running 4/3
 ✔ Container chat-ollama-chromadb-1                                                                                                                          Created0.0s 
 ✔ Container chat-ollama-chatollama-1                                                                                                                        Recreated0.4s  Container chat-ollama-redis-1       Created                                                                                                                      0.0s 
 ✔ Container chat-ollama-redis-1                                                                                                                             Created0.0s 
 ! chatollama The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested        0.0s 
Attaching to chatollama-1, chromadb-1, redis-1
chromadb-1    | Starting 'uvicorn chromadb.app:app' with args: --workers 1 --host 0.0.0.0 --port 8000 --proxy-headers --log-config chromadb/log_config.yml --timeout-keep-alive 30
redis-1       | 1:C 23 Apr 2024 22:45:29.388 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis-1       | 1:C 23 Apr 2024 22:45:29.393 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-1       | 1:C 23 Apr 2024 22:45:29.393 * Redis version=7.2.4, bits=64, commit=00000000, modified=0, pid=1, just started
redis-1       | 1:C 23 Apr 2024 22:45:29.393 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis-1       | 1:M 23 Apr 2024 22:45:29.394 * monotonic clock: POSIX clock_gettime
redis-1       | 1:M 23 Apr 2024 22:45:29.401 * Running mode=standalone, port=6379.
redis-1       | 1:M 23 Apr 2024 22:45:29.407 * Server initialized
redis-1       | 1:M 23 Apr 2024 22:45:29.409 * Loading RDB produced by version 7.2.4
redis-1       | 1:M 23 Apr 2024 22:45:29.409 * RDB age 348967 seconds
redis-1       | 1:M 23 Apr 2024 22:45:29.409 * RDB memory usage when created 0.95 Mb
redis-1       | 1:M 23 Apr 2024 22:45:29.414 * Done loading RDB, keys loaded: 51, keys expired: 0.
redis-1       | 1:M 23 Apr 2024 22:45:29.415 * DB loaded from disk: 0.007 seconds
redis-1       | 1:M 23 Apr 2024 22:45:29.415 * Ready to accept connections tcp
chromadb-1    | DEBUG:    [23-04-2024 22:45:30] Registering provider: token_config
chromadb-1    | DEBUG:    [23-04-2024 22:45:30] Registering provider: user_token_config
chromadb-1    | DEBUG:    [23-04-2024 22:45:30] Registering provider: token
chromadb-1    | DEBUG:    [23-04-2024 22:45:30] Registering provider: token
chromadb-1    | WARNING:  [23-04-2024 22:45:30] chroma_server_nofile is set to 65535, but this is less than current soft limit of 1048576. chroma_server_nofile will not be set.
chromadb-1    | INFO:     [23-04-2024 22:45:30] Anonymized telemetry enabled. See                     https://docs.trychroma.com/telemetry for more information.
chromadb-1    | DEBUG:    [23-04-2024 22:45:30] Starting component System
chromadb-1    | DEBUG:    [23-04-2024 22:45:30] Starting component OpenTelemetryClient
chromadb-1    | DEBUG:    [23-04-2024 22:45:30] Starting component SimpleAssignmentPolicy
chromadb-1    | DEBUG:    [23-04-2024 22:45:30] Starting component SqliteDB
chromadb-1    | DEBUG:    [23-04-2024 22:45:30] Starting component QuotaEnforcer
chromadb-1    | DEBUG:    [23-04-2024 22:45:30] Starting component Posthog
chromadb-1    | DEBUG:    [23-04-2024 22:45:30] Starting component LocalSegmentManager
chromadb-1    | DEBUG:    [23-04-2024 22:45:30] Starting component SegmentAPI
chromadb-1    | INFO:     [23-04-2024 22:45:30] Started server process [1]
chromadb-1    | INFO:     [23-04-2024 22:45:30] Waiting for application startup.
chromadb-1    | INFO:     [23-04-2024 22:45:30] Application startup complete.
chromadb-1    | INFO:     [23-04-2024 22:45:30] Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
chatollama-1  | 
chatollama-1  | > nuxt-app@ prisma-migrate /app
chatollama-1  | > prisma migrate dev
chatollama-1  | 
chatollama-1  | Prisma schema loaded from prisma/schema.prisma
chatollama-1  | Datasource "sqlite": SQLite database "chatollama.sqlite" at "file:/app/sqlite/chatollama.sqlite"
chatollama-1  | 
chatollama-1  | Applying migration `20240415204753_user`
chatollama-1  | Applying migration `20240422224033_user_knowledgebases`
chatollama-1  | Applying migration `20240423083729_non_unique_users`
chatollama-1  | Applying migration `20240423165019_knowledgebase_is_public`
chatollama-1  | 
chatollama-1  | The following migration(s) have been applied:
chatollama-1  | 
chatollama-1  | migrations/
chatollama-1  |   └─ 20240415204753_user/
chatollama-1  |     └─ migration.sql
chatollama-1  |   └─ 20240422224033_user_knowledgebases/
chatollama-1  |     └─ migration.sql
chatollama-1  |   └─ 20240423083729_non_unique_users/
chatollama-1  |     └─ migration.sql
chatollama-1  |   └─ 20240423165019_knowledgebase_is_public/
chatollama-1  |     └─ migration.sql
chatollama-1  | 
chatollama-1  | Your database is now in sync with your schema.
chatollama-1  | 
✔ Generated Prisma Client (v5.12.1) to ./node_modules/.pnpm/@prisma+client@5.12.
chatollama-1  | 1_prisma@5.12.1/node_modules/@prisma/client in 1.10s
chatollama-1  | 
chatollama-1  | 
chatollama-1  | Listening on http://[::]:3000

并没有能够重现问题。

你试试看最新的版本,并且不需要运行docker compose exec chatollama npx prisma migrate dev 命令了。容器启动时会在容器能自动运行的。

cmacro commented 5 months ago

Prisma Client

操作步骤:

  1. docker-compose down
  2. 删除原来的所有image 和 ~/.chatollama目录
  3. 重新 docker-compose up
...
chromadb-1    | INFO:     [24-04-2024 13:16:56] Application startup complete.
chromadb-1    | INFO:     [24-04-2024 13:16:56] Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
chatollama-1  | Segmentation fault
chatollama-1  |  ELIFECYCLE  Command failed with exit code 139.
chatollama-1  | Segmentation fault
chatollama-1 exited with code 0
chatollama-1  | 
chatollama-1  | > nuxt-app@ prisma-migrate /app
chatollama-1  | > prisma migrate dev
chatollama-1  | 
chatollama-1  | Segmentation fault
chatollama-1  |  ELIFECYCLE  Command failed with exit code 139.
chatollama-1  | Segmentation fault
chatollama-1 exited with code 139
chatollama-1  | 
chatollama-1  | > nuxt-app@ prisma-migrate /app
chatollama-1  | > prisma migrate dev
chatollama-1  | 
chatollama-1  | Segmentation fault
chatollama-1  |  ELIFECYCLE  Command failed with exit code 139.
chatollama-1  | Segmentation fault
chatollama-1 exited with code 139
chatollama-1  | 
...
Screenshot at Apr 24 21-24-47

视频有些大没办法上传,贴在油管上 https://www.youtube.com/watch?v=g07SpeDcZLE

cmacro commented 5 months ago

在公司电脑(windows11)上Docker部署正常,未出现家里电脑相同问题。

两次操作全部成功!

  1. 首次部署成功
  2. 第二次同家里的清理步骤重新启动docker也没出现异常。 不知道家里缺啥环境或权限。

windows的数据文件目录:C:\Users\admin\.chatollama

PS C:\dev\github\chat-ollama> docker-compose down
[+] Running 4/4
 ✔ Container chat-ollama-redis-1       Removed                                                                                                            0.0s
 ✔ Container chat-ollama-chromadb-1    Removed                                                                                                            0.0s
 ✔ Container chat-ollama-chatollama-1  Removed                                                                                                            0.0s
 ✔ Network chat-ollama_default         Removed                                                                                                            0.3s

PS C:\dev\github\chat-ollama> docker-compose up
[+] Running 1/1
 ✔ chatollama Pulled                                                                                                                                      5.4s
[+] Running 6/6
 ✔ Network chat-ollama_default         Created                                                                                                            0.0s
 ✔ Volume "chat-ollama_chromadb_data"  Created                                                                                                            0.0s
 ✔ Volume "chat-ollama_redis_data"     Created                                                                                                            0.0s
 ✔ Container chat-ollama-chromadb-1    Created                                                                                                            0.1s
 ✔ Container chat-ollama-redis-1       Created                                                                                                            0.1s
 ✔ Container chat-ollama-chatollama-1  Created                                                                                                            0.1s
Attaching to chatollama-1, chromadb-1, redis-1
chromadb-1    | Starting 'uvicorn chromadb.app:app' with args: --workers 1 --host 0.0.0.0 --port 8000 --proxy-headers --log-config chromadb/log_config.yml --timeout-keep-alive 30
redis-1       | 1:C 25 Apr 2024 02:45:53.432 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis-1       | 1:C 25 Apr 2024 02:45:53.432 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis-1       | 1:C 25 Apr 2024 02:45:53.432 * Redis version=7.2.4, bits=64, commit=00000000, modified=0, pid=1, just started
redis-1       | 1:C 25 Apr 2024 02:45:53.432 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
redis-1       | 1:M 25 Apr 2024 02:45:53.433 * monotonic clock: POSIX clock_gettime
redis-1       | 1:M 25 Apr 2024 02:45:53.434 * Running mode=standalone, port=6379.
redis-1       | 1:M 25 Apr 2024 02:45:53.435 * Server initialized
redis-1       | 1:M 25 Apr 2024 02:45:53.435 * Ready to accept connections tcp
chatollama-1  |
chatollama-1  | > nuxt-app@ prisma-migrate /app
chatollama-1  | > prisma migrate dev
chatollama-1  |
chatollama-1  | Prisma schema loaded from prisma/schema.prisma
chatollama-1  | Datasource "sqlite": SQLite database "chatollama.sqlite" at "file:/app/sqlite/chatollama.sqlite"
chatollama-1  |
chatollama-1  | SQLite database chatollama.sqlite created at file:/app/sqlite/chatollama.sqlite
chatollama-1  |
chatollama-1  | Applying migration `20240302004128_init`
chatollama-1  | Applying migration `20240305202320_knowlegebase_files`
chatollama-1  | Applying migration `20240305205052_files_cascade_deletion`
chatollama-1  | Applying migration `20240309101210_instruction`
chatollama-1  | Applying migration `20240415204753_user`
chatollama-1  | Applying migration `20240422224033_user_knowledgebases`
chatollama-1  | Applying migration `20240423083729_non_unique_users`
chatollama-1  | Applying migration `20240423165019_knowledgebase_is_public`
chatollama-1  |
chatollama-1  | The following migration(s) have been applied:
chatollama-1  |
chatollama-1  | migrations/
chatollama-1  |   └─ 20240302004128_init/
chatollama-1  |     └─ migration.sql
chatollama-1  |   └─ 20240305202320_knowlegebase_files/
chatollama-1  |     └─ migration.sql
chatollama-1  |   └─ 20240305205052_files_cascade_deletion/
chatollama-1  |     └─ migration.sql
chatollama-1  |   └─ 20240309101210_instruction/
chatollama-1  |     └─ migration.sql
chatollama-1  |   └─ 20240415204753_user/
chatollama-1  |     └─ migration.sql
chatollama-1  |   └─ 20240422224033_user_knowledgebases/
chatollama-1  |     └─ migration.sql
chatollama-1  |   └─ 20240423083729_non_unique_users/
chatollama-1  |     └─ migration.sql
chatollama-1  |   └─ 20240423165019_knowledgebase_is_public/
chatollama-1  |     └─ migration.sql
chatollama-1  |
chatollama-1  | Your database is now in sync with your schema.
chatollama-1  |
chatollama-1  | Running generate... (Use --skip-generate to skip the generators)
chromadb-1    | WARNING:  [25-04-2024 02:45:55] chroma_server_nofile is set to 65535, but this is less than current soft limit of 1048576. chroma_server_nofile will not be set.
chromadb-1    | INFO:     [25-04-2024 02:45:55] Anonymized telemetry enabled. See                     https://docs.trychroma.com/telemetry for more information.
chromadb-1    | DEBUG:    [25-04-2024 02:45:55] Starting component System
chromadb-1    | DEBUG:    [25-04-2024 02:45:55] Starting component OpenTelemetryClient
chromadb-1    | DEBUG:    [25-04-2024 02:45:55] Starting component SqliteDB
chromadb-1    | DEBUG:    [25-04-2024 02:45:55] Starting component QuotaEnforcer
chromadb-1    | DEBUG:    [25-04-2024 02:45:55] Starting component Posthog
chromadb-1    | DEBUG:    [25-04-2024 02:45:55] Starting component LocalSegmentManager
chromadb-1    | DEBUG:    [25-04-2024 02:45:55] Starting component SegmentAPI
chromadb-1    | INFO:     [25-04-2024 02:45:55] Started server process [1]
chromadb-1    | INFO:     [25-04-2024 02:45:55] Waiting for application startup.
chromadb-1    | INFO:     [25-04-2024 02:45:55] Application startup complete.
✔ Generated Prisma Client (v5.12.1) to ./node_modules/.pnpm/@prisma+client@5.12.
chatollama-1  | 1_prisma@5.12.1/node_modules/@prisma/client in 159ms
chatollama-1  |
chatollama-1  |
chatollama-1  | Listening on http://[::]:3000