在 Docker 中运行的 PostgreSQL 数据库突然无法启动, 错误日志类似这样:
PANIC,XX000,"could not locate a valid checkpoint record",,,,,,,,,""
LOG,00000,"startup process (PID 24) was terminated by signal 6: Aborted",,,,,,,,,""
LOG,00000,"aborting startup due to startup process failure",,,,,,,,,""这种情况多数情况下是在执行事务时, 数据库被强行关闭导致的, 修复的方法是:
pg_resetwal DATADIR 来解决;pg_resetxlog DATADIR 来解决;由于数据库是在 Docker 中运行的, 因此需要按照 Docker 的方式来修复:
使用 pg_resetxlog 或者 pgresetwal 有可能会丢失数据, 启动之后, 需要仔细检查数据库的健康情况。 如果有数据库备份的话, 请尽快进行数还原。
更多请参考 PostgreSQL 的文档 https://www.postgresql.org/docs/current/app-pgresetwal.html
没有了