Recently, I ran a test of a SRM Recovery Plan for a new set of Linux VMs I inherited. The first test didn’t go so well and returned the error “Error – The guest operating system ‘centos64Guest’ is not supported”. After doing a cleanup of the test Recovery Plan, I ran the test again but this time without the IP setting customizations which allowed the test to complete successfully. I also had to alter some of the timeout settings, but that is pretty typical of VMs that take a long time to boot or require extra time to customize.

I selected a few VMs to test with and I changed their IP addresses manually. I needed to do this to test applications they were hosting to confirm the DR test was successful. However, somewhere along the way I had to reboot one or more of the VMs and the IP settings had reverted. After further investigation, I confirmed the reason why was the VMs were using network scripts to set network configurations such as MAC, IP, gateway, etc. Linux network scripts are typically stored at /etc/sysconfig/network-scripts/ and are named similar to ifcfg-eth0 where eth0 is the name of the ethernet adapter.

The first thing I did was to take a look at the network configuration scripts and document the existing settings. To do this, I ran the command:

cat /etc/sysconfig/network-scripts/ifcfg-eth0 | less

If the list is small and can fit on the screen you do not need the “| less” at the end. A sample of the of the network script output is below excluding any sensitive information.

DEVICE=eth0
IPADDR=172.16.X.X
NETMASK=255.255.XX.XXX
GATEWAY=172.16.X.X
DNS1=172.16.X.X
DNS2=172.16.X.X
NM_CONTROLLED=no
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
IPV6INIT=no
USERCTL=no

Now knowing the VMs were configured via scripts I had to forgo using SRM IP customizations and instead use SRM’s ability to run a script or command post power on for each VM that encountered the problem. First I had to create a directory on each VM to store the ifcfg-eth0 network script with the new network settings along with a script to replace the existing network script. To do this login to the Linux VM as root and run the commands below.

1. Create the needed directories

cd /etc
mkdir srmipchanges
cd srmipchanges
mkdir dr
cd dr
2. Create the network script
    A. While in the DR directory, type the command “vi ifcfg-eth0” and hit enter.
B. Type “i” to enter edit mode, and adjust the values below as needed.

DEVICE=eth0
IPADDR=172.16.X.X
NETMASK=255.255.XX.XXX
GATEWAY=172.16.X.X
DNS1=172.16.X.X
DNS2=172.16.X.X
NM_CONTROLLED=no
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
IPV6INIT=no
USERCTL=no
    C. Hit ESC to exit edit mode, then type “:wq” and hit enter to save the file.
D. Check the network script by using the command “cat ifcfg-eth0“.
E. If it looks good type “:q!” and hit enter to exit the file.

3. Create the script to replace the network script

A. While in the DR directory, type the command “vi ipchange.sh” and hit enter.
B. Type “i” to enter edit mode, and type the values below.

/bin/cp -p /etc/srmipchanges/dr/ifcfg-eth0 /etc/sysconfig/network-scripts
/sbin/init 6
    C. Hit ESC to exit edit mode, then type “:wq” and hit enter to save the file.
D. Check the network script by using the command “cat ipchange.sh“.
E. If it looks good type “:q!” and hit enter to exit the file.
4. Configure SRM to run the ipchange.sh script

    A. Using the vSphere client go to Home, Solutions and Applications, Site Recovery.
B. Click Recovery Plans in the left pane, and select the recovery plan you are trying to test.
C. Click on the Virtual Machines tab.
D. Right-click the virtual machine and click Configure.
E. Select Post Power On Steps in the left pane, and click Add.
F. Select Command on Recovered VM.
G. For the name box, type a name. I used the name “IP change”.
H. In the Content text box, type “/bin/sh /etc/srmipchanges/dr/ipchange.sh“.
I. Adjust the Timeout settings to 10 minutes to accommodate for the needed changes.
J. Once done click OK to add the step to the recovery plan.
K. Click OK again to configure the VM Recovery Properties.Repeat the steps above for each VM within the recovery plan as needed, and rerun the test Recovery Plan. This time the test should complete successfully and the VMs should be using the new IP addresses. You may also want to check the VMs host file as it is common to see an entry in there for the old IP pointing to the localhost or host name of the Linux machine. If it does, you will need to also script the replacement of the of the hosts file with the needed changes.


Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Application Containers

Docker container management using Rancher

What is container management and why to use it?A container management platform is a solution used to o create cloud-native, distributed applications and package legacy applications that were not originally designed for virtual environments. Container Read more…

CentOS

Install MySQL Galera Cluster on Centos 7

What is MySQL cluster and how to use it?MySQL Galera Cluster is a synchronous multi-master cluster, available on Linux only, and only supports the XtraDB/InnoDB storage engines . It is designed to provide high availability Read more…

Application Containers

Installing Docker on Centos 7

What are Docker containers and how to use them?Docker is a software technology providing containers. Docker provides an additional layer of abstraction and automation of operating-system-level virtualization on Windows and Linux. Docker uses the resource Read more…