Tuesday 30 July 2013

Exalogic Virtual Tea Break Snippets - Modifying Memory, CPU and Storage on a vServer (A SimpleExaCli.sh Tutorial)

With the current release of Exalogic Virtual the Enterprise Manager Ops Center interface does not provide a support method for increasing the reasources associated with a running vServer. Therefore to increase the CPU, Memory or Disk size of a vServer we need to recreate vServer using the same Network information, mapped storage etc but with the new CPU, Memory and Disks space. Rather than simply destrying and then manually recreating the vServer we can use the SimpleExaCli.sh script described in the blog entry "Exalogic Virtual Tea Break Snippets - Simplified Exalogic IaaS Cli" to first create a template and capture the network information. Then using the generated Template and captured information to recreate the vServer with a new "VServer Type" that defines the new resource requirements. This blog entry will take you through the simple process of resizing the resources associated with an already existing Exalogic vServer.

Prerequisites

Before attempting to execute this procedure you will need to download the SimpleExaCli.sh from the Exalogic Virtual Tea Break Snippets - Simplified Exalogic IaaS Cli and install the Exalogic IaaS API/CLI as described. Once this has been done the simple step defined below will allow the modification of the existing resources.
Note: If you have just installed the SimpleExaCli.sh and have not run it previously on the current machine then it should be executed as follows to validate the authentication:
./SimpleExaCli.sh --test-cli
In addition we should validate passwordless ssh is available to the IP address specifies in the -cip parameter.

Scenario

In this simple scenario I have a vServer, vsResizeTutorial, created using the default vServer Template and the SMALL VServer Type (4 GB Memory, 1 CPU & 4 GB Storage) connected to 3 networks EoIB-network1-vlan112-10.242.96.0/21 (Static IP), IPoIB-vserver-shared-storage (Automatic IP) and vnTutorial (Static IP). What we now want is a vServer with 8 GB Memory, 2 CPU and 8 GB Storage, which just happens to match the LARGE VServer Type, but keep the two static IP and we do not need to worry about the automatic because this is simply the shared storage.

Capturing vServer Information

To capture the current vServer information we will using the SimpleExaCli.sh --capture-vserver command to retrieve the current details and write them to an Asset file that can then be used with the --create-assets command to recreate the vServer. I will assume that the user has installed the SimpleExaCli.sh on the EMOC Control vServer and hence will not specify the -url for EMOC. Executing the following line will capture the current vServer information into a template called el_template_vsResizeTutorial.tgz located on the ZFS and an Asset file vsResizeTutorial.in within the current directory.

Note: If the vServer has attached Volumes these should be removed prior to the capture process otherwise they will be built into the Template.
./SimpleExaCli.sh --capture-vserver -a andrew -v vsResizeTutorial -u tutorialuser -p welcome1 -cip 192.168.23.1 -sip 192.168.21.9 -keep-resolv -keep-hosts -vs-type LARGE

Output

[root@ec1-vm scripts]# ./SimpleExaCli.sh --capture-vserver -a andrew -v vsResizeTutorial -u tutorialuser -p welcome1 -cip 192.168.23.1 -sip 192.168.21.9 -keep-resolv -keep-hosts -vs-type LARGE
JAVA_HOME is not defined using /usr/java/latest
Stopping vServer vsResizeTutorial VSRV-ea84cf89-008d-42b8-86dc-0a36374094f0

Pausing until vServer has Shutdown
vsResizeTutorial RUNNING
Sleeping.......
vsResizeTutorial SHUTDOWNDETACHED
Just Waiting 30 Seconds......
Executing Remote Functions
Additional -keep-resolv -keep-hosts
Copying script ./SimpleExaCli.sh to 192.168.23.1
SimpleExaCli.sh 100% 75KB 75.4KB/s 00:00
JAVA_HOME is not defined using /usr/java/latest
Copying vServer Files
Copying /OVS/Repositories/0004fb00000300003c827205da5e5321/VirtualDisks/0004fb000012000095ecc177553544f8.img
Ignoring vm.cfg entry : OVM_simple_name = 'vsResizeTutorial'
Ignoring vm.cfg entry : disk = ['file:/OVS/Repositories/0004fb00000300003c827205da5e5321/VirtualDisks/0004fb000012000095ecc177553544f8.img,hda,w']
Ignoring vm.cfg entry : boot = 'c'
Ignoring vm.cfg entry : name = '0004fb000006000049391befa0c1c62c'
Ignoring vm.cfg entry : cpu_weight = 27500
Ignoring vm.cfg entry : cpu_cap = 0
Ignoring vm.cfg entry : OVM_high_availability = True
Ignoring vm.cfg entry : on_poweroff = 'destroy'
Ignoring vm.cfg entry : OVM_description = 'VServer for Resizing Blog Entry'
Ignoring vm.cfg entry : vfb = ['type=vnc,vncunused=1,vnclisten=127.0.0.1']
Unconfiguring Root Image /u01/common/images/vServerTemplatesWIP/vsResizeTutorial/template/BASE/System.img
Mounted /mnt/elsystem
removed `etc/sysconfig/ovmd.orig'
Keeping unmodified resolv.conf
removed `root/.ssh/known_hosts'
removed `etc/ssh/ssh_host_dsa_key'
removed `etc/ssh/ssh_host_dsa_key.pub'
removed `etc/ssh/ssh_host_key'
removed `etc/ssh/ssh_host_key.pub'
removed `etc/ssh/ssh_host_rsa_key'
removed `etc/ssh/ssh_host_rsa_key.pub'
Keeping unmodified hosts
removed `etc/sysconfig/network-scripts/ifcfg-eth166_1.112'
removed `etc/sysconfig/network-scripts/ifcfg-eth326_2.112'
removed `etc/sysconfig/network-scripts/ifcfg-ib0.8003'
removed `etc/sysconfig/network-scripts/ifcfg-ib0.8005'
removed `etc/sysconfig/network-scripts/ifcfg-ib0.800e'
removed `etc/sysconfig/network-scripts/ifcfg-ib1.8003'
removed `etc/sysconfig/network-scripts/ifcfg-ib1.8005'
removed `etc/sysconfig/network-scripts/ifcfg-ib1.800e'
removed `etc/sysconfig/network-scripts/ifcfg-bond0'
removed `etc/sysconfig/network-scripts/ifcfg-bond1'
removed `etc/sysconfig/network-scripts/ifcfg-bond2'
removed `etc/sysconfig/network-scripts/ifcfg-bond3'
removed `var/log/messages'
removed `var/log/messages.1'
removed `var/log/ovm-template-config.log'
removed `var/log/ovm-network.log'
removed `var/log/boot.log'
removed `var/log/boot.log.1'
removed `var/log/cron'
removed `var/log/cron.1'
removed `var/log/maillog'
removed `var/log/maillog.1'
removed `var/log/rpmpkgs'
removed `var/log/rpmpkgs.1'
removed `var/log/secure'
removed `var/log/secure.1'
removed `var/log/spooler'
removed `var/log/spooler.1'
removed `var/log/yum.log'
removed `var/log/yum.log.1'
removed `var/log/dmesg'
removed `etc/sysconfig/hwconf.orig'
removed `etc/exalogic.conf'
rm: cannot remove `root/.bash_history': No such file or directory
Unmounted /mnt/elsystem
Creating the Template tgz file
System.img
vm.cfg
Template /u01/common/images/vServerTemplates/el_template_vsResizeTutorial.tgz file created
Cleaning Working Directory
removed `vsResizeTutorial/template/BASE/System.img'
removed `vsResizeTutorial/template/BASE/vm.cfg'
removed directory: `vsResizeTutorial/template/BASE'
removed directory: `vsResizeTutorial/template'
removed directory: `vsResizeTutorial'

****************************************************
**
** /u01/common/images/vServerTemplates/el_template_vsResizeTutorial.tgz has been created from
** vServer vsResizeTutorial
**
****************************************************

Starting vServer vsResizeTutorial VSRV-ea84cf89-008d-42b8-86dc-0a36374094f0

Pausing until vServer is Running
vsResizeTutorial SCHEDULED
Sleeping.......
vsResizeTutorial NOSTATE
Sleeping.......
vsResizeTutorial RUNNING
Just Waiting 30 Seconds......
Capturing Asset information to input file
Generated Asset File vsResizeTutorialAsset.in

****************************************************
**
** /u01/common/images/vServerTemplates/el_template_vsResizeTutorial.tgz has been created from
** vServer vsResizeTutorial
**
****************************************************

[root@ec1-vm scripts]#
It can be seen from the command-line above that I specified the new VServer Type using the -vs-type parameter. This is an optional parameter and if specified will use this VServer Type in the generated asset file rather than the existing one. The -keep-resolv and -keep-hosts flags tell the script not to reinitialise the resolv.conf and hosts files during the templatisation of the vServer.

vsResizeTutorialAsset.in File

If we look at the generated vsResizeTurtorialAsset.in file we can see that it contains all the information about the vServer except the Distribution Group which can not be obtained through the CLI. If the vServer needs to be placed in a Distribution Group then the -vs-dg parameter can be specified on the command line.

andrew:Connect|tutorialuser|welcome1
andrew:Upload|ServerTemplate|vsResizeTutorial-Template|http://192.168.21.9/shares/export/common/images/vServerTemplates/el_template_vsResizeTutorial.tgz
andrew:Create|vServer|vsResizeTutorial|LARGE|vsResizeTutorial-Template|vnTutorial,IPoIB-vserver-shared-storage,EoIB-network1-vlan112-10.242.96.0/21|192.168.0.62,172.17.0.250,10.242.96.109||VServer_for_Resizing_Blog_Entry
andrew:Disconnect
At this point we can not execute the -create-asset file with the generated one because the IPoIB-vserver-shared-storage was defined with an Automatic IP. Because we do not need to keep the same IP Address for this network we will modify the Create|vServer line to specify Automatic IP generation and this is done by replacing the existing IP address (172.17.0.250) with an * as follows.

andrew:Connect|tutorialuser|welcome1
andrew:Upload|ServerTemplate|vsResizeTutorial-Template|http://192.168.21.9/shares/export/common/images/vServerTemplates/el_template_vsResizeTutorial.tgz
andrew:Create|vServer|vsResizeTutorial|LARGE|vsResizeTutorial-Template|vnTutorial,IPoIB-vserver-shared-storage,EoIB-network1-vlan112-10.242.96.0/21|192.168.0.62,*,10.242.96.109||VServer_for_Resizing_Blog_Entry
andrew:Disconnect
You will also notice that the VServer Type specified is LARGE rather than the current SMALL, if you forget to add the -vs-type parmeter to the command line then the Asset file can be edited directly to implement this change.

Recreating the vServer

To resize the vServer we must now recreate it and the the first step will be to delete the existing vServer (we can not rename the existing vServer because it still holds the static IP Addresses). Once the vServer has been removed it can be recreated by executing the SimpleExaCli.sh with the -create-assets command as follows.
./SimpleExaCli.sh --create-assets -f vsResizeTutorialAsset.in -remove-ssh-key

Output

[root@ec1-vm scripts]# ./SimpleExaCli.sh --create-assets -f vsResizeTutorialAsset.in -remove-ssh-key
JAVA_HOME is not defined using /usr/java/latest

About to execute : /opt/oracle/iaas/cli/bin/iaas-create-server-template-from-url --name vsResizeTutorial-Template --url http://192.168.21.9/shares/export/common/images/vServerTemplates/el_template_vsResizeTutorial.tgz
TMPL-cae0c067-3caf-4279-b5de-56a46d38d983
Pausing until Template upload has completed
vsResizeTutorial-Template SCHEDULED
Sleeping.......
vsResizeTutorial-Template SCHEDULED
Sleeping.......
vsResizeTutorial-Template SCHEDULED
Sleeping.......
vsResizeTutorial-Template SCHEDULED
Sleeping.......
vsResizeTutorial-Template SCHEDULED
Sleeping.......
Creating vServer vsResizeTutorial
Checking IP Address 192.168.0.62
Returning IP Address 192.168.0.62
Checking IP Address *
Returning IP Address 172.17.0.240
Checking IP Address 10.242.96.109
Returning IP Address 10.242.96.109
About to execute : /opt/oracle/iaas/cli/bin/iaas-run-vserver --name vsResizeTutorial --key-name andrew.20130730-1040.13899.cli.asset.create --vserver-type 2007 --server-template-id TMPL-cae0c067-3caf-4279-b5de-56a46d38d983 --vnets VNET-53071bd4-a704-4a36-8ec0-63006bf6b3cf,VNET-73452bf7-1341-4508-a49a-4536922d485b,VNET-2544e1e2-7f9b-44ea-9696-d244c956563f --ip-addresses 192.168.0.62,172.17.0.240,10.242.96.109
VSRV-3209ca8f-e1a1-4a2a-a63e-7e6f7341b7d3
Pausing until vServer is Running
vsResizeTutorial SCHEDULED
Sleeping.......
vsResizeTutorial SCHEDULED
Sleeping.......
vsResizeTutorial SCHEDULED
Sleeping.......
vsResizeTutorial SCHEDULED
Sleeping.......
vsResizeTutorial SCHEDULED
Sleeping.......
vsResizeTutorial SCHEDULED
Sleeping.......
vsResizeTutorial SCHEDULED
Sleeping.......
vsResizeTutorial RUNNING
Just Waiting 30 Seconds......
192.168.0.62 Address does not work for ssh
send: spawn id exp6 not open
while executing
"send "Password\r""
172.17.0.240 Address works for ssh

Removing ssh key requirement for vsResizeTutorial on 172.17.0.240
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
Removed ssh key requirement for vsResizeTutorial
vServer vsResizeTutorial has been created
As we can see from the Summary information below the vServer has now been recreated with the same Static IPs and the new VServer Type specified sizing.

1 comment:

  1. Hi Andrew, great stuff! Will this work for the Echo release as well ?

    ReplyDelete