SCENARIO==> You have a virtual machine protected using SRM which is running Oracle Linux. Once this VM gets recovered on the DR site during test recovery or disaster recovery, you want the IP address and other settings to change as soon as the VM comes up on the DR site. Since Guest IP Customization will not work on Oracle Linux you would get the following error if you try to use that method – “Error: The Guest operating system “oracleLinux64Guest” is not supported.” How will we solve this issue?
1
|
Click Recovery Plans in the left pane, and select the recovery plan which has the VM in question.
|
2
|
Click the Virtual Machines tab.
|
3
|
Right-click the virtual machine and click Configure.
|
4
|
Select Pre-Power On Steps or Post Power On Steps in the left pane, and click Add.
|
5
|
Select Command on Recovered VM.
|
6
|
In the Name text box, type a name for the step.
“Command to call IP Address Change Script.”
|
7
|
In the Content text box, type the commands for the step to run.
/bin/sh/etc/network-scripts/changeip.sh (I will share the content of the script changeip.sh in a moment)
|
8
|
(Optional) Modify the Timeout setting.
|
9
|
Click OK to add the step to the recovery plan.
|
10
|
Click OK to reconfigure the virtual machine to run the command before or after it powers on.
Here is the screenshot from my server:-
|
Here is how my script chnageip.sh looks like:-
#!/bin/bash
#################################################################
# Injecting network files for DR environment
/bin/cp -p /etc/network-scripts/network /etc/sysconfig/network
/sbin/init 6
#End of script.
Let me describe this script. I am copying the files which I have already kept on the Virtual Machine on my primary site with the new IP settings on the following location – /etc/network-scripts/network. These files are replicated to the DR VM image automatically as a part of my replication plan, whether storage based or vSphere Replication.
With this script I am copying the ‘network’ file which has all the new settings to the /etc/sysconfig/ which will replace the existing IP settings of the Linux machine to the new IP address which we have defined in our DR Network file. After that the VM would reboot to power on with the new settings.
Similar to this script you can do a bunch of things by calling such scripts on the recovered VM’s, such as:-
a) Change any other OS settings such as name, IP, network settings etc.
b) Run cron jobs or schedule tasks.
c) Run configuration files to make changes in an application configuration.
d) Do wonders 😉
Well now when you run this recovery plan, your VM will power on on the DR site and then as soon as the VMware tools is up on the VM, SRM workflow will call this script and the script will change the network settings of the VM as scripted by you automatically. Automation and agility at its best. 🙂
You might have questions about rights to run this script etc.. Remember VMware Tools is used here, so the script should have the rights same as the user account which was used to install VMware Tools, normally its domain admin on ‘Windows’ and root on ‘Linux’ OSes.
Well that’s all for this time, I hope this would help you get things going on SRM and use the amazing options which SRM provides you to automate stuff. In my upcoming article, I would speak about how to use the option of using “Command on SRM server”.
Image automatically as a part of my replication plan, whether storage based.Orlando Vending Machines
LikeLike