sabato 30 giugno 2012

Oracle VM Backup Running Guests VMs


In this post I provide a way to perform backup of running VMs for disaster recovery purpouse. Basically this procedure transfers VM Disks from production Repository to a different backup Repository placed on another SAN storage.
Please bear in mind that this backup does NOT guarantee data consistency so if your VMs runs apps such as DBs consider a backup strategy using utility tools such as rman.

In case you need to recover a VM you need first to delete the VM and corresponding disks from VM Manager then import backed up disk image and recreate the VM using imported disk image as virtual disk.



I use a dedicated Oracle Linux 6 U2 server to perform backups; it's basically a VM using a virtual disk mapped to a Repository created on an ISCSI separated storage.

Let's start step-by-step:

First I've created a dedicated Backup VM in VM Manager.

NOTE: Consider carefully the VirtualDisk size since in this machine you will store backup VirtualDisks. For example if you need to backup 5 VMs each one with a 20GB hard disk you need to have AT LEAST 20*5=100GB available disk space after system installation.

Second step is to install OS. I use Oracle Linux 6 U2 server.

Please refer to this guide to install oracle Linux: Oracle Linux installation & configuration guide

When OS is installed I created a dedicated user to perform backups:

[root@orcl ~]$ adduser VMBackup

Then I need to install two additional packages to allow backup script to be correctly executed:

[root@orcl ~]$ mkdir /mnt/cdrom
[root@orcl ~]$ mount /dev/cdrom /mnt/cdrom
[root@orcl ~]$ cd /mnt/cdrom/Packages
[root@orcl Packages]# rpm -Uvh tcl-8.5.7-6.el6.x86_64.rpm
[root@orcl Packages]# rpm -Uvh expect-5.44.1.15-2.el6.x86_64.rpm

Switch to VMBackup user:

[root@orcl ~]$ su - VMBackup

and create VMBackup.sh script

[VMBackup@orcl ~]$ nano /home/VMBackup/VMBackup.sh

NOTE: This code is inspired by "Automate SCP command using Shell Script" so credits for part of this script goes to Santhosh Kumar T.

Copy/Paste this code.

I know it's far from an elegant (and clean) code but it does the job so...

#!/bin/bash

##EDIT THIS VALUE
#Insert IP Address of your VM Server
YOUR_SERVER_IP_ADDRESS=10.0.0.12

##EDIT THIS VALUE
#Insert root password of your VM Server
YOUR_SERVER_PASSWORD=password

if [ $# -eq 0 ] ; then
    echo 'Usage: VMBackup [backup | restore] [Repository ID] [VM VirtualDisk ID]'
    exit 0
fi

case "$1" in
        backup)
           
            cat > /home/VMBackup/backup.sh <<EOF
#!/usr/bin/expect -f

spawn scp "root@$YOUR_SERVER_IP_ADDRESS:/OVS/Repositories/$2/VirtualDisks/$3.img" /home/VMBackup/$3.img

expect {
-re ".*es.*o.*" {
exp_send "yes\r"
exp_continue
}
-re ".*sword.*" {
exp_send "$YOUR_SERVER_PASSWORD\r"
}
}
interact
EOF

        chmod a+x backup.sh
       
        /home/VMBackup/backup.sh
        rm /home/VMBackup/backup.sh
       
        ;;

        restore)

            cat > /home/VMBackup/restore.sh <<EOF
#!/usr/bin/expect -f

spawn scp /home/VMBackup/$3.img "root@$YOUR_SERVER_IP_ADDRESS:/OVS/Repositories/$2/VirtualDisks/$3.img"

expect {
-re ".*es.*o.*" {
exp_send "yes\r"
exp_continue
}
-re ".*sword.*" {
exp_send "$YOUR_SERVER_PASSWORD\r"
}
}
interact
EOF

        chmod a+x restore.sh
       
        /home/VMBackup/restore.sh
        rm /home/VMBackup/restore.sh
       
        ;;

        *) echo 'Usage: VMBackup [backup | restore] [Repository ID] [VM VirtualDisk ID]' ;;
esac

Then...

[VMBackup@orcl ~]$ chmod a+x /home/VMBackup/VMBackup.sh

and this is the command you use to perform a backup:

[VMBackup@orcl ~]$ /home/VMBackup/VMBackup.sh backup REPOSITORY_ID VIRTUAL_DISK_ID

or a restore:

[VMBackup@orcl ~]$ /home/VMBackup/VMBackup.sh restore REPOSITORY_ID VIRTUAL_DISK_ID

For example if your VirtualDisk location is:

/OVS/Repositories/0004fb0000030000ad1f4d7286b3abcd/VirtualDisks/0004fb00001200005ab2a78b4b71abcd.img

REPOSITORY_ID=0004fb0000030000ad1f4d7286b3abcd

VIRTUAL_DISK_ID=0004fb00001200005ab2a78b4b71abcd


the command to backup VirtualDisk 0004fb00001200005ab2a78b4b71abcd is

[VMBackup@orcl ~]$ /home/VMBackup/VMBackup.sh backup 0004fb0000030000ad1f4d7286b3abcd 0004fb00001200005ab2a78b4b71abcd


Reasonably you'll need to add this script to crontab so it will perform automated backups at certain time.

That's all!!

mercoledì 27 giugno 2012

Automating Business Intelligence Startup and Shutdown on Linux

It's pretty common to install Oracle Middleware on an "unmanned" server, which means that there's no dedicated server admin or in general a person who could  manually start the services in event of server failure. So I usually create boot scripts that prevent services downtime in case of server restart or server crash.

This script is intended for automate starting of Oracle Business Intelligence on a Linux Server. I run this script on Oracle Linux 6 but this should work on other distributions too.

[root@orcl ~]# nano /etc/init.d/bi


#! /bin/bash
#
# OBIEE Start/Stop Script
#
# chkconfig: 345 20 80
# description: Starts and stops the Oracle BI and listeners
#
# Set BI_HOME to be equal to the $ORACLE_HOME
#
# Set ORA_OWNER to the user id of the owner of the OBIEE.

BI_HOME=/home/oracle/obiee
ORA_OWNER=oracle

export ORACLE_INSTANCE=$BI_HOME/instances/instance1

start()
    {
        echo "Starting BI service "
        su $ORA_OWNER -c "$BI_HOME/Oracle_BI1/opmn/bin/opmnctl startall"
        su $ORA_OWNER $BI_HOME/user_projects/domains/bifoundation_domain/startWebLogic.sh > /dev/null 2>&1 &
    }

stop()
    {
        echo "Stopping BI service "

        su $ORA_OWNER -c "$BI_HOME/Oracle_BI1/opmn/bin/opmnctl stopall"
        su $ORA_OWNER $BI_HOME/user_projects/domains/bifoundation_domain/bin/stopWebLogic.sh > /dev/null 2>&1 &
    }

# See how we were called.
case "$1" in
    start)
        start
    ;;
    stop)
        stop
    ;;
    status)
        status -p $pidfile $processname
        RETVAL=$?
    ;;
    restart)
        stop
        start
    ;;
    condrestart)
        if [ -f /var/lock/subsys/$servicename ]; then
            stop
            start
        fi
    ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart}"
    ;;
esac

exit $RETVAL

Chmod this script and make it executable on boot

[root@orcl ~]# chmod 750 /etc/init.d/bi

[root@orcl ~]# chkconfig --add bi

We need to allow Weblogic autostart forcing username and password, I know it's a security risk display username and password in plaintext, since by default Oracle stores passowrd information in boot.properties by encryprint using AES.

[root@orcl ~]# nano /home/oracle/obiee/user_projects/domains/bifoundation_domain/servers/AdminServer/security/boot.properties

password=YOUR_WEBLOGIC_PASSWORD_HERE
username=YOUR_WEBLOGIC_USERNAME_HERE

[root@orcl ~]# chown oracle /home/oracle/obiee/user_projects/domains/bifoundation_domain/servers/AdminServer/security/boot.properties

Now everything should work as expected!!

Try if everything works fine:

[root@orcl ~]# /etc/init.d/bi start

If you would like to have Weblogic output you can modify script, though I suggest to leave output redirection enabled, maybe change it from /dev/null to an appropriate log file.

su $ORA_OWNER $BI_HOME/user_projects/domains/bifoundation_domain/startWebLogic.sh &

On start Weblogic returned this error:

PKI-02002: Unable to open the wallet. Check password.

which was solved chmodding /tmp directory

chmod -R 777 /tmp

That's all!!

lunedì 25 giugno 2012

Oracle VM: Import VMs from Citrix


Today I was at a client's office and I was asked to convert some Guest VMs from Citrix to Oracle VM Infrastructure.

When importing in Oracle VM Manager the OVF (.ovf and .vhd) file exported using XenCenter it returned this error:

Assembly import error: encoding specified in XML declaration is incorrect

I manually imported VHD files to Oracle VM Manager then created a new VM using VHD as virtual disk but with no success. The guest VM was stucked at boot.

The same procedure above successfully completed using Oracle VM VirtualBox installed on my laptop...so here's the procedure I used to import VMs from Citrix to Oracle VM.

Basically this is a four step procedure:

1)Export OVF and VHD from Citrix XenCenter

2)Create a new VM in Oracle VM VirtualBox using as virtual disk the VHD disk exported above.

3)Export OVA from Oracle VM VirtualBox

4)Import OVA as an Assembly in Oracle VM Manager


Detailed procedure:

Export Citrix .ovf  and .vhd from  XenCenter



Open Oracle VM Virtualbox and deploy a new guest VM. As virtual hard disk select previously exported .vhd file(s).

Play virtual machine in Oracle VM Virtualbox and verify that it's booting correctly

Select File -> Export Appliance


Select vm to export NOT CHECK "Write old ovf 0.9" NOT CHECK "Write Manifest"


Export file.

The export result is an .ova file which contains the Citrix VM furtherly converted by Oracle VM VirtualBox.

Log-on to Oracle VM Manager then import new Assembly and select .ova file

When Assembly is imported click "Create VM Template".

Once Template is created guest VM can be deployed. Select "New VM" -> "Create from Template"

That's all!!

venerdì 22 giugno 2012

Your browser is not supported by Oracle BI Presentation Services

I encountered this problem while accessing OBIEE analysis using FireFox 12.

Browsing internet provided two solutions:


1) Apply official patch

Since this is a recognized problem the best way to solve this problem is to apply official patch (available for Linux).

Log on to:


https://support.oracle.com/


Download patch


p12877995_111150_LINUX.zip


Transfer it to the OBIEE server then unzip it

Apply patch using OPatch:

[oracle@orcl ~]# /home/oracle/obiee/oracle_common/Opatch/opatch apply  /home/oracle/13564003/

where

/home/oracle/obiee/oracle_common/Opatch/opatch is the path to the folder of OPatch application

/home/oracle/13564003/ is the path to the folder created when downloaded patch was previously unzipped.


After patch installation restart OBIEE server.


2) Fake User HTTP Agent

Although the solution above is preferrable if it's not possible install the previous patch there's another way to solve this problem.

BI Presentation Services seems not to support

User-Agent = Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) Gecko/20100101 Firefox/10.0

so changing it to a lower version using some Firefox addons like "User Agent Switcher" did the trick.


Update 12/07/2012:
Open Firefox, type:

about:config

Click right mouse button on the page and select "New->String".
Name it:

general.useragent.override


And use this value:

Mozilla/5.0 (Windows; Windows NT 6.1; rv:10.0) Gecko/20100101 Firefox/9.0


Refresh OBIEE webpage and everything should work!!

giovedì 21 giugno 2012

NETCA Fails During Database Installation

Some months ago I encountered this problem:

during installation of a test Oracle Database 11.2.0.1.0 Net Configuration Assistant failed.









This appened on a 32bit Oracle Linux 5 U4 test VM running on my 64bit AMD desktop PC's VMWare Player.

As stated in Oracle Support it's a known issue on 64bit hardware. (X86 DBCA, NETCA GIVE JAVA HOTSPOT ERROR IF ON X86_64 HARDWARE [ID 942076.1])


The following procedure is the one I followed to solve this problem:

Download and extract patch 8670579 from Oracle Support


So I got p8670579_112010_LINUX.zip then

[oracle@orcl ]$ unzip /home/oracle/p8670579_112010_LINUX.zip

To apply this path we need to use OPatch that is installed as additional software during most Oracle products installation...in this case Database installation. This implied that I couldn't patch the system before installing database so the trick is to install Database until NETCA fails then apply patch.

When Net Configuration Assistant fails run OPatch:


[oracle@orcl ]$ /u01/app/oracle/product/11.2.0/db_1/bin/OPatch/opatch apply /home/oracle/8670579





where as usual /home/oracle/8670579 is the path where I unzipped patch.

When patch is applied I clicked RETRY button and this time Net Configuration Assistant completed successfully!!



mercoledì 20 giugno 2012

Modify System Global Area (SGA) size

Here's a quick post about modifying Oracle Database System Global Area.

SGA is basically a certain amount of memory dedicated to an Oracle instance.

You can set the SGA size during the creation of the instance. If you need to increase it after the instance has been created you have to use some brief SQL commands



Connect to the instance using SQLPlus then run the following commands:

SQL>alter system set sga_max_size=YOUR_NEW_VALUE sid='*' scope=spfile;

SQL>alter system set sga_target=YOUR_NEW_VALUE sid='*' scope=spfile;

SQL>shutdown immediate;

SQL>startup;

Where YOUR_NEW_VALUE is obviously the new amount of memory dedicated to SGA.

martedì 19 giugno 2012

X Window Server using Xming and Putty

In this post I describe how to connect to an X server using Windows.
X Window is usually used during installation of Oracle products in a non windowed server environment.

We'll use Xming and Putty so if you haven't them already download them from here:



http://sourceforge.net/projects/xming/

http://www.chiark.greenend.org.uk/~sgtatham/putty/



After installation run XLaunch and select:

-Multiple Windows


-Start no client


-UNCHECK "Clipboard" and CHECK "No Access Control"


Launch Putty and go to  SSH -> X11 tab as illustrated below



Then connect to the server where you need X Window and run following commands:


[oracle@orcl ]$ set DISPLAY=10.0.0.122;export DISPLAY

where 10.0.0.122 needs to be replaced by your ip address!!

[oracle@orcl ~]$ xhost +

If everything went fine the previous command should return:


access control disabled, clients can connect from any host


The preparation is done now you can run any program using X Window.

For example this is the output provided on my desktop screen when I ran "runInstaller" from Oracle Database


xhost: command not found

Basic Oracle Linux 6 installation doesen't include some packages, one of these is Xorg-X11-Server that is used for X Terminal emulation

To install Xorg-X11-Server you need to mount Oracle Linux 6 installation DVD:

[root@orcl ~]# mkdir /mnt/cdrom

[root@orcl ~]# mount /dev/cdrom /mnt/cdrom/
mount: block device /dev/sr0 is write-protected, mounting read-only

[root@orcl ~]# cd /mnt/cdrom/Packages/

Then install the package.

[root@orcl Packages]# rpm -Uvh xorg-x11-server-utils-7.5-5.2.el6.x86_64.rpm
error: Failed dependencies:
        mcpp is needed by xorg-x11-server-utils-7.5-5.2.el6.x86_64

But as stated above there are some unmet dependencies that we need to fix:

[root@orcl Packages]# rpm -Uvh libmcpp-2.7.2-4.1.el6.x86_64.rpm
[root@orcl Packages]# rpm -Uvh mcpp-2.7.2-4.1.el6.x86_64.rpm

So we can successfully install Xorg-X11-Server

[root@orcl Packages]# rpm -Uvh xorg-x11-server-utils-7.5-5.2.el6.x86_64.rpm

Now xhost command works fine!!

lunedì 18 giugno 2012

Oracle Linux installation & configuration guide

This post covers the topic of Oracle Linux installation.
Oracle Linux is a versatile operating system that offers a solid base for (almost)all Oracle products.

The version used in this post is Oracle Linux Release 6 Update 2 for x86_64 (64 Bit) that can be downloaded from:

https://edelivery.oracle.com/linux

Installation is pretty simple and not different than any other Linux.

These screens describe the process.











When installation is complete it's time to configure the system to work properly.

At first we need to enable network editing ifcfg-ethX file using a text editor.
The "X" above meas that every network card needs to be manually configured, in this case I'm going to configure my only NIC that is eth0.

I log in as root user:

[root@orcl ~]# nano /etc/sysconfig/network-scripts/ifcfg-eth0

And edit the file as follows:

IPADDR=10.0.0.4
NETMASK=255.255.255.0
GATEWAY=10.0.0.250
DEVICE="eth0"
HWADDR="00:50:56:BF:00:25"
ONBOOT="yes"
TYPE=Ethernet
BOOTPROTO=static

Then you need to restart the network service to make this configuration running:

[root@orcl ~]# service network restart

Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]

When network is up and running I connect to my server via SSH using Putty from my PC

Next step is to add DNS nameserver:

[root@orcl ~]# nano /etc/resolv.conf

nameserver 10.0.0.88
nameserver 10.0.0.9

Then it's time to edit hosts file according to our server hostname

[root@orcl ~]# hostname
orcl
[root@orcl ~]# nano /etc/hosts
127.0.0.1 localhost
10.0.0.4 orcl

Now we need to enable YUM repository

[root@orcl ~]# cd /etc/yum.repos.d/
[root@orcl yum.repos.d]# wget http://public-yum.oracle.com/public-yum-ol6.repo

The step above enable access to YUM Repos giving us the ability to install software using the syntax:

yum install PACKET_NAME

Disable iptables:

[root@orcl ~]# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]

and remove the service so next reboot we don't have to stop iptables again

[root@orcl ~]# chkconfig iptables off

An optional step is to configure Network Time Protocol so your server can adjust time and date automatically.

[root@orcl ~]# nano /etc/ntp.conf

In this file look for this lines:

server 0.rhel.pool.ntp.org
server 1.rhel.pool.ntp.org
server 2.rhel.pool.ntp.org


and edit address making them point to correct NTP servers.
When done start ntpd service:

[root@orcl ~]# service ntpd start

And finally make it executable at boot:

[root@orcl ~]# chkconfig ntp on

Last step is to disable SELINUX

[root@orcl ~]# nano /etc/selinux/config

Change

SELINUX=enforcing

to

SELINUX=disabled

Reboot...then your installation and configuration is complete!!!