Creating a vServer Template

To create a vServer template from an existing vServer (for example, pwtest), do the following:

  1. Stop the vServer as described in Stopping vServers.

  2. Log in to the OVMM web interface as the root user and do the following:

    Note:

    • In this procedure, you use OVMM to clone and start a vServer. Unless explicitly documented (as in this appendix), do not use OVMM to create a vServer or perform any lifecycle operations on a vServer. Use only Exalogic Control to manage vServers.

    • The steps in this procedure are based on the OVMM web interface of Oracle VM release 3.2, which is included in Exalogic Elastic Cloud Software 2.0.6.x.x. If you are at Exalogic Elastic Cloud Software 2.0.4.x.x (or a lower release), the corresponding Oracle VM release would be 3.0.3, and the OVMM web interface may be different from that described here.

    1. Select the Servers and VMs tab.

    2. Expand Server Pools in the navigation pane on the left, and select the server pool displayed there.

    3. In the tool bar of the main display pane, change the Perspective to Virtual Machines.

      A list of all the VMs is displayed.

    4. Look for the vServer that you stopped in step 1. The status of the VM would be Stopped.

    5. Right-click on the VM, and from the resulting context menu, select Clone or Move.

      The Clone or Move Virtual Machine wizard starts.

    6. Leave the Create a clone of this VM option selected, and click Next.

    7. On the next screen, do the following:

      i. Leave the Clone to a Virtual Machine option selected.

      ii. Leave the Clone Count value at 1.

      iii. Enter a name for the clone (for example, pw-test2), and enter a description.

      iv. Click OK.

      Wait for the OVMM job to finish. The job may take a few minutes, depending on the size of the virtual disks in the VM being cloned.

      OVMM assigns the new vServer (pw-test2) to one of the available servers in the pool.

    8. Select the new VM, right-click, and select Start.

    9. Expand the row corresponding to the new VM by double-clicking in the first column.

      In the resulting pane, look for the ID (for example, 0004fb000006000030c6ec27dd5a2327). This is the UUID of the VM. Note the UUID for later use.

      Note:

      In this procedure, this ID is referenced as VM_CLONE_UUID.

  3. After the clone VM (pw-test2) starts, log in as root to the Oracle VM Server node that hosts the VM (slce02cn02 in this example).

    View a list of the VMs running on the node, by running the following command:

    [root@slce02cn02 ~]#xm list

    This command displays output, as in the following example:

    Name                                        ID  Mem  VCPUs    State   Time(s)
    0004fb00000600009c75583293d01d04            1   4096   2       -b---- 139169.3
    0004fb000006000030c6ec27dd5a2327            24  4096   1       -b----    36.8
    Domain-0                                    0   2002   24       r----- 115451.5
    

    Log in to the VM (pw-test2) by using the xm console <ID> command, where <ID> is the ID of the VM, which has <VM_CLONE_UUID> as its name. For example, run the xm console 24 command on slce02cn02. This command displays output, as in the following example:

    Oracle Linux Server release 5.6
    Kernel 2.6.32-200.21.2.el5uek on an x86_64
    
    pw-test login: root
    Password:
    Last login: Thu May 24 12:35:35 on ttyS0
    [root@pw-test ~]#
    

    Note:

    In the output, note that the hostname is the same as the original VM (pw-test). It is not the name of the clone (pw-test2). Further, the network interfaces initialized by /etc/sysconfig/network-scripts/ifcfg-bond* are also the same as the original VM. The next step unconfigures the VM, so it can be used to create a template that causes Exalogic Control to configure hostname and network scripts when a vServer is created with the template.

  4. Unconfigure the clone VM (pw-test2), and stop the VM as follows:

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

    2. Remove DNS information by running the following commands:

      cd /etc

      sed -i '/.*/d' resolv.conf

    3. Remove SSH information by running the following commands:

      rm -f /root/.ssh/*

      rm -f /etc/ssh/ssh_host*

    4. Clean up the /etc/sysconfig/network file by running the following commands:

      cd /etc/sysconfig

      sed -i '/^GATEWAY/d' network

    5. 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

    6. 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*

    7. 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

      rm -f messages*

      rm -f ovm-template-config.log

      rm -f ovm-network.log

      rm -f boot.log*

      rm -f cron*

      rm -f maillog*

      rm -f messages*

      rm -f rpmpkgs*

      rm -f secure*

      rm -f spooler*

      rm -f yum.log*

    8. Remove kernel messages by running the following commands:

      cd /var/log

      rm -f dmesg

      dmesg -c

      > ovm-network.log

    9. 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
      

      Save the file after making these changes.

    10. Edit the /etc/sysconfig/hwconf file and modify the driver: mlx4_en entry to driver: mlx4_core. Save the file after making changes.

    11. Remove the Exalogic configuration file by running the following command:

      rm -f /etc/exalogic.conf

    12. Remove bash history by running the following commands:

      rm -f /root/.bash_history

      history -c

      Do this in the end to avoid recording the cleanup commands.

      Note:

      Before proceeding, consider the following points:

      • Any storage volume that is attached to the base VM (pw-test) is cloned to the clone VM (pw-test2), including all the contents of the volume. This also applies to the template you are creating in the next step and to the vServers created from the template. Be sure to delete any unwanted files, or drop the storage volume before proceeding with template creation.

      • When creating a vServer, Exalogic Control resizes any attached storage volumes smaller than the storage size in the Server Type to the specified storage size. For example, if you have an attached volume of size 2 GB and you select a Server Type with storage size of 4 GB, the new attached volume will have the size 4 GB. There is no change to the file systems on the volume.

  5. Package the template for upload into Exalogic Control as follows:

    1. Log in to any Oracle VM Server node, such as slce02cn01, as the root user.

    2. Create a workspace on the Sun ZFS Storage Appliance, which is included in your Exalogic machine.

      The following example uses a directory in the /export/common/images share:

      [root@slce02cn01 ~]# mkdir -p /u01/common/images
      [root@slce02cn01 ~]# mount -t nfs slce02sn01:/export/common/images /u01/common/images
      [root@slce02cn01 ~]# mkdir /u01/common/images/pw-template
      
    3. Change directory to the Oracle VM Server (OVS) repository for the VM clone and verify that you are in the correct directory:

      [root@slce02cn01 ~]# cd /OVS/Repositories/*/VirtualMachines/<VM_CLONE_UUID>
      [root@slce02cn02 0004fb000006000030c6ec27dd5a2327]# grep simple_name vm.cfgOVM_simple_name = 'pw-test2'
      
    4. Copy the configuration file to the Sun ZFS Storage Appliance workspace:

      [root@slce02cn01 0004fb000006000030c6ec27dd5a2327]# cp vm.cfg /u01/common/images/pw-template
      
    5. Display the disk(s) used by the cloned VM:

      [root@slce02cn01 0004fb000006000030c6ec27dd5a2327]# grep disk vm.cfg
      disk = ['file:/OVS/Repositories/0004fb0000030000169d06eb2fdfcc6f/VirtualDisks/0004fb00001200004e5b424a5f5965bf.img,hda,w', 'file:/OVS/Repositories/0004fb0000030000169d06eb2fdfcc6f/VirtualDisks/0004fb00001200008d2bc3496683e1c4.img,xvdb,w']
      
    6. Copy the disk(s) to the Sun ZFS Storage Appliance workspace using the file name(s) displayed above:

      [root@slce02cn01 0004fb000006000030c6ec27dd5a2327]# cp /OVS/Repositories/0004fb0000030000169d06eb2fdfcc6f/VirtualDisks/0004fb00001200004e5b424a5f5965bf.img /u01/common/images/pw-template/
      [root@slce02cn01 0004fb000006000030c6ec27dd5a2327]# cp /OVS/Repositories/0004fb0000030000169d06eb2fdfcc6f/VirtualDisks/0004fb00001200008d2bc3496683e1c4.img /u01/common/images/pw-template/
      
    7. Create a compressed tar file with template configuration and disk(s) as follows:

      [root@slce02cn01 0004fb000006000030c6ec27dd5a2327]# cd /u01/common/images/pw-template
      [root@slce02cn01 pw-template]# tar zcvf pw-template.tgz * 0004fb00001200004e5b424a5f5965bf.img 0004fb00001200008d2bc3496683e1c4.img vm.cfg
      

      The resulting file is a server template ready for upload into Exalogic Control.

    8. Delete the VM clone, which you no longer need. In OVMM, right-click on the VM clone, and select Delete. In the Delete Confirmation screen, select the virtual disk(s) used by the VM, and click OK.

  6. If the HTTP protocol is not enabled on the Sun ZFS Storage Appliance with access to the workspace, complete the following steps:

    1. Use SSH to log in to the storage node (for example, slce02sn01) and enable the HTTP service, as in the following example:

      slce02sn01:> configuration services http
      slce02sn01:configuration services http> enable
      slce02sn01:configuration services http> show
      Properties:
                       <status> = online
                       require_login = false
                       protocols = http/https
                       listen_port = 80
                       https_port = 443
      
    2. Verify that the workspace with the template package is accessible by HTTP.

      slce02sn01:configuration services http> cd /
      slce02sn01:> shares
      slce02sn01:shares> select common
      slce02sn01:shares common> get sharedav
                            sharedav = off
      slce02sn01:shares common> set sharedav=ro
                            sharedav = ro (uncommitted)slce02sn01:shares common> commit
      slce02sn01:shares common> select images
      slce02sn01:shares common/images> get sharedav
                            sharedav = off
      slce02sn01:shares common/images> set sharedav=ro
                            sharedav = ro (uncommitted)
      slce02sn01:shares common/images> commit
      

      If the sharedav property is already set to rw or ro, you do not need to change it.

    3. Log out of the Sun ZFS Storage Appliance:

      slce02sn01: shares common/images> exit
      Connection to slce02sn01 closed.
      
  7. Using Exalogic Control, upload the new server template to an account as follows:

    1. Log in to the Exalogic Control web interface as a Cloud Admin or Cloud User.

    2. In the navigation pane on the left, click vDC Management. Under vDC Accounts, click the name of your Account. The vDC Account dashboard is displayed.

    3. Click Server Templates on the top navigation bar. The server templates available in your Account are listed.

    4. Under Server Templates, click the Upload Server Template icon. Alternatively, click Upload Server Template under Operate on the Actions pane. The Upload Server Template wizard is displayed, as shown in Figure G-1.

      Figure G-1 Identify Server Template

      Description of Figure G-1 follows
      Description of "Figure G-1 Identify Server Template"
    5. On the Identify Server Template screen, enter a name and description for the server template to be uploaded. For example, enter Template1 in the Name field. In the Description field, enter a brief description.You can add tags for later identification and search.

    6. Click Next. The Specify Server Template Details screen is displayed, as shown in Figure G-2.

      Figure G-2 Specify Server Template Details

      Description of Figure G-2 follows
      Description of "Figure G-2 Specify Server Template Details"
    7. Select the Image SubType option, and select Template.

    8. Select URL as the Upload Source. To specify a URL, enter the HTTP URL for the template package created in Step 6, in the Server Template URL field.

      If you used the same workspace as this document, the URL will be:

      http://<zfssa-host>/shares/export/common/images/<workspace>/<template>.tgz

      Click Next.

    9. Review the summary, and click Upload to upload the server template.

    10. Click Server Templates on the top navigation bar. You should see the newly uploaded server template listed. You can start creating vServers based on this server template.