Showing posts with label Oracle. Show all posts
Showing posts with label Oracle. Show all posts

Thursday, March 20, 2014

Creating a Windows Guest on Oracle Database Appliance(ODA) Virtualized Platform

When it comes to deploying a Windows guest as a virtual machine on Oracle's ODA, the documentation is lacking.  After some research and trial and error, I was able to put together a process that will successfully install Windows.

The ODA utilizes the oakcli command line, so OVM is not an option.  In this post, I will walk through the steps needed to prepare and deploy a Windows 7 virtual machine.

Here is a high level summary of the steps.

1. Create an unformatted virtual disk image
2. Create a configuration file for the VM template
3. Create a shared repository
4. Import the VM template
5. Clone a VM from the template
6. Boot from iso file and install Windows
7. Configure Windows network
8. Install Paravirtialized Drivers on Windows guest
9. Modify VM's network


NOTE: For the purposes of this example, all logins for Dom0 and ODA_BASE are on node 0.

First, we need to log into Domain 0 (Dom0) and create an empty unformatted virtual disk image.  The image file name must be System.img.  In the example below, the file size is fixed at 50G.

$ mkdir /OVS/staging/vm_temp/win7x64

$ dd if=/dev/zero of=/OVS/staging/vm_temp/win7x64/System.img oflag=direct bs=1M count=51200


In the same staging directory, create a vm.cfg file with the following content.  The "boot" parameter is set as "dc" which sets the CDROM first in the boot order.  The "disk" parameter names the System.img file created above as the device "hda" in "read/write" mode.  Before the Paravirtualized Drivers(PV) get installed, the "vif" parameter needs to be set with a type of "ioemu".  Later, when the VM is started, a vnc session for the console will be started.  The vnc port is set in the "vfb" parameter with a vncdisplay of 10.  The 10 sets the port to 5910.  A value of 1 would set it to 5901.

kernel = 'hvmloader'
builder = 'hvm'
vcpus = '4'
memory = '4096'
boot = 'dc'
disk = ['file:/OVS/staging/vm_temp/win7x64/System.img,hda,w']
name = 'win7x64'
vif = [ 'type=ioemu,bridge=net1' ]
on_poweroff = 'destroy'
on_reboot = 'destroy'
on_crash = 'destroy'
acpi = '1'
apic = '1'
usbdevice='tablet'
vfb = [ 'type=vnc,vnclisten=0.0.0.0,vncdisplay=10' ]


The next step is creating the tar file containing the two files created above to be imported.

$ cd /OVS/staging/vm_temp/win7x64

$ tar -Sczvf win7x64.tgz System.img vm.cfg


There are default repositories created as part of the ODA_BASE.  The repos "odarepo1" and "odarepo2" are local repositories and will not allow VMs running from these repos to fail over to the other node.  To avoid this, create a shared repository.

NOTE:  Once you create the repo, the size cannot be changed, so plan accordingly.

Log on to ODA_BASE and run the following command to create a 150GB shared repository in the DATA disk group.

$ oakcli create repo odashr -size 150G -dg DATA


Now the environment is set up to import the template.  Login to ODA_BASE as root and run the following command.

$ oakcli import vmtemplate tmpl_win7x64 -files "/OVS/staging/vm_temp/win7x64/win7x64.tgz" -repo odashr -node 0


Once the template has been imported, the VM can finally be cloned.  Using the vmtemplate, run the following command on ODA_BASE.

$ oakcli clone vm vm_win7x64 -vmtemplate tmpl_win7x64 -repo odashr -node 0


Copy the Windows installation iso file to a staging location on Dom0.  Then modify the file /OVS/Repositories/odashr/VirtualMachines/vm_win7x64/vm.cfg on Dom0 by adding the iso as a CDROM.  Below, the iso file /OVS/staging/X17-24281.iso has been defined as device "hdc" and made read only.

disk = [u'file:/OVS/Repositories/odashr/VirtualMachines/vm_win7x64/System.img,hda,w', 'file:/OVS/staging/X17-24281.iso,hdc:cdrom,r']


Now start the VM by logging into ODA_BASE and running the following command.

$ oakcli start vm vm_win7x64


Once the VM starts, log onto Dom0 and attach to the console with a VNC client using the vnc port defined above.  In our example, the port is 5910.  From the VNC console, you need to install Windows.

After the installation is complete, log into Dom0 and modify the /OVS/Repositories/odashr/VirtualMachines/vm_win7x64/vm.cfg file.  Change the boot parameter from "dc" to "cd".  This will name the boot device to the virtual hard drive rather than the CDROM.

Log into ODA_BASE and restart the VM.

$ oakcli stop vm vm_win7x64

$ oakcli start vm vm_win7x64


Now attach to your vnc session again and configure the network settings for the VM guest as per your requirements.  Once the network is configured and functioning, you can download the Windows PV Drivers to the guest and install them by running the executable.  As of the date of this post, the PV drivers can be downloaded from edelivery.oracle.com.  Go to "Cloud Portal Oracle Linux/VM", and enter "Oracle VM" for the product pack and "x86 64 bit" for the platform.

After the PV drivers have been installed, modify the /OVS/Repositories/odashr/VirtualMachines/vm_win7x64/vm.cfg file by changing the "vif" parameter as follows.

From

vif = [ 'type=ioemu,bridge=net1']

To

vif = [ 'type=netfront,bridge=net1']


Now restart your VM, and the guest should be ready for use.  If you want to by-pass using the vnc session, configure remote desktop and connect to the console.

$ oakcli stop vm vm_win7x64

$ oakcli start vm vm_win7x64



Friday, February 7, 2014

Using Linux's Logrotate to Manage Alert and Listener Log Files

If you are running Oracle on Linux, there is a handy little utility called logrotate that can be used to manage those unwieldy alert logs and listener logs.

I recently worked on a client's database, and their alert log had information going back four years. When trying to examine the log with vi, it would take several minutes to open the file due to it's enormity. To help them out, I used this simple little tool to keep the files in check.

As root, I simply created a new file in /etc/logrotate.d on each RAC node called ora_cleanup. The example below is from node 2. This will copy the alert log with a numerical extension and truncate the existing file. It performs this monthly and keeps 13 months worth of log information before deleting old files. The listener log grows much faster, so it is configured to rotate weekly and keep 53 weeks of files. The copytruncate parameter is important for the listener log because the listener process holds an open handle on the existing file.

# alert log
/u01/app/oracle/diag/rdbms/orcl/orcl2/trace/alert_orcl2.log {
monthly
rotate 13
notifempty
missingok
copytruncate
nocreate
}

# listener log
/u01/app/asm/diag/tnslsnr/db102/listener_db102/trace/listener_db102.log {
weekly
rotate 53
notifempty
missingok
copytruncate
nocreate
}

After a few months, this is what the managed files look like in their directories.

$ cd /u01/app/oracle/diag/rdbms/orcl/orcl2/trace
$ ls -arltp alert_orcl2*
-rw-rw---- 1 oracle oinstall 50051579 Oct 10 15:17 alert_orcl2.log.5
-rw-rw---- 1 oracle oinstall   993219 Nov  1 04:02 alert_orcl2.log.4
-rw-rw---- 1 oracle oinstall  1124244 Dec  1 04:02 alert_orcl2.log.3
-rw-rw---- 1 oracle oinstall  1088332 Jan  1 04:02 alert_orcl2.log.2
-rw-rw---- 1 oracle oinstall  2163268 Feb  1 04:02 alert_orcl2.log.1
-rw-rw---- 1 oracle oinstall   279484 Feb  7 09:34 alert_orcl2.log

$ cd /u01/app/asm/diag/tnslsnr/db102/listener_db102/trace
$ ls -arltp listener_db102*
-rw-rw---- 1 oracle oinstall 3857048716 Oct 10 15:28 listener_db102.log.18
-rw-rw---- 1 oracle oinstall  196362891 Oct 18 13:13 listener_db102.log.17
-rw-rw---- 1 oracle oinstall   40298571 Oct 20 04:02 listener_db102.log.16
-rw-rw---- 1 oracle oinstall  178408740 Oct 27 04:02 listener_db102.log.15
-rw-rw---- 1 oracle oinstall  188301497 Nov  3 04:02 listener_db102.log.14
-rw-rw---- 1 oracle oinstall  185073120 Nov 10 04:02 listener_db102.log.13
-rw-rw---- 1 oracle oinstall  178345071 Nov 17 04:02 listener_db102.log.12
-rw-rw---- 1 oracle oinstall  178945914 Nov 24 04:02 listener_db102.log.11
-rw-rw---- 1 oracle oinstall  165829858 Dec  1 04:02 listener_db102.log.10
-rw-rw---- 1 oracle oinstall  179395363 Dec  8 04:02 listener_db102.log.9
-rw-rw---- 1 oracle oinstall  175671704 Dec 15 04:02 listener_db102.log.8
-rw-rw---- 1 oracle oinstall  195136727 Dec 22 04:02 listener_db102.log.7
-rw-rw---- 1 oracle oinstall  195512012 Dec 29 04:02 listener_db102.log.6
-rw-rw---- 1 oracle oinstall  201759600 Jan  5 04:02 listener_db102.log.5
-rw-rw---- 1 oracle oinstall  204589312 Jan 12 04:02 listener_db102.log.4
-rw-rw---- 1 oracle oinstall  213276652 Jan 19 04:02 listener_db102.log.3
-rw-rw---- 1 oracle oinstall  212229296 Jan 26 04:02 listener_db102.log.2
-rw-rw---- 1 oracle oinstall  211244326 Feb  2 04:02 listener_db102.log.1
-rw-rw---- 1 oracle oinstall  159275570 Feb  7 09:35 listener_db102.log