[zabbix_server] OSのリブートやシャットダウン時の挙動について

ktokiと申します。

動作環境は、以下の通りです。
・CentOS 5.2
・zabbix-1.6.2
・PostgreSQL 8.3.5

/etc/init.d/postgresql は、chkconfig: 2345 85 15
/etc/init.d/zabbix_server_ctl は、chkconfig: 2345 99 01
としています。

rootで直接、/etc/init.d/zabbix_server_ctl stopを叩いていれば
問題ありませんが、稼動したまま、OSの rebootや shutdownを行う
と、pistgresqlのバックエンドが起動したまま落ちているようで、
それぞれのログに以下のエラーが記録されます。

--- zabbix_server.log -------------
4273:20090202:142942 One child process died. Exiting ...
4273:20090202:142944 [Z3001] Connection to database 'zabbix' failed: [0] could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

4273:20090202:142944 [Z3005] Query failed: [0] Result is NULL [select oid from pg_type where typname = 'bytea']
------------------------------------------

----- pgsql_server.log --------------------
LOG: unexpected EOF on client connection
LOG: unexpected EOF on client connection
LOG: unexpected EOF on client connection
LOG: unexpected EOF on client connection
LOG: unexpected EOF on client connection
LOG: unexpected EOF on client connection
LOG: received smart shutdown request
LOG: autovacuum launcher shutting down
FATAL: terminating connection due to administrator command
FATAL: terminating connection due to administrator command
FATAL: terminating connection due to administrator command
FATAL: terminating connection due to administrator command
FATAL: terminating connection due to administrator command
FATAL: terminating connection due to administrator command
LOG: could not send data to client: Broken pipe
LOG: shutting down
LOG: database system is shut down
------------------------------------------------

同じ様な症状が起きている方はおりませんでしょうか?

zabbix_server_ctl に /etc/init.d/functionsを読み込ませて
killproc -d 30 zabbix_server とかにして、間を空けるように
もしてみましたが、状況は変わりませんでした。

# zabbix_serverのソースも眺めてみましたが、ちょっと判りませんでした。

コメント表示オプション

お好みのコメント表示方法を選び「設定の保存」をクリックすると変更が反映されます。
ユーザー KAZ の写真

ktokiさん

殆ど同一環境で動かしています。

動作環境は、以下の通りです。
・RHEL 5.2
・zabbix-1.6.2
・PostgreSQL 8.3.5

zabbixとpostgresのサービス起動順はどうなっていますか?
起動順:postgres⇒zabbix
停止順:zabbix⇒postgres

上記のような順でないと起動できなかったり、停止時にエラーが出るはずです。

configureインストールのデフォルト設定ですと、zabbixはserverもagentdも90で、postgresは98なので、自動起動しません。当方はpostgresを50、zabbix serverとagentdを99に変更しています。

zabbixより先に起動する必要のあるサービスはnetwork(※1)、DB(postgres/MySQL等)です。

※1:ボンディング/チーミング等行っている場合は、そのサービスも先にあげる必要があります。

ユーザー ktoki の写真

KAZさん

応答ありがとうございます。別件でしばらく遠ざかっていましたが
原因が判明しました。

# ちなみに...
# etc/init.d/postgresql は、chkconfig: 2345 85 15
# /etc/init.d/zabbix_server_ctl は、chkconfig: 2345 99 01
# なので、それぞれ、S85、K15、S99、K01で、順番に問題はありません。

要するに、CentOSの(と言うより SystemV系の?) reboot時や shutdown時の動作を思い込みから誤解していたせいでした。

スクリプト経由で落とされるのは、/var/lock/subsys/ にあるもの
だけなのですね。 rc6.dや rc0.dで Sが付いているスクリプトだけが
実行されているぽっく、/var/lock/subsys/の件は、最初に実行される init.d/killall内に書かれています。
(他は、直接シグナルを送って killしている模様。)

zabbix_serverと postgresqlの起動スクリプトで、/var/lock/subsys/ 内に 登録するよう修正。

postgresql側の stopスクリプトに適当な sleepを加える事で解決しました。

以上、お騒がせ致しました。