2013-07-03 111 views
1

後最後重放WAL繼PostgreSQL的9.2官方文檔,我已經設置了連續歸檔在我postgres.conf文件:的PostgreSQL 9.2歸檔恢復

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

一個成功的備份和恢復後,歸檔命令失敗時數據庫啓動是因爲PostgreSQL試圖歸檔最後一個重播的WAL文件,顯然它已經被歸檔了。我的recovery.conf文件如下:

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

這是當我嘗試啓動數據庫,我發現了錯誤:

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 

這是一個預期的行爲?最後重播的WAL文件是否應該在恢復後歸檔?如果是這樣,歸檔命令應該不會失敗,以防文件已被歸檔(如文檔中所述)。

回答

0

顯然你應該只存檔一次,並恢復你的檔案副本。

我會在恢復過程中關閉存檔,然後再打開它。