这个报错发生在主备切换后,老主降为配后产生的错误。
类似下面的报错:
发生这样的错误的原因是:
备用服务器在能够赶上主服务器之前已经升级,导致现在主服务器不能充当备用服务器的角色。
解决方法:
使得pg_rewind 同步数据库时间线。参考
具体流程:
- 先停止服务。(如:
kill
-INT `
head
-1
/usr/local/pg/data/postmaster
.pid`
) - pg_rewind /u01/pgsql/bin/pg_rewind --target-pgdata=/u01/pg3306/data --source-server='host=xxx.xx.xx.xx port=3306 user=test dbname=postgres password=test'
注意:执行pg_rewind需要wal_log_hints 设置成 on 或者 PG 在初始化时开启 checksums 功能