Friday

Oracle VM: Did you accidently delete your VM?

Lets say you deleted your VM (by accident or not) but now you want to restore it. Its pretty easy to do unless you selected the option “Remove image files from storage” when you deleted the VM.

To delete a VM:

From Oracle VM Manager, on the Virtual Machines tab, select the VM you would like to delete and from the “More Actions” drop down list and click on the “Go” button. The following confirmation screen will appear:

image

If you don’t want to clean up the image files from the VM Server manually, select “Remove image files from storage” and click on the delete button.

To clean up the files manually ssh to your Oracle VM Server, go to the /OVS/running_pool and delete it:

[root@ ~]# cd /OVS/running_pool/
[root@ running_pool]# ls
15_RC0001 22_RC0002 28_RC0003
[root@ running_pool]# cd 28_RC0003/
[root@ 28_RC0003]# ls -alrt
total 1001481
-rw-rw-rw- 1 root root 351 Aug 14 08:05 vm.cfg
drwxrwxrwx 5 root root 4096 Aug 14 08:05 ..
drwxrwxrwx 2 root root 4096 Aug 14 08:05 .
-rw-rw-rw- 1 root root 1025507328 Aug 14 08:07 System.img
[root@ 28_RC0003]# cd ..
[root@ running_pool]# rm –rf 28_RC0003

To restore a VM:

For any number of reasons you decide that you want to restore a previously deleted VM. If you didn’t select the “Remove image files from storage” option and you didn’t clean up the files manually, your VM is still on the VM Server. If the VM is no longer on disk then you’ll need to restore from tape and place it back in the /OVS/running_pool directory. (Hopefully you backed it up!)

Login to Oracle VM Manager, goto the Resources tab and select Virtual Machine Images.

image

Click on the Import button:

image

Select the second option, Select from Server Pool (Discover and register) and click on Next:

image

In the Virtual Machine Image Name drop down you should see you VM which is same name as the directory the VM is stored in in /OVS/running_pool. Select and fill in the other fields and click on the Next button. You will be shown a confirmation page, review the screen and click on the Confirm button. At which point you’ll be back to the Virtual Machine Images entry page:

image

Click on the Approve button. You will be shown another confirmation page, click on the Confirm button.

image

You should now see the VM in a powered off state. Click the Power On button and you should be good to go!

Oracle VM: Adding a disk to a Guest OS

 

For my first VM, I used the Oracle Enterprise Linux template provided by Oracle.   Depending on which template you download you either have 4GB or 10GB of disk space configured.

From the README here are the details for two templates.

 

Template                   Kernel                    VCPU RAM Storage
------------------------   ------------------------- ---- --- -------

OVM_EL5U2_X86_64_PVM_10GB  2.6.18-92.1.17.0.2.el5xen    2 2GB 10GB
OVM_EL5U2_X86_64_PVM_4GB   2.6.18-92.1.17.0.2.el5xen    1 1GB 4GB

Depending on how you want to use the VM, this may not be enough space.  So the first thing your going to want to do is add another disk.   As you can see in the screenshot below, from the Virtual Machine tab select the VM you would like to add disk to and click on the configure button.

image

Once you click on the configure button you will be presented with the configuration screen.  Click on the storage link (tab) and you should see something similar to the following:

image

Click on the Create New Virtual Disk button and the following window will appear:

image 

As you can see, I have already filled in the requested information. I usually use the mount point I plan on placing this disk under as the Virtual Disk Name .  Above I will be creating a ~10GB disk with the name u01.  Once you click on the Next button you will be provided with a summary screen:

image

After you click the Confirm button you will be brought back ot the Virtual Machine Configuration screen:

image

Notice that the disk I created, /u01 has a Disk Status of Creating.  If you login to the Oracle VM Machine your using to host this VM you will see that behind the scenes the dd command is being used to create a 10GB file named u01.img.   Below you can see I am ssh’d into the VM Server under the /OVS/running_pool directory where my VM is located.

image

Once the disk has finished being created it will be active:

image

Now that we have added the disk to the VM we need to format and mount it within the guest OS.   Notice the Front-end Device column in the screenshot above.  The value for u01 is xvdb and is the device name we will pass to fdisk to create a partition.   SSH or VNC into your VM as root.

[root@ ~]# fdisk -l
Disk /dev/xvdb: 10.4 GB, 10485760000 bytes
255 heads, 63 sectors/track, 1274 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


Disk /dev/xvdb doesn't contain a valid partition table

 

Above is just a clip of the fdisk –l output showing the device /dev/xvdb and that it doesn’t contain any partitions.  Next create a partition:


[root@ ~]# fdisk /dev/xvdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1274, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1274, default 1274):
Using default value 1274
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

[root@ ~]# fdisk -l

Disk /dev/xvdb: 10.4 GB, 10485760000 bytes
255 heads, 63 sectors/track, 1274 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1        1274    10233373+  83  Linux

Now that we have a valid partition, format it as an ext3 filesystem:


[root@ ~]# /sbin/mkfs -t ext3 /dev/xvdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1281696 inodes, 2558343 blocks
127917 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2621440000
79 block groups
32768 blocks per group, 32768 fragments per group
16224 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Next label the partition so we don’t have to use the device name in /etc/fstab.  Finally add the partition details in /etc/fstab so that its automatically mounted upon startup and mount the partition:


[root@ ~]# /sbin/e2label /dev/xvdb1 /u01
[root@ ~]# vi /etc/fstab
[root@ ~]# cat /etc/fstab
/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
LABEL=/u01              /u01                    ext3    defaults        1 2
[root@ ~]# mount /u01
[root@ ~]# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      10125560   3011540   6591372  32% /
/dev/xvda1              101086     13229     82638  14% /boot
tmpfs                  1048576         0   1048576   0% /dev/shm
/dev/xvdb1            10072456    153696   9407092   2% /u01

 

Thats it!  To summarize, I used Oracle VM Manager to add a new disk to my VM.  Then I logged into the VM created a partition on the new disk, formatted it, added the details to /etc/fstab and finally mounted it.  Next step, 11G Fusion!

Tuesday

My first Oracle VM install.

We are starting to embark on a new phase of a project and for the DEV environment we are planning to use Oracle VM. The initial phase of this project will be evaluating different software solutions and we believe Oracle VM will be a good fit. Why do I believe it makes sense for us?

  1. It will allow us to quickly build environments from templates provided by Oracle and GOLD images we create.
  2. We will be building many environments to evaluate different software solutions. With Oracle VM we can keep the installations separate and when not in use they can be shut down.
  3. We can place our DEV servers into a single server pool. This provides us with load balancing and the ability for the vm's to run on any server in the pool. In the event of planned hardware maintenance we can also migrate vm's to other servers in the the pool without downtime.
  4. As a DBA it provides me with some extra freedoms. I can clone a VM to test patches, upgrades, etc and not disturb the developers.
  5. I'm sure there are more benefits.


Number 2 and 3 will help maximize resources and maybe even be able to run more environments than I could on bare metal.

I'll be honest, I am a skeptic when it comes to virtualization. There have been plenty of discussions on the Oracle-L and OAUG mailing lists with pros/cons and success stories. I believe virtualization makes perfect sense for certain situations such as training. I've been using it myself for the past couple of years to practice/learn things I otherwise couldn't. (Such as RAC.) Time will tell whether or not we will see any benefit from this in our environment. I'll be sure to post a follow up in a couple of months.

Installing Oracle VM was pretty easy but I did have a couple of issues. The VM Manager installed within minutes. Although, my first few attempts failed. I created a CD from the ISO images provided by Oracle but instead of walking down 5 flights of stairs to the server room (bad ankle), I took the 'lazy' approach and copied the CD to local disk on the server. The install proceeded without any errors but the VM Manager wouldn't start properly. On my way out of the building I mounted the CD in the server, reinstalled and it worked flawlessly. Not sure why it caused me problems because I have staged other Oracle products the same way without issue.

Oracle VM Server was a bit more difficult but I believe that is due to my hardware configuration. I am not sure why but when installing any flavor of linux (including the VM Server), the SAN drive is placed ahead of local disk in the boot order. Apparently the BIOS is responsible for providing the details of the correct drive order but everything looked fine. The controller servicing local disk was listed before the controller connected to the SAN and on top of that, it wasn't even configured to be bootable. So by default, the boot loader was being installed on the MBR for the SAN. After a reboot I would receive GRUB errors.

With a full Linux distribution such as RedHat or Oracle Enterprise Linux you are provided with some advanced boot loader configuration options, one of them being to change the drive order. By manually placing the local disk ahead of the SAN, I am now provided with the option to install the boot loader on the MBR of the local disk. I can now install Linux and boot with no issues.

Oracle VM Server however, doesn't provide you with any advanced boot loader configuration options. So I had no choice but to place my SAN controller ahead of the local controller in the boot order and allow it to be bootable. However, when I rebooted I was greeted with "Error 21: Selected disk does not exist". I examined the grub config and noticed that it was trying to boot from "root (hd1,0)". hd1 should be corresponding to my local disk since it was placed second in the boot order and this is where I placed the /boot partition (along with the rest of the VM server install). I wanted to reserve the SAN drive for the /OVS directory, which is where all of the VM's are stored and also the bulk of my disk space.

For some reason tho, local disk is hd0. I edited the grub config to boot from "root (hd0,0)", restarted and it worked flawlessly. I'll admit, i'm not a server admin in a professional sense. I've been using linux since around ~93 (Slackware version 1), so I can figure things out but i've never supported it in a corporate environment with server class hardware before. I wouldn't be surprised if there is some hardware/BIOS config issues at play here.

Now that its installed, the fun begins!