From: Haruka harukat Date: Mon, 29 Dec 2008 06:39:24 +0000 (+0000) Subject: * add "pidfile" parameter X-Git-Tag: PGPOOL_HA_1_2~3 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=7f9aff166c2d683759aa4ea5e8f632b0751dc15d;p=pgpoolha.git * add "pidfile" parameter * fix typo bug "lexit" * renew sample cib.xml in document (test on heartbeat 2.1.4) * reform indent format of scripts --- diff --git a/ChangeLog b/ChangeLog index a736dde..19744f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,18 +1,23 @@ 2006/8/21 initial release - - - 2007/6/XX release 1.1 - -* fix ocf script to work properly with pgpool 3.2+ . -* Works well with pgpool-II. -* New configuration variables added . - you can specify path of configuration files . It means you can run multiple pgpool instances on single heartbeat instance. + * fix ocf script to work properly with pgpool 3.2+ . + * Works well with pgpool-II. + * New configuration variables added . + you can specify path of configuration files . + It means you can run multiple pgpool instances on single heartbeat + instance. pgpoolconf path to pgpool.conf pcpconf path to pcp.conf hbaconf path to pool_hba/.conf -* support log redirection . use "logfile" parameter to specify logfile location.If you set this parameter. If you specify logfile parameter , "-d" option added automaticully. + * support log redirection . use "logfile" parameter to specify logfile + location.If you set this parameter. If you specify logfile parameter , + "-d" option added automaticully. + +2008/12/29 1.2-dev + * add "pidfile" parameter + * fix bugs + * renew sample cib.xml tested on heartbeat 2.1.4 diff --git a/README b/README index d24dce7..1e9aa10 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ pgpool-ha - Heartbeat scripts for pgpool -TANIDA Yutaka(tanida@sraoss.co.jp) +TANIDA Yutaka, TAKATSUKA Haruka (harukat@sraoss.co.jp) 1. What's this? @@ -13,8 +13,8 @@ This is a scripts to combine both pgpool and heartbeat. Pgpool is a replication 2.0+ required. - pgpool - Tested on 3.0+ only , but It will work if 'show pool_status' command was supported. - pgpool.conf on default path is only supported. + Tested on pgpool-II only , but It will work if 'show pool_status' command + was supported. - PostgreSQL 7.0+ 'psql' also needed for install hosts . postmaster doesn't required. diff --git a/doc/pgpool-ha.en.txt b/doc/pgpool-ha.en.txt index 90d9d2e..8a47789 100644 --- a/doc/pgpool-ha.en.txt +++ b/doc/pgpool-ha.en.txt @@ -1,4 +1,4 @@ -t's this? +1. What's this? This is a scripts to integrate pgpool and heartbeat. Pgpool is a replication server of PostgreSQL and makes reliability ,but pgpool @@ -13,12 +13,11 @@ This software contains: 2. Requirement - heartbeat - 2.0+ required. + 2.0+ required. (Tested on 2.1.4 only) - pgpool - Tested on 3.0+ only , but It will work if 'show pool_status' command was -supported. - pgpool.conf on default path is only supported. + Tested on pgpool-II only , but It will work if 'show pool_status' command + was supported. - PostgreSQL client installation. 'psql' also required for install hosts . 'postmaster' doesn't required. @@ -55,85 +54,95 @@ heartbeat installation. -----Sample cib.xml start - + - + - - - - - - - - - - + + + + + - - + + + + + + + + + + + + + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + ----- Sample cib.xml end. @@ -150,28 +159,9 @@ Config File , Parameter , pgpool.conf , pgpoolconf , pool_hba.conf , hbaconf , pgpool 3.2+ only pcp.conf , pcpconf , pgpool-II only +log file , logfile , +pid file , pidfile , e.g. /tmp/pgpool.pid -Here is an example how to specify paths of config files. --- - - - - - - - - - - - - - -- Following entries in pgpool.conf will be referrenced to monitor pgpool. @@ -191,85 +181,7 @@ user/role ,database and pg_hba.conf entry to connect from pgpool host by - Active - Active configuration. Pgpool-ha 1.1+ supports multiple configuration , so it can support -active-active style configuration . Here is an exmaple. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +active-active style configuration . 4. Restriction diff --git a/doc/pgpool-ha.ja.txt b/doc/pgpool-ha.ja.txt index e45d3d9..2e30dfc 100644 --- a/doc/pgpool-ha.ja.txt +++ b/doc/pgpool-ha.ja.txt @@ -41,6 +41,7 @@ perl 5以上とGetOpt::Longを必要とします。 -heartbeat 2.0以降(http://www.linux-ha.org/) +動作テストは 2.1.4 で行っています。 また、このホストに入っている必要はありませんが、以下のソフトウェアも必要になります。 @@ -82,57 +83,95 @@ crm true -cib.xml cib.xmlはheartbeatでcrmを利用するために必要なファイルで、通常/var/lib/heartbeat/crm/以下に配置されています。サンプルとして1仮想IPアドレス、アクティブ/スタンバイのpgpool構成を行うcib.xmlを以下に示します。 - + - + - - - - - - - - - - + + + + + - - + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + この設定ファイル例によりpgpoolを管理できるようになります。この中で書き換える項目は以下の通りになります。 -ノード名 @@ -144,49 +183,19 @@ cib.xmlはheartbeatでcrmを利用するために必要なファイルで、通 -設定ファイルの格納場所(任意) 設定ファイルの格納場所がデフォルト以外の場合、instance_attributes項目に以下のキーと、値としてそのファイル名を指定することで設定できます。 -ファイル名 , 指定するキー , 備考 -pgpool.conf , pgpoolconf , -pool_hba.conf , hbaconf , pgpool 3.2以降で有効 -pcp.conf , pcpconf , pgpool-IIでのみ有効 - - なお、この設定はpgpool 1.1以降でのみ有効です。 - --ログファイルの出力先 - 設定ファイルの格納場所と同様、ログファイルの出力先を指定することも可能です。logfileをキーに、対応するファイル名を -値として記述することで指定場所にリダイレクト出力するようになります。なお、ログファイル出力時は-d、デバッグオプションが -自動的に付与されます。 - - - - - 以下に、実際の設定例を示します。ここでは、先の設定ファイルのpgpool設定部分 -のみを記述しますので、随時置き換えてください。 - - - - - - - - - - - - - - +ファイル名 , 指定するキー , 備考 +pgpool.conf , pgpoolconf , +pool_hba.conf , hbaconf , pgpool 3.2+ only +pcp.conf , pcpconf , pgpool-II only +log file , logfile , pgpoolからリダイレクト出力するログファイル +pid file , pidfile , logdir='/tmp' なら /tmp/pgpool.pid を指定 +ログファイル出力時はデバッグオプション -d が自動的に付与されます。  この記述が終了したらファイルをheartbeatが利用する全てのサーバーに配置します。cib.xmlはサーバー間で全く同じである必要があります。なお、記述の検証にはheartbeatに付属しているcrm_verifyコマンドが使えます。 -crm_verify -VX /opt/powergres/hb/var/lib/heartbeat/crm/cib.xml +crm_verify -VX /var/lib/heartbeat/crm/cib.xml  最後に全てが終わったら起動して確認します。 @@ -198,80 +207,6 @@ crm_verify -VX /opt/powergres/hb/var/lib/heartbeat/crm/cib.xml pgpool-HA 1.1以降では、複数の設定ファイルが記述できるため、Active-Active構成を取ることが可能になります。 -以下に、/usr/local/pgsql/etc/pgpool-host1.conf と -/usr/local/pgsql/etc/pgpool-host2.conf で示される構成を、192.168.0.3 と -192.168.0.4 の2種類のIPで実行する場合の例を示します。 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 3. 利用方法 diff --git a/src/pgpool.in b/src/pgpool.in index 769a543..d973304 100755 --- a/src/pgpool.in +++ b/src/pgpool.in @@ -1,10 +1,10 @@ #!/bin/sh # -# OCF style start/stop/monitoring script for pgpool. use with heartbeat 2.0+ . +# OCF style start/stop/monitoring script for pgpool. use with heartbeat 2.1+ # -# Author: TANIDA Yutaka(tanida@sraoss.co.jp) +# Author: TANIDA Yutaka, TAKATSUKA Haruka # -# Copyright (c) 2006-2007 PgPool Global Development Group +# Copyright (c) 2006-2008 PgPool Global Development Group # # Permission to use, copy, modify, and distribute this software and # its documentation for any purpose and without fee is hereby @@ -17,12 +17,9 @@ # suitability of this software for any purpose. It is provided "as # is" without express or implied warranty. # -# +# defined OCF_RESKEY_value : pgpoolconf pcpconf hbaconf logfile pidfile # -# defined OCF_RESKEY_value : none -# pgpool.pid file path and default port number will be read -# from this file automatically. - +# default port number will be read from pgpool.conf automatically. check_pid () { @@ -35,62 +32,62 @@ check_pid () { fi } - - -PATH=/bin:/usr/bin:/sbin:/usr/sbin -export PATH -PGP_CONF=`@_PGPOOL_@ -h 2>&1 | grep default | sed -e 's/ config_file default path: //g'` PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH +PGPOOLCMD=@_PGPOOL_@ + if [ "x$OCF_RESKEY_pgpoolconf" = 'x' ]; then - PGP_CONF=`@_PGPOOL_@ -h 2>&1 | grep " config_file default" | sed -e 's/ config_file default path: //g'` + XX=$($PGPOOLCMD --help 2>&1 | grep ' config_file default path: ') + PGP_CONF=${XX# config_file default path: } else - PGP_CONF=$OCF_RESKEY_pgpoolconf + PGP_CONF=$OCF_RESKEY_pgpoolconf fi if [ "x$OCF_RESKEY_pcpconf" = 'x' ]; then - PCP_CONF=`@_PGPOOL_@ -h 2>&1 | grep " pcp_config_file default" | sed -e 's/ pcp_config_file default path: //g'` + XX=$($PGPOOLCMD --help 2>&1 | grep ' pcp_config_file default path: ') + PCP_CONF=${XX# pcp_config_file default path: } else - PCP_CONF=$OCF_RESKEY_pcpconf + PCP_CONF=$OCF_RESKEY_pcpconf fi if [ "x$OCF_RESKEY_hbaconf" = 'x' ]; then - HBA_CONF=`@_PGPOOL_@ -h 2>&1 | grep " hba_file default" | sed -e 's/ hba_file default path: //g'` + XX=$($PGPOOLCMD --help 2>&1 | grep ' hba_file default path: ') + HBA_CONF=${XX# hba_file default path: } else - HBA_CONF=$OCF_RESKEY_hbaconf + HBA_CONF=$OCF_RESKEY_hbaconf fi if [ "x$OCF_RESKEY_logfile" != 'x' ]; then - LOGFILE=$OCF_RESKEY_logfile + LOGFILE=$OCF_RESKEY_logfile +fi +if [ "x$OCF_RESKEY_pidfile" = 'x' ]; then + PGPOOL_PID=/tmp/pgpool.pid +else + PGPOOL_PID=$OCF_RESKEY_pidfile fi -echo $PGP_CONF - -PGPOOL="@_PGPOOL_@ -f $PGP_CONF" +PGPOOL="$PGPOOLCMD -f $PGP_CONF" PGPOOL_START_ARG="" if [ "x$HBA_CONF" != 'x' ];then - PGPOOL="$PGPOOL -a $HBA_CONF" + PGPOOL="$PGPOOL -a $HBA_CONF" fi - if [ "x$PCP_CONF" != 'x' ];then - PGPOOL="$PGPOOL -F $PCP_CONF" + PGPOOL="$PGPOOL -F $PCP_CONF" fi - if [ "x$LOGFILE" != 'x' ];then - PGPOOL="nohup $PGPOOL" - PGPOOL_START_ARG="$PGPOOL_START_ARG -d -n >>$LOGFILE 2>&1 &" + PGPOOL="nohup $PGPOOL" + PGPOOL_START_ARG="$PGPOOL_START_ARG -d -n >>$LOGFILE 2>&1 &" fi PGPOOL_STOP_ARG=" stop" PGPOOL_FORCE_STOP_ARG=" -m i $PGPOOL_STOP_ARG" -PGPOOL_MONITOR=@_PGPOOL_@.monitor +PGPOOL_MONITOR=${PGPOOLCMD}.monitor PGPOOL_MONITOR_ARGS=--conf=$PGP_CONF localhost >/dev/null 2>&1 -PGPOOL_PID=`grep -P '^[^#]*logdir' $PGP_CONF | tr -d "''=" | awk '{print $2."/pgpool.pid"}'` # Source function library. . /etc/rc.d/init.d/functions # See how we were called. case "$1" in - start) + start) if check_pid then # pgpool is already running. @@ -98,58 +95,58 @@ case "$1" in else su -c "$PGPOOL $PGPOOL_START_ARG" postgres exit $? - fi + fi ;; - stop) + stop) if check_pid then RET=`su -c "$PGPOOL $PGPOOL_STOP_ARG | grep ERROR" postgres` - if [ -z "$RET" ] ; then - exit 0 - else + if [ -z "$RET" ] ; then + exit 0 + else # try immediate stop. - RET=`su -c "$PGPOOL $PGPOOL_FORCE_STOP_ARG | grep ERROR " postgres` - if [ -z "$RET" ] ; then + RET=`su -c "$PGPOOL $PGPOOL_FORCE_STOP_ARG | grep ERROR " postgres` + if [ -z "$RET" ] ; then exit 0; else exit 1; fi - fi + fi else # not running exit 0 fi ;; - status) - if check_pid + status) + if check_pid then exit 0 # no error else exit 2 # not running fi ;; - monitor) + monitor) if check_pid then - $PGPOOL_MONITOR $PGPOOL_MONITOR_ARGS + $PGPOOL_MONITOR $PGPOOL_MONITOR_ARGS exit $? else - exit 7 + exit 7 # stop or fail fi ;; - methods) - echo start - echo stop - echo status - echo methods - echo monitor + methods) + echo start + echo stop + echo status + echo methods + echo monitor echo recover echo reload ;; - recover|reload) - $0 stop + recover|reload) + $0 stop $0 start exit 0 ;; - meta-data) + meta-data) cat < @@ -181,7 +178,6 @@ cat <pool_hba.conf - Path to output logfile . logfile contains debuglog. if this entry is empty , log output is depends on pgpool. @@ -189,6 +185,13 @@ cat <logfile + + + Path to pgpool.pid logfile . + + pidfile + + @@ -204,9 +207,8 @@ EOF exit 0; ;; *) - echo "Usage: $0 {start|stop|status|methods|reload|recover|meta-data|monitor}" + echo "Usage: $0 {start|stop|status|methods|reload|recover|meta-data|monitor}" exit 1 esac - -lexit 0 +exit 0