From: Bo Peng Date: Thu, 27 Feb 2025 07:07:15 +0000 (+0900) Subject: Update sample scripts. X-Git-Tag: V4_2_21~2 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=95cf6cbbec3e0103963196cc70bbdb5f3478a5af;p=pgpool2.git Update sample scripts. --- diff --git a/src/sample/scripts/escalation.sh.sample b/src/sample/scripts/escalation.sh.sample index ffffa3302..d8fd97fd2 100755 --- a/src/sample/scripts/escalation.sh.sample +++ b/src/sample/scripts/escalation.sh.sample @@ -12,15 +12,23 @@ PGPOOLS=(server1 server2 server3) VIP=192.168.137.150 DEVICE=enp0s8 +CIDR_NETMASK=24 for pgpool in "${PGPOOLS[@]}"; do [ "$HOSTNAME" = "${pgpool}" ] && continue timeout ${SSH_TIMEOUT} ssh -T ${SSH_OPTIONS} ${POSTGRESQL_STARTUP_USER}@${pgpool} " - /usr/bin/sudo /sbin/ip addr del ${VIP}/24 dev ${DEVICE} + /sbin/ip addr show dev ${DEVICE} | grep ${VIP} > /dev/null 2>&1 " - if [ $? -ne 0 ]; then - echo ERROR: escalation.sh: failed to release VIP on ${pgpool}. + + if [ $? -eq 0 ]; then + timeout ${SSH_TIMEOUT} ssh -T ${SSH_OPTIONS} ${POSTGRESQL_STARTUP_USER}@${pgpool} " + /usr/bin/sudo /sbin/ip addr del ${VIP}/${CIDR_NETMASK} dev ${DEVICE} + " + + if [ $? -ne 0 ]; then + echo ERROR: escalation.sh: failed to release VIP on ${pgpool}. + fi fi done exit 0 diff --git a/src/sample/scripts/follow_primary.sh.sample b/src/sample/scripts/follow_primary.sh.sample index 31204571c..1830e2ea0 100755 --- a/src/sample/scripts/follow_primary.sh.sample +++ b/src/sample/scripts/follow_primary.sh.sample @@ -1,6 +1,5 @@ #!/bin/bash # This script is run after failover_command to synchronize the Standby with the new Primary. -# First try pg_rewind. If pg_rewind failed, use pg_basebackup. set -o xtrace