Postgresql 解决pg掉电后无法重启的问题

时间:2022-03-09 07:50:00

机房断电后重启pg数据库,报如下错误:

?
1
2
3
4
5
6
< 2019-01-01 22:42:59.240 EST >LOG: database system was interrupted while in recovery at 2019-01-01 22:00:58 EST
< 2019-01-01 22:42:59.240 EST >HINT: This probably means that some data is corrupted and you will have to use the last backup for recovery.
< 2019-01-01 22:42:59.241 EST >LOG: database system was not properly shut down; automatic recovery in progress
< 2019-01-01 22:42:59.333 EST >PANIC: unexpected pageaddr 26EA/46000000 in log segment 00000001000026EA00000017, offset 0
< 2019-01-01 22:42:59.333 EST >LOG: startup process (PID 88586) was terminated by signal 6: Aborted
< 2019-01-01 22:42:59.333 EST >LOG: aborting startup due to startup process failure

修复方法:

 

切换到bin目录下:

?
1
cd /usr/pgsql-9.3/bin

使用pg_resetxlog命令修复日志:(/var/lib/pgsql/9.3/data为pg_data的目录)

?
1
pg_resetxlog -f /var/lib/pgsql/9.3/data

重启数据库:

?
1
pg_ctl start

补充:PostgreSQL 数据库服务无法启动的解决方法

因为客户那边的磁盘一般是FAT32的文件系统,所以我们程序安装时,采用手动安装PostgreSQL的形式安装数据库,但初始化数据库群成功并且成功注册了系统服务后,

发现PostgreSQL的服务总是启动不了,提示服务启动又停止了,然后在系统时间查看器里发现报的错误是:Could not create inherited socket, 错误编码为10022

解决方法:

 

运行 netsh winsock reset,重启电脑,OK!

以上为个人经验,希望能给大家一个参考,也希望大家多多支持服务器之家。如有错误或未考虑完全的地方,望不吝赐教。

原文链接:https://blog.csdn.net/NextAction/article/details/85606530