mirror of
https://github.com/maxkratz/community-tutorials.git
synced 2024-09-08 00:02:56 +00:00
Merge pull request #147 from eiabea/poc-fix-to-master-race-condidtion
keepalived: Add to_backup.sh script
This commit is contained in:
commit
1251b92f9e
1 changed files with 19 additions and 1 deletions
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue