简体   繁体   English

恢复后的PostgreSQL 9.2归档上次重播了WAL

[英]PostgreSQL 9.2 archiving last replayed WAL after recovery

Following the PostgreSQL 9.2 official documentation, I have set up continuous archiving on my postgres.conf file: 遵循PostgreSQL 9.2官方文档后,我在postgres.conf文件中设置了持续归档:

wal_level = archive
archive_mode = on
archive_command = 'test ! -f /.../archive/%f && cp %p /.../archive/%f'

After a successful backup and recovery, the archive command fails when the database is started because PostgreSQL is trying to archive the last replayed WAL file, and obviously, it'd already been archived. 成功备份和恢复后,启动数据库时archive命令失败,因为PostgreSQL试图归档上一个重播的WAL文件,而且显然已经被归档了。 My recovery.conf file is the following: 我的recovery.conf文件如下:

restore_command = 'cp /.../archive/%f "%p"'
recovery_target_time = '2013-07-02 15:20:12'

And this is the error I'm getting when I try to start the database: 这是我尝试启动数据库时遇到的错误:

LOG:  database system was interrupted; last known up at 2013-07-02 14:53:37 CEST
LOG:  creating missing WAL directory "pg_xlog/archive_status"
LOG:  starting point-in-time recovery to 2013-07-02 15:20:12+02
LOG:  restored log file "000000010000000000000002" from archive
LOG:  redo starts at 0/2000020
LOG:  consistent recovery state reached at 0/20023D0
LOG:  restored log file "000000010000000000000003" from archive
LOG:  recovery stopping before commit of transaction 4063, time 2013-07-02 15:20:12.211559+02
LOG:  redo done at 0/306D8B8
LOG:  last completed transaction was at log time 2013-07-02 15:20:11.189978+02
cp: cannot stat `/.../archive/00000002.history': No such file or directory
LOG:  selected new timeline ID: 2
cp: cannot stat `/.../archive/00000001.history': No such file or directory
LOG:  archive recovery complete
LOG:  autovacuum launcher started
LOG:  database system is ready to accept connections
LOG:  archive command failed with exit code 1
DETAIL:  The failed archive command was: test ! -f /.../archive/000000010000000000000003 && cp pg_xlog/000000010000000000000003 /.../archive/000000010000000000000003
LOG:  archive command failed with exit code 1
DETAIL:  The failed archive command was: test ! -f /.../archive/000000010000000000000003 && cp pg_xlog/000000010000000000000003 /.../archive/000000010000000000000003
LOG:  archive command failed with exit code 1
DETAIL:  The failed archive command was: test ! -f /.../archive/000000010000000000000003 && cp pg_xlog/000000010000000000000003 /.../archive/000000010000000000000003
WARNING:  transaction log file "000000010000000000000003" could not be archived: too many failures

Is this an expected behaviour? 这是预期的行为吗? Should the last replayed WAL file be archived after recovery? 恢复后是否应存档最后一个重播的WAL文件? If so, the archive command should not fail in case the file is already archived (as mentioned in the documentation). 如果是这样,如果文件已被存档(如文档中所述),则archive命令应该不会失败。

Obviously you should only archive once and recover off copies of your archives. 显然,您只应存档一次并从存档副本中恢复。

I would turn off archiving during recovery and then turn it on after. 我会在恢复过程中关闭存档,然后再打开它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM