gpt4 book ai didi

postgresql - 无法连接到端口 5432 上的服务器(PostgreSQL - CentOS 7.4)

转载 作者:行者123 更新时间:2023-12-04 19:42:26 24 4
gpt4 key购买 nike

尝试连接到数据库时,我收到此消息“无法连接到服务器。服务器是否在主机 10.9.10.83 上运行并接受端口 5432 上的 TCP/IP 连接?”
昨天与数据库的连接工作正常,但今天我收到了这条消息。我关闭了我的电脑,电池没电了,然后这个问题就发生了,所以它可能是相关的。如何修复连接?

我运行命令:postgresql-10.service status。
结果是这样的:

 Redirecting to /bin/systemctl status postgresql-10.service
● postgresql-10.service - PostgreSQL 10 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-10.service; enabled; vendor preset: disabled)
Active: active (running) since sam. 2018-07-21 16:35:53 CEST; 41min ago
Docs: https://www.postgresql.org/docs/10/static/
Process: 4997 ExecReload=/bin/kill -HUP $MAINPID (code=exited, status=0/SUCCESS)
Process: 4909 ExecStartPre=/usr/pgsql-10/bin/postgresql-10-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 4915 (postmaster)
CGroup: /system.slice/postgresql-10.service
├─4915 /usr/pgsql-10/bin/postmaster -D /var/lib/pgsql/10/data/
├─4917 postgres: logger process
├─4919 postgres: checkpointer process
├─4920 postgres: writer process
├─4921 postgres: wal writer process
├─4922 postgres: autovacuum launcher process
├─4923 postgres: stats collector process
├─4924 postgres: bgworker: logical replication launcher
├─4932 postgres: etpta etpta 127.0.0.1(60872) idle
├─5061 postgres: etpta etpta 127.0.0.1(33322) idle
├─7739 postgres: etpta etpta 10.9.10.83(35034) idle
├─7747 postgres: etpta etpta 10.9.10.83(35036) idle
├─7748 postgres: etpta etpta 10.9.10.83(35038) idle
├─7749 postgres: etpta etpta 10.9.10.83(35040) idle
├─7750 postgres: etpta etpta 10.9.10.83(35042) idle
├─7751 postgres: etpta etpta 10.9.10.83(35044) idle
├─7752 postgres: etpta etpta 10.9.10.83(35046) idle
├─7753 postgres: etpta etpta 10.9.10.83(35048) idle
├─7770 postgres: etpta etpta 10.9.10.83(35066) idle
├─7790 postgres: etpta etpta 10.9.10.83(35788) idle
├─7809 postgres: etpta etpta 10.9.10.83(35948) idle
├─7847 postgres: etpta etpta 10.9.10.83(35958) idle
├─7849 postgres: etpta etpta 10.9.10.83(35960) idle
├─7852 postgres: etpta etpta 10.9.10.83(35962) idle
├─7855 postgres: etpta etpta 10.9.10.83(35968) idle
├─7863 postgres: etpta etpta 10.9.10.83(35972) idle
└─7867 postgres: etpta etpta 10.9.10.83(35978) idle

和 :
[root@VM-ACTION telnet]# netstat -antpl | grep 5432
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN 14507/postmaster
tcp 0 0 10.9.10.83:5432 10.9.10.83:40942 ESTABLISHED 16181/postgres: etp
tcp 126 0 10.9.10.83:58240 10.9.10.83:5432 CLOSE_WAIT 12980/hrmtpr
tcp 126 0 10.9.10.83:58212 10.9.10.83:5432 CLOSE_WAIT 12950/hrmtrt
tcp 126 0 10.9.10.83:58210 10.9.10.83:5432 CLOSE_WAIT 12948/hrmdisp
tcp 0 0 127.0.0.1:5432 127.0.0.1:41280 ESTABLISHED 14586/postgres: etp
tcp 0 0 10.9.10.83:5432 10.9.10.83:40936 ESTABLISHED 16178/postgres: etp
tcp 126 0 10.9.10.83:58214 10.9.10.83:5432 CLOSE_WAIT 12951/hrmtrt
tcp 126 0 10.9.10.83:58218 10.9.10.83:5432 CLOSE_WAIT 12953/hrmtrt
tcp 0 0 10.9.10.83:5432 10.9.10.83:40934 ESTABLISHED 16176/postgres: etp
tcp 0 0 10.9.10.83:40928 10.9.10.83:5432 ESTABLISHED 16140/hrmlog
tcp 0 0 10.9.10.83:40942 10.9.10.83:5432 ESTABLISHED 16180/hrmtra
tcp 0 0 10.9.10.83:40932 10.9.10.83:5432 ESTABLISHED 16173/hrmsrv
tcp 0 0 10.9.10.83:40952 10.9.10.83:5432 ESTABLISHED 16192/hrmtra
tcp 0 0 10.9.10.83:40936 10.9.10.83:5432 ESTABLISHED 16177/hrmtra
tcp 0 0 10.9.10.83:5432 10.9.10.83:40928 ESTABLISHED 16141/postgres: etp
tcp 126 0 10.9.10.83:58964 10.9.10.83:5432 CLOSE_WAIT 13017/adtacq
tcp 0 0 127.0.0.1:5432 127.0.0.1:41236 ESTABLISHED 14520/postgres: etp
tcp 0 0 10.9.10.83:5432 10.9.10.83:40932 ESTABLISHED 16174/postgres: etp
tcp 0 0 10.9.10.83:5432 10.9.10.83:40952 ESTABLISHED 16193/postgres: etp
tcp 0 0 10.9.10.83:40934 10.9.10.83:5432 ESTABLISHED 16175/hrmtra
tcp 126 0 10.9.10.83:58220 10.9.10.83:5432 CLOSE_WAIT 12954/hrmtrt
tcp 0 0 10.9.10.83:40946 10.9.10.83:5432 ESTABLISHED 16188/hrmtra
tcp 126 0 10.9.10.83:58216 10.9.10.83:5432 CLOSE_WAIT 12952/hrmtrt
tcp 0 0 10.9.10.83:5432 10.9.10.83:52714 TIME_WAIT -
tcp 126 0 10.9.10.83:58222 10.9.10.83:5432 CLOSE_WAIT 12955/hrmtrt
tcp 0 0 10.9.10.83:5432 10.9.10.83:40946 ESTABLISHED 16189/postgres: etp
tcp6 0 0 :::5432 :::* LISTEN 14507/postmaster
tcp6 0 0 127.0.0.1:41236 127.0.0.1:5432 ESTABLISHED 2422/java
tcp6 0 0 127.0.0.1:41280 127.0.0.1:5432 ESTABLISHED 2422/java

最佳答案

尝试

telnet 10.9.10.83 5432

如果没有应答,则服务器未在此 IP 上监听。
尝试
netstat -antpl | grep 5432

并检查 postgres 监听的 IP,也许 10.9.10.83 不是正确的 IP。

检查 postgresql 日志文件以获取线索。

关于postgresql - 无法连接到端口 5432 上的服务器(PostgreSQL - CentOS 7.4),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51457125/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com