主服务器
# postgresql.conf
wal_level = hot_standby
archive_mode = on
archive_timeout = 10
archive_command = 'test ! -f /archive/%f && cp %p /archive/%f'
备用服务器
hot_standby = on
我将主服务器复制/archive/*
到备用服务器,$PGDATA/pg_xlog
但没有任何反应。当我重新启动备用服务器时,我从服务器日志中收到错误消息:
2016-11-21 17:56:09 CST [17762-3] LOG: invalid primary checkpoint record
2016-11-21 17:56:09 CST [17762-4] LOG: record with zero length at 0/6000100
2016-11-21 17:56:09 CST [17762-5] LOG: invalid secondary checkpoint record
2016-11-21 17:56:09 CST [17762-6] PANIC: could not locate a valid checkpoint record
2016-11-21 17:56:09 CST [17761-1] LOG: startup process (PID 17762) was terminated by signal 6: Aborted
2016-11-21 17:56:09 CST [17761-2] LOG: aborting startup due to startup process failure
问题:
/archive/*
只需将主服务器复制到备用服务器就足以将数据同步到备用服务器$PGDATA/pg_xlog
吗?如何以及何时在热备用服务器中触发 WAL 文件的恢复?备用服务器是否定期检查其
$PGDATA/pg_xlog
目录是否有新的 WAL 文件?还是我必须手动触发它?我说的是热备份,而不是流复制;所以我假设我不必配置
conninfo
. 我对吗?配置
hot_standby = on
并重新启动服务器后,我仍然可以毫无错误地进行操作INSERT
。如何配置使其真正只读?