2010-08-11 81 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。