chatchat-space / Langchain-Chatchat

Langchain-Chatchat(原Langchain-ChatGLM)基于 Langchain 与 ChatGLM, Qwen 与 Llama 等语言模型的 RAG 与 Agent 应用 | Langchain-Chatchat (formerly langchain-ChatGLM), local knowledge based LLM (like ChatGLM, Qwen and Llama) RAG and Agent app with langchain
Apache License 2.0
32.05k stars 5.57k forks source link

[BUG] Docker部署chatchat容器(0.3.1.2-2024-0720版本)启动失败 #4593

Open zhaochuninhefei opened 3 months ago

zhaochuninhefei commented 3 months ago

问题描述 / Problem Description 使用docker-compose启动时,chatchat容器发生错误:

sqlite3.OperationalError: unable to open database file

Xinference正常启动,并已运行qwen2-instruct与bge-m3。

查看docker实例状态

$ docker-compose up -d
WARN[0000] /ssd/docker_work_base/chatchat_xinference/docker-compose.yaml: `version` is obsolete 
[+] Running 2/0
 ✔ Container chatchat_xinference-xinference-1  Running                                                                                                                                                 0.0s 
 ✔ Container chatchat_xinference-chatchat-1    Started

docker ps结果:

$ docker ps
CONTAINER ID   IMAGE                                                        COMMAND                  CREATED             STATUS                         PORTS                                                           NAMES
43eb52821492   ccr.ccs.tencentyun.com/chatchat/chatchat:0.3.1.2-2024-0720   "chatchat start -a"      11 minutes ago      Restarting (1) 2 seconds ago                                                                   chatchat_xinference-chatchat-1
f54a8bd5b3c6   xprobe/xinference:latest                                   "xinference-local -H…"   About an hour ago   Up About an hour                                                                               chatchat_xinference-xinference-1

服务端口状态:

$ ss -anptl | grep -E '(8501|7861|9997)'
LISTEN     0      128          *:9997                     *:*                  

完整堆栈信息:

2024-07-23 15:10:09.941 | WARNING  | chatchat.server.utils:get_default_llm:205 - default llm model glm4-chat is not found in available llms, using qwen2-instruct instead
cwd:/root/chatchat_data
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 146, in __init__
    self._dbapi_connection = engine.raw_connection()
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 3300, in raw_connection
    return self.pool.connect()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 449, in connect
    return _ConnectionFairy._checkout(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 1263, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
          ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/impl.py", line 179, in _do_get
    with util.safe_reraise():
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/impl.py", line 177, in _do_get
    return self._create_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 390, in _create_connection
    return _ConnectionRecord(self)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/create.py", line 643, in connect
    return dialect.connect(*cargs, **cparams)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 620, in connect
    return self.loaded_dbapi.connect(*cargs, **cparams)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlite3.OperationalError: unable to open database file
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/usr/local/bin/chatchat", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/chatchat/startup.py", line 364, in main
    create_tables()
  File "/usr/local/lib/python3.11/site-packages/chatchat/server/knowledge_base/migrate.py", line 39, in create_tables
    Base.metadata.create_all(bind=engine)
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/sql/schema.py", line 5871, in create_all
    bind._run_ddl_visitor(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 3250, in _run_ddl_visitor
    with self.begin() as conn:
  File "/usr/local/lib/python3.11/contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 3240, in begin
    with self.connect() as conn:
         ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 3276, in connect
    return self._connection_cls(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 148, in __init__
    Connection._handle_dbapi_exception_noconnection(
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 2440, in _handle_dbapi_exception_noconnection
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 146, in __init__
    self._dbapi_connection = engine.raw_connection()
                             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 3300, in raw_connection
    return self.pool.connect()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 449, in connect
    return _ConnectionFairy._checkout(self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 1263, in _checkout
    fairy = _ConnectionRecord.checkout(pool)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 712, in checkout
    rec = pool._do_get()
          ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/impl.py", line 179, in _do_get
    with util.safe_reraise():
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/impl.py", line 177, in _do_get
    return self._create_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 390, in _create_connection
    return _ConnectionRecord(self)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 674, in __init__
    self.__connect()
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 900, in __connect
    with util.safe_reraise():
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/util/langhelpers.py", line 146, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 896, in __connect
    self.dbapi_connection = connection = pool._invoke_creator(self)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/create.py", line 643, in connect
    return dialect.connect(*cargs, **cparams)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/sqlalchemy/engine/default.py", line 620, in connect
    return self.loaded_dbapi.connect(*cargs, **cparams)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file
(Background on this error at: https://sqlalche.me/e/20/e3q8)

复现问题的步骤 / Steps to Reproduce 按照下面的说明,执行到5. 启动 chatchat & xinference 服务时,chatchat实例发生以上错误。 https://github.com/chatchat-space/Langchain-Chatchat/blob/master/docs/install/README_docker.md

预期的结果 / Expected Result 不应该出现错误,chatchat服务应该正常启动。

实际结果 / Actual Result chatchat服务发生错误,服务未能启动。

环境信息 / Environment Information

附加信息 / Additional Information

zhaochuninhefei commented 3 months ago

找到原因了,首次部署,还需要将data.tar.gz 文件(包含初始化后的数据库 samples 文件一份及相应目录结构)放置到对应挂在目录下并解压:

cd ~/chatchat
wget https://github.com/chatchat-space/Langchain-Chatchat/blob/master/docker/data.tar.gz
tar -xvf data.tar.gz

对应docker-compose配置:

  (上文 ...)
  chatchat:
    volumes:
      - ~/chatchat:/root/chatchat_data
  (下文 ...)
zhaochuninhefei commented 3 months ago

首次部署的数据准备应该记录到[一. Langchain-Chatchat 体验部署]的步骤[5. 启动 chatchat & xinference 服务]之前。 建议修改一下文档: https://github.com/chatchat-space/Langchain-Chatchat/blob/master/docs/install/README_docker.md

nadirvishun commented 3 months ago

确实挺无语,docker中不配置此文件及自动解压,而且即便解压了也没有配置文件,还要:


而且我用0720版本,没有生成Langchain-Chatchat相关文件夹,然后向量库一直用不了, 改用最新的0729版本才正常了。

xiaohundun commented 3 months ago

解决了,感谢 竟然还没改文档 😂

tiomfree commented 2 months ago

确实挺无语,docker中不配置此文件及自动解压,而且即便解压了也没有配置文件,还要:

  • 进入容器docker compose exec -it chatchat /bin/sh
  • 然后在/root/chatchat_data目录下运行chatchat init才能生成配置文件

而且我用0720版本,没有生成Langchain-Chatchat相关文件夹,然后向量库一直用不了, 改用最新的0729版本才正常了。

确实挺无语,docker中不配置此文件及自动解压,而且即便解压了也没有配置文件,还要:

  • 进入容器docker compose exec -it chatchat /bin/sh
  • 然后在/root/chatchat_data目录下运行chatchat init才能生成配置文件

而且我用0720版本,没有生成Langchain-Chatchat相关文件夹,然后向量库一直用不了, 改用最新的0729版本才正常了。

确实挺无语,docker中不配置此文件及自动解压,而且即便解压了也没有配置文件,还要:

  • 进入容器docker compose exec -it chatchat /bin/sh
  • 然后在/root/chatchat_data目录下运行chatchat init才能生成配置文件

而且我用0720版本,没有生成Langchain-Chatchat相关文件夹,然后向量库一直用不了, 改用最新的0729版本才正常了。

docker 版本的一个大坑啊,thanks!