Tuesday, August 30, 2011

Cloning of ORACLE_HOME in Oracle 11g

Cloning of ORACLE_HOME in Oracle 11g:

We have to clone ORACLE_HOME for few of the reasons like
1)Whenever a mount point disk space is insufficient.
2)Copy the software from one machine to other withour intstalling.

When we are doing Cloning of the ORACLE_HOME(i.e software) in Oracle11g we need to specify ORACLE_BASE by executing clone.pl perl script below is the experiment to do this ORACLE_HOME cloning for Oracle 10g ORACLE_HOME the steps remain the same only difference is ORACLE_BASE environment variable is not required.We have to request for the downtime of 30 minutes for performing this task because after cloning ORACLE_HOME

we need to verify and change the below things:

1).bash_profile(.profile on solaris,hp/ux,aix) file on linux.

2)/etc/oratab file(/var/opt/oracle/oratab on solaris) on linux.

3)listener.ora file in $TNS_ADMIN($ORACLE_HOME/network/admin) path.

4)expdp(export job script) and RMAN scripts or other scripts using ORACLE_HOME and ORACLE_BASE


Step 1:Collect the environment variable of your current ORACLE_HOME from the .bash_profile (.profile in any other unix environment):

Below are the current settings:

# .bash_profile

export ORACLE_BASE=/u01/oracle11g

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1

export PATH=$ORACLE_HOME/bin:$PATH


Step 2:Set the Display environmet variable:

DISPLAY=":0.0" export DISPLAY
(or)
xclock -display machine_name:0.0


Step 3:Now,zipped and extract using tar in a mount point where you have sufficient diskspace:


$ export OLD_ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
$ cd $OLD_ORACLE_HOME/..
$ tar -cvf /u05/TAR_ORACLE_HOME1/OH.tar /u01/oracle11g/product/11.2.0/dbhome_1

Note:
tar -cvf destination_location source_location
Where:Destination_location=u05/TAR_ORACLE_HOME1/OH.tar
Source_location=/u01/oracle11g/product/11.2.0/dbhome_1

Step 4:Destination ORACLE_HOME Creation:

[oracle@testnode1 u03]$ cd /u05
[oracle@testnode1 u05]$ mkdir app
[oracle@testnode1 u05]$ cd app/
[oracle@testnode1 app]$ ls
[oracle@testnode1 app]$ mkdir db11g2
[oracle@testnode1 app]$ cd db11g2/
[oracle@testnode1 db11g2]$ mkdir product
[oracle@testnode1 db11g2]$ cd product/
[oracle@testnode1 product]$ pwd
/u05/app/db11g2/product
[oracle@testnode1 product]$ mkdir 11.2
[oracle@testnode1 product]$ cd 11.2/
[oracle@testnode1 11.2]$ pwd
/u05/app/db11g2/product/11.2


export ORACLE_BASE=/u05/app/db11g2
export ORACLE_HOME=/u05/app/db11g2/product/11.2

[oracle@testnode1 11.2]$ pwd
/u05/app/db11g2/product/11.2
$cd /u05/app/db11g2/product/11.2
$ tar -xvf /u05/TAR_ORACLE_HOME1/OH.tar

=>This will create the ORACLE_HOME as present is /u01 mount point in /u05 mount point
Next,

$export PATH=$ORACLE_HOME/bin:$PATH
$export ORACLE_HOME=/u05/app/db11g2/product/11.2/u01/oracle11g/product/11.2.0/dbhome_1
$echo $ORACLE_HOME
/u05/app/db11g2/product/11.2/u01/oracle11g/product/11.2.0/dbhome_1
$cd /u05/app/db11g2/product/11.2/u01/oracle11g/product/11.2.0/dbhome_1
$perl $ORACLE_HOME/clone/bin/clone.pl ORACLE_HOME=/u05/app/db11g2/product/11.2/u01/oracle11g/product/11.2.0/dbhome_1 ORACLE_BASE=/u05/app/db11g2/product/11.2/u01/oracle11g ORACLE_HOME_NAME=OraDb11g_home2

Result:
--------------------------------------

WARNING:
The following configuration scripts need to be executed as the "root" user.
/u05/app/db11g2/product/11.2/u01/oracle11g/product/11.2.0/dbhome_1/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts

The cloning of OraDb11g_home_2 was successful.
Please check '/u01/oraInventory/logs/cloneActions2011-08-29_04-23-59PM.log' for more details.
[oracle@testnode1 dbhome_1]$
[oracle@testnode1 dbhome_1]$
[oracle@testnode1 dbhome_1]$


Step 5:Execute root.sh script:
Log in as "root"
[oracle@testnode1 dbhome_1]$ su
Password:
[root@testnode1 dbhome_1]# cd /u05/app/db11g2/product/11.2/u01/oracle11g/product/11.2.0/dbhome_1
[root@testnode1 dbhome_1]#pwd
/u05/app/db11g2/product/11.2/u01/oracle11g/product/11.2.0/dbhome_1
[root@testnode1 dbhome_1]# sh root.sh
Check /u05/app/db11g2/product/11.2/u01/oracle11g/product/11.2.0/dbhome_1/install/root_testnode1.in.bosch.com_2011-08-29_16-32-46.log
for the output of root script

Step 6:Copy the spfiles and password files:

Copy the spfiles and password files of Databases from previous $ORACLE_HOME/dbs( $ORACLE_HOME/database in windows)
to new $ORACLE_HOME/dbs path

Step 7:Post ORACLE_HOME clonning steps are as given below:


1)Modify .bash_profile file:

If we have created separate profile for each databases environment than we have update there and
check we are able to login the Database successfully

vi .bash_profile

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
export ORACLE_BASE=/u05/app/db11g2/product/11.2/u01/oracle11g
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export sq='sqlplus "/as sysdba"'
export ORACLE_SID=TESTDB1

:wq =>save and quit.

2)Modify /etc/oratab file.

Modify the /etc/oratab entry in linux with the neW ORACLE_HOME path

# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
#TESTDB2:/u01/oracle11g/product/11.2.0/dbhome_1:Y
#TESTDB1:/u01/oracle11g/product/11.2.0/dbhome_1:Y

#New ORACLE_HOME
TESTDB2:/u05/app/db11g2/product/11.2/u01/oracle11g/product/11.2.0/dbhome_1:Y
TESTDB1:/u05/app/db11g2/product/11.2/u01/oracle11g/product/11.2.0/dbhome_1:Y

3)Modify listener.ora file

If we are not able to connect from other machine or client machine after ORACLE_HOME cloning don't get shocked as we have to update listener.ora with the new ORACLE_HOME path.Before modifying listener.ora file create a backup file
if it does not exists.Now you cand set the new ORACLE_HOME path here as given below.

[oracle@testnode1 oracle11g]$ cd $TNS_ADMIN
[oracle@testnode1 admin]$ pwd
/u05/app/db11g2/product/11.2/u01/oracle11g/product/11.2.0/dbhome_1/network/admin
[oracle@testnode1 admin]$ ls -altr
-rw-r--r-- 1 oracle dba 431 May 13 15:36 sqlnet.ora
-rw-r--r-- 1 oracle dba 959 Aug 29 17:15 tnsnames.ora
-rw-r--r-- 1 oracle dba 405 Aug 29 19:32 listener.ora_bkp29082011
-rw-r--r-- 1 oracle dba 461 Aug 29 19:34 listener.ora
drwxr-xr-x 3 oracle dba 4096 Aug 30 11:04 .
[oracle@testnode1 admin]$ vi listener.ora

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =testnode1)(PORT = 1521))
)
)

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = TESTDB1)
(ORACLE_HOME = /u05/app/db11g2/product/11.2/u01/oracle11g/product/11.2.0/dbhome_1)
)
(SID_DESC =
(SID_NAME = TESTDB2)
(ORACLE_HOME = /u05/app/db11g2/product/11.2/u01/oracle11g/product/11.2.0/dbhome_1)
)
)

:wq =>save and quit.

4)Modify expdp(export job script) and RMAN scripts or other scripts using ORACLE_HOME and ORACLE_BASE for their executions.
If we don't modify the Backup scripts or other scripts using ORACLE_HOME and ORACLE_BASE than next morning we might see backups or jobs getting failed so please make sure you modify the ORACLE_HOME and ORACLE_BASE.

Now,we can test ourself in our local system whether we are able to connect to the Databases with the new ORACLE_HOME and than request the end users to use the system.Thus our task can be successfully completed.


Hope it helps.

Enjoy DBA tasks.

Best regards,

Rafi.


















No comments:

Post a Comment