initdb: error: program "postgres" is needed by initdb but was not found in the same directory as "/usr/lib/postgresql/15/bin/initdb"
CalvinFang opened this issue · 6 comments
例行检查
- 我已确认目前没有类似 issue
- 我已完整查看过项目 README,以及项目文档
- 我使用了自己的 key,并确认我的 key 是可正常使用的
- 我理解并愿意跟进此 issue,协助测试和提供反馈
- 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭
你的版本
- 公有云版本
- 私有部署版本
问题描述
我使用docker-compose部署启动时发现pg一直重启,通过logs查看提示
popen failure: Cannot allocate memory
initdb: error: program "postgres" is needed by initdb but was not found in the same directory as "/usr/lib/postgresql/15/bin/initdb"
也使用了初始化的curl尝试修复但未成功:
curl --location --request POST 'http://*****:3000/api/admin/initv467' \
--header 'rootkey: root_key'
--header 'Content-Type: application/json'
复现步骤
预期结果
相关截图
docker ps结果
[root@***** fast]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0e739ee4b4b4 ghcr.io/labring/fastgpt:latest "sh -c 'node ${serve…" 32 minutes ago Up 32 minutes 0.0.0.0:3000->3000/tcp fastgpt
9ab1e0909d33 ankane/pgvector:v0.5.0 "docker-entrypoint.s…" 32 minutes ago Restarting (1) 23 seconds ago pg
eb5523051929 mongo:5.0.18 "docker-entrypoint.s…" 32 minutes ago Up 32 minutes 0.0.0.0:27017->27017/tcp mongo
docker的logs
[root@***** fast]# docker logs 9ab1e0909d33
popen failure: Cannot allocate memory
initdb: error: program "postgres" is needed by initdb but was not found in the same directory as "/usr/lib/postgresql/15/bin/initdb"
popen failure: Cannot allocate memory
initdb: error: program "postgres" is needed by initdb but was not found in the same directory as "/usr/lib/postgresql/15/bin/initdb"
[root@***** fast]# curl --location --request POST 'http://*****:3000/api/admin/initv467' --header 'rootkey: root_key' --header 'Content-Type: application/json'
得到的回复是{"code":500,"statusText":"","message":"getaddrinfo ENOTFOUND pg","data":null}
文件目录如下,发现pg的目录下为空
[root@***** fast]# tree
├── config.json
├── docker-compose.yml
├── mongo
│ └── data
│ ├── collection-0--4162485612890685892.wt
│ ├── collection-11-7081506281161257466.wt
│ └── WiredTiger.wt
│ └── .......
└── pg
| └── data
│ └── data目录下没有文件生成
DockerFile文件内容如下
[root@***** fast]# cat docker-compose.yml
version: '3.3'
services:
pg:
image: ankane/pgvector:v0.5.0 # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/pgvector:v0.5.0 # 阿里云
container_name: pg
restart: always
ports: # 生产环境建议不要暴露
- 5432:5432
networks:
- fastgpt
environment:
# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
- POSTGRES_USER=username
- POSTGRES_PASSWORD=password
- POSTGRES_DB=postgres
volumes:
- ./pg/data:/var/lib/postgresql/data
mongo:
image: mongo:5.0.18
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/mongo:5.0.18 # 阿里云
container_name: mongo
restart: always
ports: # 生产环境建议不要暴露
- 27017:27017
networks:
- fastgpt
environment:
# 这里的配置只有首次运行生效。修改后,重启镜像是不会生效的。需要把持久化数据删除再重启,才有效果
- MONGO_INITDB_ROOT_USERNAME=username
- MONGO_INITDB_ROOT_PASSWORD=password
volumes:
- ./mongo/data:/data/db
fastgpt:
container_name: fastgpt
image: ghcr.io/labring/fastgpt:latest # git
# image: registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:latest # 阿里云
ports:
- 3000:3000
networks:
- fastgpt
depends_on:
- mongo
- pg
restart: always
environment:
# root 密码,用户名为: root
- DEFAULT_ROOT_PSW=4jYIRrZ
# 中转地址,如果是用官方号,不需要管。务必加 /v1
- OPENAI_BASE_URL=https://apivip.aiproxy.io
- CHAT_API_KEY=sk-*****
- DB_MAX_LINK=5 # database max link
- TOKEN_KEY=any
- ROOT_KEY=root_key
- FILE_TOKEN_KEY=filetoken
# mongo 配置,不需要改. 如果连不上,可能需要去掉 ?authSource=admin
- MONGODB_URI=mongodb://username:password@mongo:27017/fastgpt?authSource=admin
# pg配置. 不需要改
- PG_URL=postgresql://username:password@pg:5432/postgres
volumes:
- ./config.json:/app/data/config.json
networks:
fastgpt:
可以尝试一下在 pg 部署的 docker-compose 配置中 增加 privileged=true ,应该是由于权限问题,我是通过这个方式解决的
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
You can try adding privileged=true in the docker-compose configuration deployed by pg. It should be due to permission issues. I solved it in this way.
tks,我将pg镜像版本由v0.5.0更换为pgvector:v0.4.2解决了这个问题;
Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
tks, I changed the pg image version from v0.5.0 to pgvector:v0.4.2 to solve this problem;
可以尝试一下在 pg 部署的 docker-compose 配置中 增加 privileged=true ,应该是由于权限问题,我是通过这个方式解决的
thx,我也是这个问题解决了
可以尝试一下在 pg 部署的 docker-compose 配置中 增加 privileged=true ,应该是由于权限问题,我是通过这个方式解决的
(base) root@DESKTOP-ND8N4R2:/mnt/e/code/FastGPT/fastgpt# docker-compose up -d privileged=true
no such service: privileged=true 何解?我是wsl2+docker桌面版弄的,