[pgsql-jp: 32940] Re: pgpoolのfailover について
HIRANO Yoshitaka
yo @ hirano.cc
2004年 5月 15日 (土) 05:28:29 JST
> たぶん根本的な解決は,多くのHAソフトがやっているような,ハートビートを
> 方法だと思いますが,何かアイデアがあれば私も教えて欲しいです.
なるほど、やっぱり、pgpool側では切断を知る方法はないんですかね。
石井さんのアイデアを受けて、次のようにしてみました。
これで、LANケーブルを引っこ抜いた場合も、期待通り動いている
ようです。
------------------------------------------------------------------------
*** pgpool-1.2.1/child.c Sat May 8 11:03:27 2004
--- pgpool-1.2.1_hira2/child.c Sat May 15 02:40:25 2004
***************
*** 56,61 ****
--- 56,62 ----
static void reset_backend(POOL_CONNECTION *backend);
static void cancel_request(CancelPacket *cp, int secondary_backend);
static RETSIGTYPE die(int sig);
+ static RETSIGTYPE backend_timeout();
/*
* child main loop
***************
*** 79,84 ****
--- 80,86 ----
signal(SIGCHLD, SIG_DFL);
signal(SIGUSR1, SIG_DFL);
signal(SIGPIPE, SIG_IGN);
+ signal(SIGUSR2, backend_timeout);
#ifdef NONE_BLOCK
/* set listen fds to none block */
***************
*** 624,626 ****
--- 626,636 ----
{
exit(0);
}
+
+ static RETSIGTYPE backend_timeout()
+ {
+ pool_debug("backend connection error occured");
+
+ notice_backend_error();
+ exit(1);
+ }
------------------------------------------------------------------------
監視スクリプト
#!/bin/csh -f
set hosts = (192.168.5.161 192.168.5.163)
while (1)
foreach host ($hosts)
ping -q -n -c 1 -w 1 $host > /dev/null
if ($status == 1) then
set pids = `netstat -anp | grep ${host}:5432 | tr '/' ' ' | awk '{print $7}'`
foreach pid ($pids)
if ("$pid" != "-") then
echo $host cannot be reached. notice to process $pid
kill -USR2 $pid
endif
end
endif
sleep 1
end
end
------------------------------------------------------------------------
pgsql-jp メーリングリストの案内