Wednesday, 5 December 2012

Backing up an Exalogic vServer via templating the vServer

 Introduction


Following on from my earlier post about backing up a vServer using the rsync command  it is also possible to effectively backup a vServer by using the capability to template it. This is documented in appendix F of the Cloud Administrators guide however an example process is documented here to create a template and re-create a vServer from this template.

A really useful little script has been created by the Exalogic A-Team that could save you some time and effort in templating a vServer.  It is available for download from here.   To do it manually read on....

The vServer we will be using to perform the actions on is the same one that we have done a backup with using rsync.  Namely a vServer that has been configured to perform an rsync backup and has an additional partition over and above the Exalogic base template mounted on /u01 that contains a deployment of Weblogic.

The general steps to follow are:-
  1. Shutdown vServer
  2. Clone in OVMM
  3. Startup cloned image
  4. Log on and edit to remove configuration
  5. Shutdown
  6. Copy files to create a template
  7. Import template to Exalogic Control
  8. Delete previous vServer
  9. Create new vServer based on new template
  10. Check operation.

Shutdown/Clone Operations (Backup)

The first step is simply to shutdown the vServer, this can be done from Exalogic Control. Then we switch context to log in to OVMM in order to perform the cloning activity. Below is a screenshot of the clone process in OVMM.



As you can see we do not clone as a template but clone the machine as a vServer. This is because we will make changes to the new vServer so that it can become a template for Exalogic Control.  Thus once the job to clone the machine has completed we can then go in and start the server up. The behaviour is to automatically assign the cloned vServer into the target server pool that was selected, however it will be stopped by default. By highlighting the pool and selecting the "Virtual Machines" tab we are able to select our newly created clone and start it.

Once the machine has started it is possible to log onto the cloned vServer using the IP address of the previous instance. Log on as root and now we want to make a number of changes to the configuration files so that it becomes an "unconfigured" vServer, ready to be imported as a template into Exalogic Control. The changes to perform are described below.

Action 
Detail 
Edit and /etc/sysconfig/ovmd file and change the INITIAL_CONFIG=no parameter to INITIAL_CONFIG=yes. Save the file after making this change.

Remove DNS information by running the following commands:
cd /etc
sed -i '/.*/d' resolv.conf
Remove SSH information by running the following commands:
rm -f /root/.ssh/*
rm -f /etc/ssh/ssh_host*
Clean up the /etc/sysconfig/network file by running the following commands:
cd /etc/sysconfig
sed -i '/^GATEWAY/d' network
Clean up the hosts files by running the following commands:
cd /etc
sed -i '/localhost/!d' hosts
cd /etc/sysconfig/networking/profiles/default
sed -i '/localhost/!d' hosts
Remove network scripts by running the following commands:
cd /etc/sysconfig/network-scripts
rm -f ifcfg-*eth*
rm -f ifcfg-ib*
rm -f ifcfg-bond*
Remove log files, including the ones that contain information you do not want to propagate to new vServers, by running the following commands:
cd /var/log and remove the following files
messages*, ovm-template-config.log,ovm-network.log, boot.log*, cron*, maillog*, messages*, rpmpkgs*, secure*, spooler*, yum.log*
Remove kernel messages by running the following commands:
cd /var/log
rm -f dmesg
dmesg -c
Edit the /etc/modprobe.conf file and remove the following lines (and other lines starting with alias bond):
options bonding max_bonds=11
alias bond0 bonding
alias bond1 bonding
Edit the /etc/sysconfig/hwconf file and modify the driver: mlx4_en entry to driver: mlx4_core. Save the file after making changes.

Remove the Exalogic configuration file by running the following command:
rm -f /etc/exalogic.conf
Remove bash history by running the following commands:
rm -f /root/.bash_history
history -c

Once completed stop the vServer from the command line. Then log onto one of the hypervisor compute nodes. What we need to do is copy the disk images and the vm.cfg file from the OVS repository into a scratch area where we will create the template.  The simplest mechanism to achieve this on an Exalogic rack is by placing them onto the handy ZFS appliance. This can be made available via HTTP to Exalogic Control to upload the template. Thus the steps to follow are:-
  1. Mount a share on the compute node
    # mkdir /mnt/images
    # mount <ZFS Appliance IP>:/export/common/images /mnt/images
  2. Under the /OVS/Repositories directory will be a unique ID then a directory called VirtualMachines. Under this directory will be multiple directories named by their identifiers. Each with a vm.cfg file contained within. This is one of the files that we need to copy to the scratch area.
    # cd /OVS/Repositories/*/VirtualMachines
    # grep -i simple */vm.cfg
    This will enable you to spot the name of the cloned vServer and hence identify the correct vm.cfg file.
  3. Copy the cloned vServer vm.cfg to the scratch area.
    # cp vm.cfg /mnt/images
  4. Inside the vm.cfg file is a line that specifies the disks involved. Copy the disk image into the scratch area.
  5. Create the template by simply creating a tar.gz file from the config file and the disk image.
    # cd /mnt/images
    # tar zvcf my_template.tar.gz vm.cfg <disk image ID.img>

Startup/Create Operations (Restore)

Now load up the template into Exalogic control and create a vServer from it. If the new vServer looks to match in perfectly with the old one and all your testing proves a successful duplicate then all we need do is a tidy up exercise:-
  • Delete the image file and config file from the location where we created the template. (You may want to delete the template as well although it might be worth keeping it as a historical archive.  It will depend on how much free storage space you have.)
  • Delete the clone from OVMM. Make sure you mark all the volumes to be deleted.

For more complicated deployments it is likely that if you are moving your vServer to a new rack or recreating another instance there may be changes required to configuration held on disk to correct things such as IP address changes, mounts in /etc/fstab, /etc/hosts file etc.

Advantages/Disadvantages of this approach

Using the template capability has both advantages and disadvantages and it will depend on what you are aiming to achieve as to what backup approach you use.


Advantages Disadvantages
Ability to make the backup portable to any Exalogic rack The existing vServer must be shutdown, making its service unavailable for a period of time.
A simple process Not able to recover individual files and directories without going through an entire process of creating another vServer and copying files back from this newly created vServer.
Intensive work required to script up for automated backup.

1 comment: