postgres在Rocky Linux 8.5上运行
sudo systemctl status postgresql-14
● postgresql-14.service - PostgreSQL 14 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/postgresql-14.service.d
└─override.conf
Active: active (running) since Thu 2022-03-10 04:31:09 GMT; 16min ago
Docs: https://www.postgresql.org/docs/14/static/
Process: 67527 ExecStartPre=/usr/pgsql-14/bin/postgresql-14-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 67534 (postmaster)
Tasks: 8 (limit: 101066)
Memory: 18.3M
CGroup: /system.slice/postgresql-14.service
├─67534 /usr/pgsql-14/bin/postmaster -D /mnt/data/db-rocky-primary/data
├─67536 postgres: logger
├─67538 postgres: checkpointer
├─67539 postgres: background writer
├─67540 postgres: walwriter
├─67541 postgres: autovacuum launcher
├─67542 postgres: stats collector
└─67543 postgres: logical replication launcher
Mar 10 04:31:08 db-primary-rocky systemd[1]: Starting PostgreSQL 14 database server...
Mar 10 04:31:09 db-primary-rocky postmaster[67534]: 2022-03-10 04:31:09.590 GMT [67534] LOG: redirecting log output to logging collector process
Mar 10 04:31:09 db-primary-rocky postmaster[67534]: 2022-03-10 04:31:09.590 GMT [67534] HINT: Future log output will appear in directory "log".
Mar 10 04:31:09 db-primary-rocky systemd[1]: Started PostgreSQL 14 database server.我可以连接到它时,没有问题时,在方框:
psql
psql (14.2)
Type "help" for help.
postgres=# \conninfo
You are connected to database "postgres" as user "postgres" via socket in "/var/run/postgresql" at port "5432".我已将其添加到pg_hba.conf文件中:
host all all 192.168.1.0/24 trust我还在postgresql.conf文件和restarted the server中更改了以下内容
listen_addresses = '*'为什么我不能通过pgadmin4连接到它?我坐在192.168.1.0/24网络和运行在192.168.1.0/24网络中的PostgreSQL中。
这两个网络可以互相连接。pgadmin4给出connection refused错误。我不知道为什么?我遗漏了什么?
谢谢
发布于 2022-03-12 08:17:21
根据@Nic3500的评论,我就是这样修正的:
检查postgres是否正在监听指定端口:
sudo netstat -nltp现在检查是否启用了防火墙:
systemctl status firewalld
OR
sudo firewall-cmd --state如果服务处于活动状态并正在运行,那么只需执行以下操作:
sudo firewall-cmd --add-service=postgresql使设置永久化:
sudo firewall-cmd --runtime-to-permanent现在你可以不带任何问题的连接
https://stackoverflow.com/questions/71445520
复制相似问题