+pgpool-ha 3.x
+=============
- pgpool-ha 2.x
- OCF style Resource Agent for pgpool-II
-
+pgpool-ha is an OCF style Resource Agent for pgpool-II.
install
-=======
+-------
+
+ $ su
+ # install -m 0755 -o root -g root \
+ ./pgpool.in /usr/lib/ocf/resource.d/heartbeat/pgpool
- see "INSTALL"
usage
-=====
+-----
+
+OCF parameters are as below.
+
+### pgpoolconf
+
+Specifies the path of pgpool.conf. (default: /usr/local/etc/pgpool.conf)
+
+### pcpconf
+
+Specifies the path of pcp.conf. (default: empty)
+
+### hbaconf
+
+Specifies the path of pool_hba.conf. (default: empty)
+
+### logfile
+
+Specifies the log output. (default: empty)
+
+You can set a file path for redirection or a program for pipeline processing.
+The value start with "|" is recognized as a program.
+Parameter "-n" is added to pgpool implicitly if some value is set into this.
+The example are as follows:
+
+ "/var/log/pgpool.log"
+ "| logger -t pgpool -p local3.info"
+
+### options
+
+Specifies pgpool's starting options. (default: empty)
+
+"-D" is recommended if pgpool_status file is not in shared space.
+"-n", "-f", "-a" and "-F" shouldn't be included, since these are
+used implicitly by other parameters.
+
+### pgpooluser
+
+Specifies the user to run the pgpool process. (default: postgres)
+
+### checkmethod
+
+Specifies monitoring method. (default: pid)
+
+Possible values are as follows:
+
+ "pid" check by process existence.
+ "pcp" check by pcp_node_count command.
+ "psql" check by psql or pg_isready command.
+
+### checkstring
+
+Specifies the details for the monitoring method.
+This parameter means differently by checkmethod setting.
+
+When checkmetod is "pid", this means pid file path.
+The default value is pid_file_name setting in pgpool.conf.
+
+When checkmetod is "pcp", this means parameters for pcp_nod_count command.
+The default value is "10 localhost 9898 postgres pass".
+"-w -h localhost -p 9898" is a good idea for 3.5.x and later version,
+for the response 'authentication failed' is considered success.
+
+When checkmetod is "psql", this means parameters for psql or other command
+which is specified in psqlcmd parameter.
+The default value is "-U postgres -h localhost -l -p 9999".
+"-U postgres -h localhost -p 9999" is a good idea when you use pg_isready.
+
+### psqlcmd
+
+Specifies the path of psql or pg_isready command.
+
+### pgpoolcmd
+
+Specifies the path of pgpool command.
+
+### pcpnccmd
- OCF parameters are as below:
+Specifies the path of pcp_node_count command.
- pgpoolconf path of pgpool.conf
- (default: /usr/local/etc/pgpool.conf)
- pcpconf path of pcp.conf
+crm samples
+-----------
- hbaconf path of pool_hba.conf
+simple process check:
- logfile log file for stdout and stderr redirection;
- or a program for log collecting by a pipeline.
- (e.g.)
- "/var/log/pgpool.log"
- "| logger -t pgpool -p local3.info"
+ primitive pgpool ocf:heartbeat:pgpool \
+ params pgpoolconf="/usr/local/pgpool/etc/pgpool.conf" \
+ options="-D" pgpooluser="postgres" \
+ checkmethod="pid" \
+ pgpoolcmd="/usr/local/pgpool/bin/pgpool" \
+ op start interval=0s timeout=60s \
+ op monitor interval=10s timeout=30s \
+ op stop interval=0s timeout=60s
- options pgpool start options (except configuration file options and
- -n option for log resirection)
- (e.g.)
- "--discard-status"
- "-D -d"
- pgpooluser pgpool start user
+using pgpool-II 3.5.x's pcp_node_count:
- checkmethod monitoring method:
- "pid" process existence check only (default).
- "pcp" check by pcp_node_count command.
- "psql" check by psql command.
+ primitive pgpool ocf:heartbeat:pgpool \
+ params pgpoolconf="/usr/pgpool2-3.5/etc/pgpool.conf" \
+ pcpconf="/usr/pgpool2-3.5/etc/pcp.conf" \
+ options="-D" pgpooluser="postgres" \
+ checkmethod="pcp" checkstring="-w -h localhost -p 9898" \
+ pgpoolcmd="/usr/pgpool2-3.5/bin/pgpool" \
+ pcpnccmd="/usr/pgpool2-3.5/bin/pcp_node_count" \
+ op start interval=0s timeout=60s \
+ op monitor interval=30s timeout=30s \
+ op stop interval=0s timeout=60s
- "pcp" and "psql" methods also check process existence
- with pid_file_name parameter in pgpool.conf file.
- checkstring parameter for monitoring method
- checkmetod="pid" : pidfile
- (default: value of pid_file_name parameter in pgpool.conf)
+using pg_isready:
- checkmetod="pcp" : parameter string for pcp_node_count
- (default: "10 localhost 9898 postgres pass")
+ primitive pgpool pgpool \
+ params pgpoolconf="/etc/pgpool-II-95/pgpool.conf" \
+ pcpconf="/etc/pgpool-II-95/pcp.conf" \
+ options="-D" pgpooluser="postgres" \
+ checkmethod="psql" checkstring="-U postgres -h localhost -p 9999" \
+ pgpoolcmd="/usr/pgpool-9.5/bin/pgpool" \
+ psqlcmd="/usr/pgsql-9.5/bin/pg_isready" \
+ op start interval=0s timeout=60s \
+ op monitor interval=30s timeout=30s \
+ op stop interval=0s timeout=60s
- checkmetod="psql" : parameter string for psql
- (default: "-U postgres -h localhost -p 9999 -l")
support ML
-==========
+----------
pgpool-general@pgpool.net
#!/bin/bash
#
-# OCF Resource Agent for pgpool-II 2.x
+# OCF Resource Agent for pgpool-II 3.x
#
-# Copyright 2012-2013 PgPool Global Development Group
+# Copyright 2012-2016 PgPool Global Development Group
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose and without fee is hereby
# OCF parameters are as below
#
# pgpoolconf path of pgpool.conf
-# (default: @_PGPOOL_DIR_@/etc/pgpool.conf)
+# (default: /usr/local/etc/pgpool.conf)
#
# pcpconf path of pcp.conf
#
#
# logfile log file for stdout and stderr redirection;
# or a program for log collecting by a pipeline.
-# (e.g.)
+# e.g.
# "/var/log/pgpool.log"
# "| logger -t pgpool -p local3.info"
#
# checkmethod monitoring method:
# "pid" process existence check only (default).
# "pcp" check by pcp_node_count command.
-# "psql" check by psql command.
+# "psql" check by psql or pg_isready command.
#
-# checkstring parameter for monitoring method
+# checkstring parameter for the monitoring method
# checkmetod="pid" : pidfile
# (default: parse from pgpool.conf file)
# checkmetod="pcp" : parameter string for pcp_node_count
# (default: "10 localhost 9898 postgres pass")
+# "-w -h localhost -p 9898" is a good idea for 3.5.x version,
+# for the response 'authentication failed' is considered success.
# checkmetod="psql" : parameter string for psql
# (default: "-U postgres -h localhost -l -p 9999")
#
+# psqlcmd path of psql or pg_isready command
+#
+# pgpoolcmd path of pgpool command
+#
+# pcpnccmd path of pcp_node_count command
-VERSION=2.1
+
+VERSION=3.0
##### Source function library.
###### Parameter defaults
-OCF_RESKEY_pgpoolconf_default="@_PGPOOL_DIR_@/etc/pgpool.conf"
+OCF_RESKEY_pgpoolconf_default="/usr/local/etc/pgpool.conf"
OCF_RESKEY_pcpconf_default=""
OCF_RESKEY_hbaconf_default=""
OCF_RESKEY_logfile_default=""
OCF_RESKEY_pgpooluser_default="postgres"
OCF_RESKEY_checkmethod_default="pid"
OCF_RESKEY_checkstring_default=""
-OCF_RESKEY_pgpoolcmd_default=@_PGPOOL_DIR_@/bin/pgpool
-OCF_RESKEY_psqlcmd_default=@_PGSQL_DIR_@/bin/psql
-OCF_RESKEY_pcpnccmd_default=@_PGPOOL_DIR_@/bin/pcp_node_count
+OCF_RESKEY_pgpoolcmd_default=/usr/local/bin/pgpool
+OCF_RESKEY_psqlcmd_default=/usr/local/pgsql/bin/psql
+OCF_RESKEY_pcpnccmd_default=/usr/local/bin/pcp_node_count
: ${OCF_RESKEY_pgpoolconf=${OCF_RESKEY_pgpoolconf_default}}
: ${OCF_RESKEY_pcpconf=${OCF_RESKEY_pcpconf_default}}
do_pcp_check() {
- ocf_run -q $OCF_RESKEY_pcpnccmd $OCF_RESKEY_checkstring
+ RET=$($OCF_RESKEY_pcpnccmd $OCF_RESKEY_checkstring 2>&1)
rc=$?
- if [ $rc -eq 0 ]
- then
+ if [ $rc -eq 0 ] ; then
return $OCF_SUCCESS
else
- ocf_log err "${OCF_RESOURCE_INSTANCE}: pcp_check fail"
+ if ( echo $RET | head -1 | grep -q 'authentication failed' ) ; then
+ return $OCF_SUCCESS
+ fi
+ ocf_log err "${OCF_RESOURCE_INSTANCE}: pcp_check fail : ${RET}"
return $OCF_NOT_RUNNING
fi
}
-
do_psql_check() {
ocf_run -q $OCF_RESKEY_psqlcmd $OCF_RESKEY_checkstring
rc=$?
</parameter>
<parameter name="logfile" unique="0" required="0">
<longdesc lang="en">
-pgpool log file for stdout and stderr redirection;
-or a program for log collecting by a pipeline.
+pgpool log file or log processing program.
(e.g.)
"/var/log/pgpool.log",
"| logger -t pgpool -p local3.info"
</parameter>
<parameter name="psqlcmd" unique="0" required="0">
<longdesc lang="en">
-psql command.
+psql or pg_isready command.
</longdesc>
<shortdesc lang="en">psql command</shortdesc>
<content type="string" default="$OCF_RESKEY_psqlcmd_default" />