Skip to content

Commit

Permalink
keepalived: Add to_backup.sh script
Browse files Browse the repository at this point in the history
  • Loading branch information
eiabea committed Oct 19, 2023
1 parent 4170c41 commit 949c432
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion community-tutorials/high-availability-keepalived/01-en.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ CURL_CHECK='
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>'
REROUTE_RESULT=$(curl -s -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction:" -d "$CURL_REROUTE" -X POST https://www.servercontrolpanel.de:443/WSEndUser?xsd=1)
# Do not trigger re-route before checking if the current may even has the correct IP
# REROUTE_RESULT=$(curl -s -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction:" -d "$CURL_REROUTE" -X POST https://www.servercontrolpanel.de:443/WSEndUser?xsd=1)
CHECK_RESULT=$(curl -s -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction:" -d "$CURL_CHECK" -X POST https://www.servercontrolpanel.de:443/WSEndUser?xsd=1)
FAILOVER_IP_ACTIVE=$(echo $CHECK_RESULT | grep YOUR_FAILOVER_IP | wc -l)
Expand All @@ -186,6 +187,19 @@ Hints:
- _YOUR_VSERVER_NAME_ can be found in your SCP in the _General_ section of the corresponding server.
- _YOUR_VSERVER_MAC_ can also be found in your SCP in the _General_ section of the corresponding server (note that you need the MAC of your primary interface not the MAC of the vLAN).


**to_backup.sh**

```
#!/usr/bin/bash
# Ensure no to_master script is still running even though we got into backup state
if pgrep to_master.sh; then killall to_master.sh; fi
```

The above script kills the `to_master.sh` script if it is already running on this host. This prevents a race condition where 2 servers might want the vIP routed to themselves

# Step 3 - Set up Keepalived

## Step 3.1 - Install Keepalived
Expand Down Expand Up @@ -229,6 +243,8 @@ vrrp_instance VI_1 {
10.132.0.100
}
notify_master /PATH/TO/YOUR/SCRIPT/to_master.sh
notify_backup /PATH/TO/YOUR/SCRIPT/to_backup.sh
notify_fault /PATH/TO/YOUR/SCRIPT/to_backup.sh
}
```

Expand All @@ -249,6 +265,8 @@ vrrp_instance VI_1 {
10.132.0.100
}
notify_master /PATH/TO/YOUR/SCRIPT/to_master.sh
notify_backup /PATH/TO/YOUR/SCRIPT/to_backup.sh
notify_fault /PATH/TO/YOUR/SCRIPT/to_backup.sh
}
```

Expand Down

0 comments on commit 949c432

Please sign in to comment.