记录一次PostgreSQL连接失败问题

发布于:2023-09-14 ⋅ 阅读:(162) ⋅ 点赞:(0)

harbor版本:v1.10.8

操作系统版本:

[root@host157 clair]# cat /etc/.productinfo 
KYLIN Linux Advanced Server
V10(SP1)/(Tercel)-sw64-Build20.1-20210518-JUN
[root@host157 clair]# 

容器化部署harbor,harbor-core这个容器一直处于restarting状态,查看harbor-core日志,显示无法连接PostgreSQL,错误显示:

Oct 14 14:45:26 _gateway core[1729289]: 2021-10-14T06:45:26Z [ERROR] [/common/utils/utils.go:101]: failed to connect to tcp://postgresql:5432, retry after 2 seconds :dial tcp 192.168.32.7:5432: connect: connection refused

出现上述问题时,需修改postgresql.conf

这个文件在postgresql数据文件目录中,容器中默认为/var/lib/postgresql/data/。将postgresql.conf修改如下:listen_addresses = '*',对所有的地址监听。

或者修改data_volumedatabase目录中的postgresql.conf文件。

重启harbor-db和harbor-core这两个容器这两个容器,先重启harbor-db,再重启harbor-core即可。

参考文章:初识Postgresql和Sqoop - smilezjw的个人页面 - OSCHINA - 中文开源技术交流社区