Tuesday, November 24, 2009

Peopesoft OVM in VMWare : start/stop script

Working on virtual machine is nice but that multiply dramatically the number of IP addresses, server names, etc.
Peoplesoft VM on Oracle VM comes with 3 templates. If you add one Oracle VM Manager (optional), that makes one more, in total in that simple configuration :
* 1-3 IP address for Oracle VM Server (depending how many running images you want in one)
* 1 IP address for Oracle VM Manager
* 3 IP address for the servers (one for each running Oracle VM image)
And you need to start each one before doing anything you want to do.
Then, and only then you have to start the database, application server, batch server and web server.
And eventually you'll have the connection to your front end application.

But if you install all this on top of VMWare as I described here, that obviously does not make the picture more simple, you'll also have to start the VMWare image in front. And a lot of manual tasks to achieve before to be able to work within the front end application.
So, that becomes obvious to script the start and stop of all the compenents.

Here are all the steps required to use the script given below, and the description of the script itself.

1. VMWare tools
First step, install the VMWare tools on every single VMWare image, it is required to stop the VMware image through the command line.



Mount the CD-ROM drive, untar the gz file in /tmp, and run the VMWare tools installation script vmware-install.pl.
You should open the VMWare console to do so, not through a telnet connection (the tools stop and restart the network service), before running the tools installation script :

On the VMWare image hosting Oracle VM Server, a couples of messages about C-libraries, ignore them, just answer no, we don't want it, they are not required for what we want to achieve :
Finally, it is done, and the tools are running :


2. Authorized key
2.1 On the host OS
Generate a rsa public key on the host, as root :
ssh-keygen -t rsa
That'll create a file under /root/.ssh/rsa.pub.

2.2 On every single remote server
According to my picture, on the 3 VMWare images (2 Oracle VM Server, 1 Oracle VM Manager), on the 3 Peoplesoft VMs (the database server, the App/Batch server and the PIA server), create the file authorized_keys2 under /root/.ssh, and copy the content of the /root/.ssh/rsa.pub from the host create at the step 2.1.
Add the reference of the host into the /etc/hosts file as well (IP address and host server name).

3 The script
The script will take place onto the host, within no modification on the remote servers (except the point 2 above).
It has been tested with the following configuration :
=> host OS : CentOS5.4
=> VMWare 2.0.2
=> Oracle VM ServerManager 2.2.0
=> Peoplesoft VM images 1.0.0

Here a brief description of the script :

3.1 Variables settings
You'll see in the script a lot of parameters, everything is doing to make it the most flexible as possible, there are 3 mains part :
* variables regarding the VMWare installs and images
* variables regarding the Oracle Server and Manager images
* variables regarding the Peoplesoft VM images
You MUST change all the values according to YOUR own environment.

3.2 Functions
There are some functions used to manage the startup and shutdown of the the components.
* check_availability()
This one check if the given server (IP address or name) is up or down with a ping server.
* xm()
This function start and stop the Peoplesoft VM images.
To start the Peoplesoft VM images, after connected onto the Oracle VM Server, it uses the Xen command, xm, available on Oracle VM server hosting the Peoplesoft VM image, e.g. :
xm create /OVS/running_pool/*${remote_image}/vm.cfg
To stop the Peoplesoft VM images, it is simply connect onto the server, and run a shudown :
shutdown -h now
There is also an xm command line option to stop Oracle VM image, but somehow, that does not work inside a ssh connection. It needs to be investigate further.
* vmware_vmrun()
Use to start and stop the VMWare images through the vmrun command line from VMWare 2.0.2.
* startup_psovm()
Main function to start all the environment. Firstly, start the VMWare images, then the Peoplesoft VM images within the functions xm() and vmware_vmrun() described above, and finally the database, the application server, the web server and the batch server.
* shutdown_psovm()
Main function to start all the environment. Firstly, stop batch server, the web server, the application server, then the Peoplesoft VM images and VMWare images within the functions xm() and vmware_vmrun() described above.
* main
The main of the script is small, check the valid input parameter (startupshutdown) and call the corresponding function.

3.2 The main commands used
As a remember, here are the main commands used in the script (of course, all the parameters need to be set in front) :
* This one return 0 if the server ${remote_server} is not available, 1 otherwise
count=$(ping -c 1 ${remote_server}  grep 'received'  awk -F',' '{ print $2 }'  awk '{ print $1 }')
* This one start the ORacle VM image ${remote_image}
xm create /OVS/running_pool/*${remote_image}/vm.cfg
* This one start the VMWare image ${vmware_image} :
${vmware_bin}/vmrun -T server -h https://${vmware_ip}:${vmware_port}/sdk -u ${vmware_user} -p ${vmware_pwd} start "[${datastore}] ${vmware_image}/${vmware_image}.vmx"
* This one return a number > 0 if the VMWare image${vmware_image} is up :
count=`${vmware_bin}/vmrun -T server -h https://${vmware_ip}:${vmware_port}/sdk -u ${vmware_user} -p ${vmware_pwd} listgrep "${vmware_image}/${vmware_image}.vmx"wc -l`
* Shutdown the VMWare image ${vmware_image} :
${vmware_bin}/vmrun -T server -h https://${vmware_ip}:${vmware_port}/sdk -u ${vmware_user} -p ${vmware_pwd} stop "[${datastore}] ${vmware_image}/${vmware_image}.vmx" soft
* Start the application domain ${ovs_apps} :
./psadmin -c boot -d ${ovs_apps}
* Start the batch domain ${ovs_prcs} :
./psadmin -p start -d ${ovs_prcs}
* Stop the batch domain ${ovs_prcs} :
./psadmin -p stop -d ${ovs_prcs}
* Stop the application domain ${ovs_apps} :
./psadmin -c shutdown -d ${ovs_apps}
* Note, start and stop the database are, well, standard for Oracle (startup, shutdown immediate)
* Note, start and stop the web server are,again standard for Weblogic (startPIA.sh, stopPIA.sh)

Now, you can find the script here : PSOVM_HR.sh

Enjoy,

Nicolas

No comments: