Update sample scripts.
authorBo Peng <pengbo@sraoss.co.jp>
Thu, 27 Feb 2025 07:07:15 +0000 (16:07 +0900)
committerBo Peng <pengbo@sraoss.co.jp>
Thu, 27 Feb 2025 07:08:19 +0000 (16:08 +0900)
src/sample/scripts/escalation.sh.sample
src/sample/scripts/follow_primary.sh.sample

index ffffa33024b275a7fc9e2f12df86592550d02bdd..d8fd97fd26299027584fac8469a80cee70313eb5 100755 (executable)
@@ -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
index 31204571c3dbfb6eb8d0b67429df24511109fa22..1830e2ea067acb29f9240a48810d6a62bd2f1a93 100755 (executable)
@@ -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