查看pgstartup.log日志

[root@developer pgsql-12]# tail -f /zbomc/pgsql/log/pgstartup.log
2021-05-21 14:57:29.246 CST [719012] LOG:  starting PostgreSQL 12.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-23), 64-bit
2021-05-21 14:57:29.246 CST [719012] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2021-05-21 14:57:29.248 CST [719012] LOG:  could not create IPv6 socket for address "::": Address family not supported by protocol
2021-05-21 14:57:29.260 CST [719012] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2021-05-21 14:57:29.264 CST [719012] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2021-05-21 14:57:29.279 CST [719012] LOG:  redirecting log output to logging collector process
2021-05-21 14:57:29.279 CST [719012] HINT:  Future log output will appear in directory "log".

core文件

解析core文件

gdb /usr/pgsql-12/bin/postmaster core.722359
Loaded symbols for /lib64/libnss_dns.so.2
Core was generated by `postgres: startup                                '.
Program terminated with signal 6, Aborted.
#0  0x00007fea32c6f4f5 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: debuginfo-install postgresql12-server-12.4-1PGDG.rhel6.x86_64
(gdb) bt
#0  0x00007fea32c6f4f5 in raise () from /lib64/libc.so.6
#1  0x00007fea32c70cd5 in abort () from /lib64/libc.so.6
#2  0x00000000008812bb in errfinish ()
#3  0x00000000005120c5 in StartupXLOG ()
#4  0x00000000006f7e81 in StartupProcessMain ()
#5  0x000000000051d65f in AuxiliaryProcessMain ()
#6  0x00000000006f2ae4 in ?? ()
#7  0x00000000006f6fe5 in PostmasterMain ()
#8  0x0000000000667f20 in main ()

查看postgresql日志

cd /zbomc/pgsql/data/log
tail -f postgresql-Fri.log
报错信息:
2021-05-21 15:52:45.579 CST [722359] LOG:  database system was interrupted; last known up at 2021-05-19 16:45:39 CST
2021-05-21 15:52:45.975 CST [722360] FATAL:  the database system is starting up
2021-05-21 15:52:46.151 CST [722359] LOG:  invalid primary checkpoint record
2021-05-21 15:52:46.151 CST [722359] PANIC:  could not locate a valid checkpoint record
2021-05-21 15:52:46.377 CST [722352] LOG:  startup process (PID 722359) was terminated by signal 6: Aborted
2021-05-21 15:52:46.377 CST [722352] LOG:  aborting startup due to startup process failure
2021-05-21 15:52:46.395 CST [722352] LOG:  database system is shut down

解决

[root@developer log]# /usr/pgsql-12/bin/pg_resetwal -f /zbomc/pgsql/data/
pg_resetwal: 错误: 不能由"root"执行
pg_resetwal: 您现在作为PostgreSQL超级用户运行pg_resetwal.
使用su  切换至postgres用户便于执行 pg_resetwal 
[root@developer log]# su - postgres
-bash-4.1$ /usr/pgsql-12/bin/pg_resetwal -f /zbomc/pgsql/data/
重置预写日志
-bash-4.1$

重启pg数据库成功

[root@developer ~]# service postgresql-12 start
Starting postgresql-12 service:                            [  OK  ]
文档更新时间: 2021-05-21 02:07   作者:周风磊