在主数据库和热备数据库之间建立同步流复制。
在备用数据库上执行每日备份以避免主数据库出现任何性能问题似乎是个好主意。
使用 pg_basebackup 成功恢复了备用数据库的备份。存档的 WAL 文件在本地传输,并且在 recovery.conf 中添加了 restore_command 以指向它们 - 在启动数据库时在日志文件中记录了以下错误:
cp: cannot stat ‘/archivedir/wal_arch/00000002.history’: No such file or directory
2016-05-12 17:33:52 BST LOG: starting archive recovery
cp: cannot stat ‘/archivedir/wal_arch/0000000100000000000000E7’: No such file or directory
2016-05-12 17:33:52 BST LOG: redo starts at 0/E7000CA0
2016-05-12 17:33:52 BST LOG: consistent recovery state reached at 0/E7000D80
2016-05-12 17:33:52 BST LOG: invalid resource manager ID 100 at 0/E7000D80
2016-05-12 17:33:52 BST LOG: redo done at 0/E7000D48
cp: cannot stat ‘/archivedir/wal_arch/0000000100000000000000E7’: No such file or directory
cp: cannot stat ‘/archivedir/wal_arch/00000002.history’: No such file or directory
2016-05-12 17:33:52 BST LOG: selected new timeline ID: 2
cp: cannot stat ‘/archivedir/wal_arch/00000001.history’: No such file or directory
2016-05-12 17:33:52 BST LOG: archive recovery complete
2016-05-12 17:33:52 BST LOG: MultiXact member wraparound protections are now enabled
2016-05-12 17:33:52 BST LOG: database system is ready to accept connections
2016-05-12 17:33:52 BST LOG: autovacuum launcher started
备份备用数据库而不是主数据库是个好主意吗?
是的,这可能是个好主意。事实上,允许这是 PostgreSQL 9.2 版本中的一个主要特性。