Windows使用docker部署fastgpt出现的一些问题

文章目录

Windows使用docker部署FastGPT出现的一些问题

1.docker部署pg一直重启的问题

猜测是权限问题,请教了fastgpt的飞书社区之后更改yml文件

解决办法

复制代码
将挂载的配置选项改成以下配置
 volumes:
      - ./pg/data:/var/lib/postgresql/data && sudo chmod 0750 /var/lib/postgresql/data
或者
 volumes:
      - ./pg/data:/var/lib/postgresql/data && sudo chmod 0700 /var/lib/postgresql/data

2.重启MongoDB之后一直出现"Waiting for MongoDB to start..."

起初是发现fastgpt的网页打不开

然后查看日志发现MongoDB连不上,查看MongoDB日志发现全都是Waiting for MongoDB to start...

报错日志:

复制代码
[1739937319:887261][10:0x7f07fc766c80], file:WiredTiger.wt, connection: __posix_open_file, 815: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted"}}
2025-02-19 11:55:19 {"t":{"$date":"2025-02-19T03:55:19.903+00:00"},"s":"E",  "c":"STORAGE",  "id":22435,   "ctx":"initandlisten","msg":"WiredTiger error","attr":{"error":1,"message":"[1739937319:903566][10:0x7f07fc766c80], file:WiredTiger.wt, connection: __posix_open_file, 815: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted"}}
2025-02-19 11:55:19 {"t":{"$date":"2025-02-19T03:55:19.919+00:00"},"s":"E",  "c":"STORAGE",  "id":22435,   "ctx":"initandlisten","msg":"WiredTiger error","attr":{"error":1,"message":"[1739937319:919680][10:0x7f07fc766c80], file:WiredTiger.wt, connection: __posix_open_file, 815: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted"}}
2025-02-19 11:55:19 {"t":{"$date":"2025-02-19T03:55:19.920+00:00"},"s":"W",  "c":"STORAGE",  "id":22347,   "ctx":"initandlisten","msg":"Failed to start up WiredTiger under any compatibility version. This may be due to an unsupported upgrade or downgrade."}
2025-02-19 11:55:19 {"t":{"$date":"2025-02-19T03:55:19.920+00:00"},"s":"F",  "c":"STORAGE",  "id":28595,   "ctx":"initandlisten","msg":"Terminating.","attr":{"reason":"1: Operation not permitted"}}
2025-02-19 11:55:19 {"t":{"$date":"2025-02-19T03:55:19.920+00:00"},"s":"F",  "c":"-",        "id":23091,   "ctx":"initandlisten","msg":"Fatal assertion","attr":{"msgid":28595,"file":"src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp","line":688}}
2025-02-19 11:55:19 {"t":{"$date":"2025-02-19T03:55:19.920+00:00"},"s":"F",  "c":"-",        "id":23092,   "ctx":"initandlisten","msg":"\n\n***aborting after fassert() failure\n\n"}
2025-02-19 11:55:21 Waiting for MongoDB to start...
2025-02-19 11:55:23 Waiting for MongoDB to start...

从错误日志来看,MongoDB 无法启动的原因是 WiredTiger 存储引擎无法打开文件 /data/db/WiredTiger.wt,提示 Operation not permitted。这通常与文件权限或挂载卷的配置有关。

解决办法

复制代码
第一次尝试是将卷映射关闭掉
...
environment:
    - MONGO_INITDB_ROOT_USERNAME=myusername
    - MONGO_INITDB_ROOT_PASSWORD=mypassword
entrypoint:
  - bash
  - -c
  - |
...
发现这个方法重启之后确实可以访问fastgpt了,但是我在fastgpt里面加配置之后再重启容器,我里面配置的东西全没有了,故选择第二个方法

第二次尝试使用docker卷映射:
mongo:
  image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18
  container_name: mongo
  restart: always
  ports:
    - 27017:27017
  networks:
    - fastgpt
  command: mongod --keyFile /data/mongodb.key --replSet rs0
  environment:
    - MONGO_INITDB_ROOT_USERNAME=myusername
    - MONGO_INITDB_ROOT_PASSWORD=mypassword
  volumes:
    - mongo_data:/data/db
  entrypoint:
    - bash
    - -c
    - |
      openssl rand -base64 128 > /data/mongodb.key
      chmod 400 /data/mongodb.key
      chown 999:999 /data/mongodb.key
      echo 'const isInited = rs.status().ok === 1
      if(!isInited){
        rs.initiate({
            _id: "rs0",
            members: [
                { _id: 0, host: "mongo:27017" }
            ]
        })
      }' > /data/initReplicaSet.js
      # 启动MongoDB服务
      exec docker-entrypoint.sh "$$@" &

      # 等待MongoDB服务启动
      until mongo -u myusername -p mypassword --authenticationDatabase admin --eval "print('waited for connection')" > /dev/null 2>&1; do
        echo "Waiting for MongoDB to start..."
        sleep 2
      done

      # 执行初始化副本集的脚本
      mongo -u myusername -p mypassword --authenticationDatabase admin /data/initReplicaSet.js

      # 等待docker-entrypoint.sh脚本执行的MongoDB服务进程
      wait $$!

volumes:
  mongo_data:
  
这边使用docker卷来进行映射,这样重启之后数据就还在了。

3.oneapi启动不了failed to get gpt-3.5-turbo token encoder

报错信息:

复制代码
failed to get gpt-3.5-turbo token encoder: Get "https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken": tls: failed to verify certificate: x509: certificate is not authorized to sign other certificates

解决办法

1.下载文件:https://openaipublic.blob.core.windows.net/encodings/cl100k_base.tiktoken

2.将该文件复制一份然后分别改名为:

9b5ad71b2ce5302211f9c61530b329a4922fc6a4

fb374d419588a4632f3f557e76b4b70aebbca790

3.将该文件放在fastgpt/oneapi/cache位置下

4.更改docker-compose文件:

复制代码
oneapi:
    container_name: oneapi
    # image: ghcr.io/songquanpeng/one-api:v0.6.7
    image: registry.cn-hangzhou.aliyuncs.com/fastgpt/one-api:v0.6.6 # 阿里云
    ports:
      - 3001:3000
    depends_on:
      - mysql
    networks:
      - fastgpt
    restart: always
    environment:
      # mysql 连接参数
      - SQL_DSN=root:oneapimmysql@tcp(mysql:3306)/oneapi
      # 登录凭证加密密钥
      - SESSION_SECRET=oneapikey
      # 内存缓存
      - MEMORY_CACHE_ENABLED=true
      # 启动聚合更新,减少数据交互频率
      - BATCH_UPDATE_ENABLED=true
      # 聚合更新时长
      - BATCH_UPDATE_INTERVAL=10
      # 初始化的 root 密钥(建议部署完后更改,否则容易泄露)
      - INITIAL_ROOT_TOKEN=fastgpt
      # 修复无法获取gpt3.5令牌错误
      - TIKTOKEN_CACHE_DIR=/data/cache
    volumes:
      - ./oneapi:/data

5.重启docker

相关推荐
碣石潇湘无限路15 分钟前
【云原生】Kubernetes CEL 速查表
容器·贪心算法·kubernetes
学也不会2 小时前
d202541
windows
mingyuewu2 小时前
MAC安装docker 后提示com.docker.vmnetd”将对您的电脑造成伤害
macos·docker·容器
小小寂寞的城2 小时前
Ubuntu里安装Jenkins
ubuntu·ci/cd·docker·jenkins
厦门德仔2 小时前
【C#】C#字符串拼接的6种方式及其性能分析对比
服务器·windows·c#
Architect_Lee5 小时前
阿里云服务器安装docker以及mysql数据库
阿里云·docker·云计算
geek_super5 小时前
Docker学习--容器的root文件系统(rootfs)命令--docker cp 命令
docker
专注代码七年5 小时前
Docker运维篇
运维·docker·容器
一杯敬朝阳 一杯敬月光6 小时前
WIN11 企业版 部署Dify+Docker
运维·docker·容器
Leo Han6 小时前
k8s常用命令(持续更新中)
docker·容器·kubernetes