zhaiduo.com

Loving Coding & Visual Design

PostgreSQL 11 报错:PANIC: could not locate a valid checkpoint record

Docker up 的时候,显示 PostgreSQL 启动失败:

db_1     | 2019-10-07 05:51:27.608 UTC [22] LOG:  database system was interrupted; last known up at 2019-10-06 10:17:33 UTC
db_1     | 2019-10-07 05:52:03.416 UTC [22] LOG:  invalid record length at 0/1832AA8: wanted 24, got 0
db_1     | 2019-10-07 05:52:03.416 UTC [22] LOG:  invalid primary checkpoint record
db_1     | 2019-10-07 05:52:03.416 UTC [22] PANIC:  could not locate a valid checkpoint record


解决办法:
1. 登录 postgres : docker run -ti postgres /bin/bash
2. 切换到 postgres 用户
3. 执行修复命令:/usr/lib/postgresql/11/bin/pg_resetwal -f /var/lib/postgresql/data
4. 如果看到“Write-ahead log reset”,表示修复成功。