[root@localhost ~]# pg_dumpall -U postgres -h 195.168.116.135 -p 5432 > /home/backup/alltest01.sql
pg_dumpall: 错误: 无法与数据库 "template1" 联接: 无法联接到服务器: 拒绝连接
服务器是否在主机 "195.168.116.135" 上运行并且准备接受在端口
5432 上的 TCP/IP 联接?
查看数据库状态,failed
[root@localhost bin]# systemctl status postgresql-12.service
● postgresql-12.service - PostgreSQL 12 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 日 2022-05-22 09:32:47 CST; 6min ago
Docs: https://www.postgresql.org/docs/12/static/
Process: 82814 ExecStart=/usr/pgsql-12/bin/postmaster -D ${PGDATA} (code=exited, status=1/FAILURE)
Process: 82808 ExecStartPre=/usr/pgsql-12/bin/postgresql-12-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 82814 (code=exited, status=1/FAILURE)
5月 22 09:32:47 localhost.localdomain systemd[1]: Starting PostgreSQL 12 database server...
5月 22 09:32:47 localhost.localdomain postmaster[82814]: 2022-05-22 09:32:47.745 CST [82814] 致命错误: 锁文件 "postmaster.pid" 已经存在
5月 22 09:32:47 localhost.localdomain systemd[1]: postgresql-12.service: main process exited, code=exited, status=1/FAILURE
5月 22 09:32:47 localhost.localdomain systemd[1]: Failed to start PostgreSQL 12 database server.
5月 22 09:32:47 localhost.localdomain systemd[1]: Unit postgresql-12.service entered failed state.
5月 22 09:32:47 localhost.localdomain systemd[1]: postgresql-12.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
发现服务关闭,而且重新启动不了
1、查看 postmaster.pid 的具体位置
[root@localhost bin]# find / -name postmaster.pid
/var/lib/pgsql/12/data/postmaster.pid
2、查看postgres进程,使用kill删除所有进程:注意kill PID
3、删除postmaster.pid 文件
[root@localhost bin]# rm -rf /var/lib/pgsql/12/data/postmaster.pid
4、再次启动并查看,服务成功重新启动
[root@localhost bin]# systemctl start postgresql-12.service
[root@localhost bin]#
[root@localhost bin]# systemctl status postgresql-12.service
● postgresql-12.service - PostgreSQL 12 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-12.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2022-05-22 09:44:56 CST; 13s ago