问题描述
我们有一个 Postgres 11 集群,包含一台主服务器和一台热复制服务器。复制服务器已停止工作很长时间。但是,主服务器遇到了意外的电源故障。之后,它无法重新启动,并且日志说:
2021-05-10 10:20:09.134 UTC [1] LOG: listening on IPv4 address "0.0.0.0",port 5432
2021-05-10 10:20:09.134 UTC [1] LOG: listening on IPv6 address "::",port 5432
2021-05-10 10:20:09.137 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGsql.5432"
2021-05-10 10:20:09.245 UTC [22] LOG: database system was shut down at 2021-05-10 09:30:22 UTC
2021-05-10 10:20:09.248 UTC [22] PANIC: replication slot file "pg_replslot/replica_1_slot/state" has wrong magic number: 842020920 instead of 17112225
2021-05-10 10:20:09.531 UTC [1] LOG: startup process (PID 22) was terminated by signal 6
2021-05-10 10:20:09.531 UTC [1] LOG: aborting startup due to startup process failure
2021-05-10 10:20:09.546 UTC [1] LOG: database system is shut down
有什么办法可以解决这个问题?非常感谢。
解决方法
关闭PostgreSQL,进入数据目录并运行
rm -r pg_replslot/replica_1_slot
如果这是您唯一的问题,那么删除复制槽就可以解决问题。
但是,复制槽通常不会像那样损坏。可能还有其他损坏的文件。
如果您可以这样启动服务器,请立即获取 pg_dumpall
,如果成功,将其恢复到不同硬件上的新集群。如果无法启动服务器,请对数据目录进行文件系统备份。
测试您的硬件,这可能是问题所在。