现象
使用docker-compose部署FastGPT私有部署版本后,出现PostgreSQL容器无法正常运作的问题,ankane/pgvector:v0.5.0镜像的容器反复重启。容器日志出现以下报错:
pg | popen failure: Cannot allocate memory
pg | initdb: error: program "postgres" is needed by initdb but was not found in the same directory as "/usr/lib/postgresql/15/bin/initdb"该问题在CentOS 7.9环境中复现,在Windows环境部署无此问题,FastGPT功能可正常运行且无报错日志。
可能原因
根据容器报错信息,可推测可能的触发原因为两点:
- 系统可用内存不足,无法执行popen系统调用,导致容器初始化失败;
- PostgreSQL初始化工具
initdb无法在指定目录下找到主程序postgres,引发初始化错误。
排查步骤
- 查看PostgreSQL容器的运行日志,确认是否出现
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"报错内容。 - 检查当前部署主机的可用内存资源,确认是否存在内存不足的情况。
- 对比Windows部署环境与当前CentOS环境的配置差异,排查环境相关的配置问题。
- 确认使用的PostgreSQL镜像为
ankane/pgvector:v0.5.0,检查镜像的完整性与正确性。
解决与验证
若为内存不足导致的问题,可调整PostgreSQL容器的内存分配参数,或增加部署主机的可用内存。若为路径配置异常,需按实际环境确认镜像的文件路径配置,或更换符合要求的镜像版本。 验证方式为重启PostgreSQL容器,查看容器日志无上述报错,容器正常运行,且FastGPT功能恢复正常。同时可参考Windows环境的部署配置逻辑进行调整。