Creating Virtual IP control scripts (Linux)
Start
- On the primary VM Server, create a shell file to enable the Virtual IP interface that is named SC_VIP_UP.SH, and enter the following commands into the file:
[+] Commands for SC_VIP_UP.SH
#!/bin/sh
# Set the path in which log files will be stored
Logpath=<Specify the path to log files>
# For example Logpath=/home/Logs
echo -e "\n--------Bringing VIP Up----------" >> $Logpath/Takeover_On.log
date >> $Logpath/Takeover_On.log
# Set the following parameter corresponding to your machine configuration
Interface=<Interface in which VIP should be added>
# For example Interface=eth0:1
Virtual_IP=<Virtual IP of the Machine>
# For example Virtual_IP=172.24.133.254
Gateway=<Gateway of the Machine>
# For example Gateway=10.1.1.1
ping_count=1
loop_count=20
# Looping up to 20 count or till VIP disabled in the HA pair
for (( i=1; i<=$loop_count;i++ ))
do
result=$(ping -c $ping_count $Virtual_IP | grep "bytes from")
if [ "$result" ]
then
echo "$i ping reply got from the HA pair" >> $Logpath/Takeover_On.log
sleep 1
else
echo "VIP disabled in the HA pair" >> $Logpath/Takeover_On.log
# Enabling the VIP once it is disabled in paired host
break
fi
done
/sbin/ifconfig $Interface $Virtual_IP up
# Update the ARP cache of the gateway
arping -s $Virtual_IP $Gateway -f
echo -e "\n--------VIP enabled in this machine----------" >> $Logpath/Takeover_On.log
date >> $Logpath/Takeover_On.log
exit
- In the shell file, replace the variables indicated by angle brackets with appropriate values.
- On both GSVM server host computers, create a shell file to disable the Virtual IP interface that is named SC_VIP_DOWN.SH, and enter the following commands into the file:
[+] Commands for SC_VIP_DOWN.SH
# Set the path in which log files will be stored
Logpath= <Specify the path to log files>
# For example Logpath=/home/Logs
echo -e "\n----------Bringing VIP down---------" >> $Logpath/Takeover_Off.log
date >> $Logpath/Takeover_Off.log
# Set the following parameter corresponding to your machine configuration
Interface=<Interface in which VIP should be added>
Virtual_IP=<Virtual IP of the Machine>
/sbin/ifconfig $Interface down
sleep 10
# Update arpcache of the local machine
ping -c 2 $Virtual_IP
echo -e "---------VIP disabled--------------" >> $Logpath/Takeover_Off.log
- In the shell file, replace the variables indicated by angle brackets with appropriate values.
- Add the SC_VIP_DOWN script as a startup script by adding the script to the current run-level of the machine.
- Copy SC_VIP_DOWN.SH to the /etc/init.d folder.
- Create a symlink from your run-level directory to execute when a system starts to disable the Virtual IP. For example, if the run-level is 5, the creation of symlink is as follows:
"ln -s /etc/init.d/<scriptfile> /etc/rc.d/rc5.d/S50<scriptfile>"
The S50 tells the system to start the script when it starts.
End
Next Steps
Genesys Applications
OR
Back to Task Table