[pgpool-hackers: 70] Re: pgpool-II fails to restart using redhat/pgpool.init
alex
alex at smalldemons.com
Fri May 18 01:14:29 JST 2012
I have a modified version I use that also supports re-reading the hba
and pcp config files (defined in /etc/sysconfig/pgpool). It stops
pgpool via "pgpool stop" rather than killproc. I haven't seen problems
with it so far, and I think the changes would benefit others.
I've attached my version.
alex
On 5/16/12 8:07 PM, Yugo Nagata wrote:
> Dear Mr. Devrim
>
> An problem with restart using redhat/pgpool.init has been reported to the bug
> track.
> http://www.pgpool.net/mantisbt/view.php?id=12
>
> When pgpool is connected from frontend (e.g. psql), restart using
> redhat/pgpool.init fails with error like
> "bind(/tmp/.s.PGSQL.9898) failed. reason: Address already in use".
>
> There is no probrem when using `pgpool -m f stop; pgpool`.
> Would killproc fail to close the socket properly?
>
> I heard from Tatsuo Ishii that you are in charge of redhat/pgpool.init.
> Could you respond to the issue?
>
-------------- next part --------------
#!/bin/sh
# pgpool This is the init script for starting up pgpool-II
#
# chkconfig: - 64 36
# description: Starts and stops the pgpool daemon
# processname: pgpool
# pidfile: /var/run/pgpool.pid
#
# v1.0.0 Devrim GUNDUZ <devrim at CommandPrompt.com>
# - Initial version of Red Hat / Fedora init script
#
# v2.2 Devrim GUNDUZ <devrim at CommandPrompt.com>
# - New and improved version which has some fixes.
#
# v2.2.5 Devrim GUNDUZ <devrim at CommandPrompt.com>
# - Fix logging.
#
# v2.2.6 alex
# - support for the HBA and pcp config files
if [ -r /etc/sysconfig/pgpool ]; then
. /etc/sysconfig/pgpool
fi
# Source function library.
INITD=/etc/rc.d/init.d
. $INITD/functions
# Get function listing for cross-distribution logic.
TYPESET=`typeset -f|grep "declare"`
# Get config.
. /etc/sysconfig/network
# Check that networking is up.
# We need it for pgpool
[ "${NETWORKING}" = "no" ] && exit 0
# Find the name of the script
NAME=`basename $0`
if [ ${NAME:0:1} = "S" -o ${NAME:0:1} = "K" ]
then
NAME=${NAME:3}
fi
# For SELinux we need to use 'runuser' not 'su'
if [ -x /sbin/runuser ]
then
SU=runuser
else
SU=su
fi
# Set defaults for configuration variables
PGPOOLENGINE=/usr/bin
PGPOOLDAEMON=$PGPOOLENGINE/pgpool
PGPOOLCONF=/etc/pgpool-II/pgpool.conf
PGPOOLPIDDIR=/var/run/pgpool
PGPOOLLOG=/var/log/pgpool.log
PGPOOLHBA=""
PGPOOLPCP=""
test -x $PGPOOLDAEMON || exit 5
# Check whether the config file exists or not
if [ ! -r $PGPOOLCONF ]
then
echo "$PGPOOLCONF not found"
RETVAL=1
failure
exit
fi
# Create the log file if it does not exist
if [ ! -x $PGPOOLLOG ]
then
touch $PGPOOLLOG
chown postgres: $PGPOOLLOG
fi
if [ ! -d $PGPOOLPIDDIR ]
then
mkdir $PGPOOLPIDDIR
chown postgres: $PGPOOLPIDDIR
fi
script_result=0
start(){
pid=`pidof -s "$PGPOOLDAEMON"`
if [ $pid ]
then
echo "pgpool is already running with pid $pid"
failure "$PGPOQL_START"
echo
script_result=1
exit 1
fi
PGPOOL_START=$"Starting ${NAME} service: "
echo -n "$PGPOOL_START"
[ -f "$PGPOOLHBA" ] && OPTS="$OPTS -a $PGPOOLHBA"
[ -f "$PGPOOLPCP" ] && OPTS="$OPTS -F $PGPOOLPCP"
$SU -l postgres -c "$PGPOOLDAEMON -f $PGPOOLCONF $OPTS & " >> "$PGPOOLLOG" 2>&1 < /dev/null
sleep 2
pid=`pidof -s "$PGPOOLDAEMON"`
if [ $pid ]
then
success "$PGPOOL_START"
touch /var/lock/subsys/${NAME}
echo
else
failure "$PGPOQL_START"
echo
script_result=1
fi
}
stop(){
echo -n $"Stopping ${NAME} service: "
if [ $UID -ne 0 ]; then
RETVAL=1
failure
else
#killproc /usr/bin/pgpool
$PGPOOLDAEMON stop & >> "$PGPOOLLOG" 2>&1 < /dev/null
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/${NAME}
fi;
echo
return $RETVAL
}
switch() {
echo -n $"Sending switchover request to $NAME "
$PGPOOLDAEMON -f $PGPOOLCONF switch >> "$PGPOOLLOG" 2>&1 < /dev/null
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]
then
echo_success
else
echo_failure
fi
echo
}
restart(){
stop
start
}
reload(){
echo -n $"Reloading ${NAME}: "
POPTS=""
[ -f "$PGPOOLHBA" ] && POPTS="$POPTS -a $PGPOOLHBA"
[ -f "$PGPOOLPCP" ] && POPTS="$POPTS -F $PGPOOLPCP"
$PGPOOLDAEMON -f $PGPOOLCONF $POPTS reload >> "$PGPOOLLOG" 2>&1 < /dev/null
if [ $? -ne 0 ] ; then
failure $"Reloading ${NAME}"
fi
RETVAL=$?
echo
}
condrestart(){
[ -e /var/lock/subsys/${NAME} ] && restart
}
condstop(){
[ -e /var/lock/subsys/${NAME} ] && stop
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
switch)
switch
;;
status)
status pgpool
script_result=$?
;;
restart)
restart
;;
reload|force-reload)
reload
;;
condrestart)
condrestart
;;
condstop)
condstop
;;
*)
echo $"Usage: $0 {start|stop|switch|status|restart|condrestart|condstop|reload|force-reload}"
exit 1
esac
exit $script_result
More information about the pgpool-hackers
mailing list