2010-08-11 204 views
2

我有一個工作的WAL運行安裝程序,它具有應用WAL文件的熱備用從屬服務器。Postgresql pg_standby永久執行故障轉移

當我創建pg_standby觸發器文件時,它立即檢測到它,但實際上已準備好接受連接需要大約10-15分鐘。大部分時間都花在等待.history文件上。

觸發器文件爲空,因此應該執行「智能」故障切換。我能做些什麼來使故障轉移(更快)?

日誌輸出:

WAL file not present yet. Checking for trigger file... 
trigger file found: smart failover 
LOG: could not open file "pg_xlog/000000010000000000000089" (log file 0, segment 137): No such file or directory 
LOG: redo done at 0/88003428 
LOG: last completed transaction was at log time 2010-08-10 13:26:20.232799+00 
Trigger file  : /psql_archive/role.master 
Waiting for WAL file : 000000010000000000000088 
WAL file path  : /psql_archive/000000010000000000000088 
Restoring to  : pg_xlog/RECOVERYXLOG 
Sleep interval  : 60 seconds 
Max wait interval : 0 forever 
Command for restore : cp "/psql_archive/000000010000000000000088" "pg_xlog/RECOVERYXLOG" 
Keep archive history : 000000000000000000000000 and later 
trigger file found: smart failover 
running restore  : OK 

LOG: restored log file "000000010000000000000088" from archive 
Trigger file  : /psql_archive/role.master 
Waiting for WAL file : 00000002.history 
WAL file path  : /psql_archive/00000002.history 
Restoring to  : pg_xlog/RECOVERYHISTORY 
Sleep interval  : 60 seconds 
Max wait interval : 0 forever 
Command for restore : cp "/psql_archive/00000002.history" "pg_xlog/RECOVERYHISTORY" 
Keep archive history : 000000000000000000000000 and later 
running restore  :cp: cannot stat `/psql_archive/00000002.history': No such file or directory 
cp: cannot stat `/psql_archive/00000002.history': No such file or directory 
cp: cannot stat `/psql_archive/00000002.history': No such file or directory 
cp: cannot stat `/psql_archive/00000002.history': No such file or directory 
not restored 
history file not found 
LOG: selected new timeline ID: 2 
Trigger file  : /psql_archive/role.master 
Waiting for WAL file : 00000001.history 
WAL file path  : /psql_archive/00000001.history 
Restoring to  : pg_xlog/RECOVERYHISTORY 
Sleep interval  : 60 seconds 
Max wait interval : 0 forever 
Command for restore : cp "/psql_archive/00000001.history" "pg_xlog/RECOVERYHISTORY" 
Keep archive history : 000000000000000000000000 and later 
running restore  :cp: cannot stat `/psql_archive/00000001.history': No such file or directory 
cp: cannot stat `/psql_archive/00000001.history': No such file or directory 
cp: cannot stat `/psql_archive/00000001.history': No such file or directory 
cp: cannot stat `/psql_archive/00000001.history': No such file or directory 
not restored 
history file not found 
LOG: archive recovery complete 
LOG: autovacuum launcher started 
LOG: database system is ready to accept connections 

感謝。

丹尼斯

回答

0

根據文檔:http://www.postgresql.org/docs/current/static/pgstandby.html

快速故障切換:在快速故障轉移,服務器被立即恢復。歸檔中尚未應用的任何WAL文件都將被忽略,並且這些文件中的所有事務都將丟失。要觸發快速故障轉移,請創建一個觸發器文件並將其快速寫入該文件。如果在定義的時間間隔內沒有出現新的WAL文件,也可以配置pg_standby以自動執行快速故障轉移。

或者查看「表F-23。pg_standby選項」,其中描述了maxwaittime。

乾杯

+0

我知道快速與智能故障切換。我們故意使用'聰明'。但主服務器上沒有活動,WAL存檔目錄中沒有任何內容可以讀取和應用。 從日誌判斷它等待文件很長時間,即使'智能'還原應該只應用可用的WAL文件,據我瞭解。 至少我認爲10-15分鐘的方式太長,當沒有WAL文件申請。 – 2010-08-13 07:36:12

1

總之,如果你不使用快速故障轉移pg_standby將繼續處理那剩下的所有日誌(因爲它應該),以減少數據丟失。

爲了讓您的生活更輕鬆我會看看PITRTools。