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

mfpqipee  于 4个月前  发布在  Docker
关注(0)|答案(4)|浏览(84)

问题描述 / 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

  • langchain-Chatchat 版本/commit 号:0.3.1.2-2024-0720
  • 是否使用 Docker 部署(是/否):是
  • 使用的模型(ChatGLM2-6B / Qwen-7B 等):Qwen2-7B-instruct
  • 使用的 Embedding 模型(moka-ai/m3e-base 等):bge-m3
  • 使用的向量库类型 (faiss / milvus / pg_vector 等): 不清楚
  • 操作系统及版本 / Operating system and version: centos7
  • Python 版本 / Python version: -
  • 其他相关环境信息 / Other relevant environment information: -

附加信息 / Additional Information

olhwl3o2

olhwl3o21#

找到原因了,首次部署,还需要将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
(下文 ...)

goucqfw6

goucqfw62#

首次部署的数据准备应该记录到[一. Langchain-Chatchat 体验部署]的步骤[5. 启动 chatchat & xinference 服务]之前。

建议修改一下文档:

$x_1^e_0^f_1^x$

djmepvbi

djmepvbi3#

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

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

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

zsbz8rwp

zsbz8rwp4#

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

相关问题