Showing posts with label Project. Show all posts
Showing posts with label Project. Show all posts

Wednesday, February 27, 2013

Cloning Oracle database Home from one server to another


How To Clone A  ORACLE Database Home From One Server To Other

Step1 : 
[oracle@lnx1 dbhome_1]$ opatch lsinv
Invoking OPatch 11.2.0.1.3
Oracle Interim Patch Installer version 11.2.0.1.3
Copyright (c) 2010, Oracle Corporation. All rights reserved.
Oracle Home : /oracle/app/product/11.2.0/dbhome_1
Central Inventory : /home/oracle/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.3
OUI version : 11.2.0.1.0
OUI location : /oracle/app/product/11.2.0/dbhome_1/oui
Log file location : /oracle/app/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2010-11-05_08-52-30AM.log
Patch history file: /oracle/app/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch_history.txt
Lsinventory Output file location : /oracle/app/product/11.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2010-
11-05_08-52-30AM.txt
--------------------------------------------------------------------------------
Installed Top-level Products (1):
Oracle Database 11g 11.2.0.1.0
There are 1 products installed in this Oracle Home.
Interim patches1) :
Patch 9952216 : applied on Fri Nov 05 07:13:34 PDT 2010
Unique Patch ID: 12825033
Created on 13 Sep 2010, 04:55:09 hrs PST8PDT
Bugs fixed:
9068088, 9363384, 8865718, 8898852, 8801119, 9054253, 8725286, 8974548
9093300, 8909984, 8755082, 8780372, 9952216, 8664189, 8769569, 7519406
9471411, 9302343, 8822531, 7705591, 8650719, 9637033, 8883722, 8639114
8723477, 8729793, 8919682, 8856478, 9001453, 8733749, 8565708, 8735201
8684517, 8870559, 8773383, 8981059, 8812705, 9488887, 8813366, 9242411
8822832, 8897784, 8760714, 8775569, 8671349, 8898589, 9714832, 8642202
9011088, 9369797, 9170608, 9165206, 8834636, 8891037, 8431487, 8570322
8685253, 8872096, 8718952, 8799099, 9032717, 9399090, 9713537, 9546223
8588519, 8783738, 8834425, 9454385, 8856497, 8890026, 8721315, 8818175
8674263, 9145541, 8720447, 9272086, 9467635, 9010222, 9102860, 9197917
8991997, 8661168, 8803762, 8769239, 9654983, 8546356, 8706590, 8778277
9058865, 8815639, 9971778, 9971779, 9027691, 9454036, 9454037, 9454038
9255542, 8761974, 9275072, 8496830, 8702892, 8818983, 8475069, 8875671
9328668, 8891929, 8798317, 8782959, 9971780, 8774868, 8820324, 8544696
8702535, 9406607, 9952260, 8268775, 9036013, 9363145, 8933870, 8405205
9467727, 8822365, 9676419, 8761260, 8790767, 8795418, 8913269, 8717461
8861700, 9531984, 8607693, 8330783, 8780281, 8784929, 8780711, 9341448
9015983, 8828328, 9119194, 8832205, 8665189, 8717031, 9482399, 9676420
9399991, 8821286, 8633358, 9321701, 9231605, 9655013, 8796511, 9167285
8782971, 8756598, 9390484, 8703064, 9066116, 9007102, 9461782, 9382101

8505803, 9352237, 8753903, 9216806, 8918433, 9057443, 8790561, 8795792
8733225, 9067282, 8928276, 8837736, 9210925
--------------------------------------------------------------------------------
OPatch succeeded.

Step 2:   Check the oracle home size

[oracle@lnx1 ~]$ cd /oracle/app/product/11.2.0/dbhome_1
[oracle@lnx1 dbhome_1]$
[oracle@lnx1 dbhome_1]$ du -chs

4.5G


step 3: Create the directory tree on the remote server and change ownership to oracle
[oracle@lnx2 ~]$ su -
Password:
[root@lnx2 ~]# mkdir -p /oracle/app/product/11.2.0/
[root@lnx2 ~]# chown -R oracle:oinstall  /oracle

step4: On source execute tar command to copy over the network the oracle_home directories to the target server
[oracle@lnx1 ~]$ cd /oracle/app/product/11.2.0
[oracle@lnx1 11.2.0]$ tar -cvf dbhome_1.tar dbhome_1
[oracle@lnx1 11.2.0]$ scp dbhome_1.tar oracle@linux2: /oracle/app/product/11.2.0/

go to new machine
[oracle@lnx2 11.2.0]$ tar -xvf dbhome_1.tar

 [oracle@lnx2 dbhome_1]$ du -chs


4.5G

step5: First I need to detach the inventory because the server was itself a clone of the source

[oracle@lnx2 ~]$ cd /oracle/app/product/11.2.0/dbhome_1/oui/bin
[oracle@lnx2 bin]$ ./runInstaller -detachHome
ORACLE_HOME="/oracle/app/product/11.2.0/dbhome_1"
Starting Oracle Universal Installer...

Checking swap space: must be greater than 500 MB. Actual 1992 MB Passed
The inventory pointer is located at /etc/oraInst.loc
The inventory is located at /home/oracle/oraInventory
'DetachHome' was successful.

step 6: Run the cloning procedure:
[oracle@lnx2 bin]$ ./runInstaller -clone -silent -ignorePreReq ORACLE_HOME="/oracle/app/product/11.2.0/dbhome_1" ORACLE_HOME_NAME="dbhome_11gR2"

ORACLE_BASE="/oracle/app" OSDBA_GROUP=dba OSOPER_GROUP=dba

Starting Oracle Universal Installer...
Checking swap space: must be greater than 500 MB. Actual 1992 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2010-11-05_11-28-15AM. Please
wait ...[oracle@lnx2 bin]$ Oracle Universal Installer, Version 11.2.0.1.0 Production
Copyright (C) 1999, 2009, Oracle. All rights reserved.
You can find the log of this install session at:
/home/oracle/oraInventory/logs/cloneActions2010-11-05_11-28-15AM.log
.................................................................................................... 100% Done.
Installation in progress (Friday, November 5, 2010 11:28:48 AM PDT)
.............................................................................. 78% Done.
Install successful
Linking in progress (Friday, November 5, 2010 11:29:21 AM PDT)
Link successful
Setup in progress (Friday, November 5, 2010 11:31:59 AM PDT)
Setup successful
End of install phases.(Friday, November 5, 2010 11:35:50 AM PDT)
Starting to execute configuration assistants
Configuration assistant "Oracle Configuration Manager Clone" succeeded
WARNING:
The following configuration scripts need to be executed as the "root" user.
/oracle/app/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 dbhome_11gR2 was successful.
Please check '/home/oracle/oraInventory/logs/cloneActions2010-11-05_11-28-15AM.log' for more details.


Step 7: The last step is to execute as root the root.sh script:
[root@lnx2 ~]# /oracle/app/product/11.2.0/dbhome_1/root.sh
Check /oracle/app/product/11.2.0/dbhome_1/install/root_lnx2_2010-11-05_11-39-06.log for the output of
root script

Post Check:

[oracle@lnx2 ~]$ opatch lsinv
Invoking OPatch 11.2.0.1.3
Oracle Interim Patch Installer version 11.2.0.1.3
Copyright (c) 2010, Oracle Corporation. All rights reserved.
Oracle Home : /oracle/app/product/11.2.0/dbhome_1
Central Inventory : /home/oracle/oraInventory
from : /etc/oraInst.loc
OPatch version : 11.2.0.1.3
OUI version : 11.2.0.1.0
OUI location : /oracle/app/product/11.2.0/dbhome_1/oui
Log file location : /oracle/app/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch2010-11-05_11-46-19AM.log
Patch history file: /oracle/app/product/11.2.0/dbhome_1/cfgtoollogs/opatch/opatch_history.txt
Lsinventory Output file location : /oracle/app/product/11.2.0/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2010-
11-05_11-46-19AM.txt
--------------------------------------------------------------------------------
Installed Top-level Products (1):
Oracle Database 11g 11.2.0.1.0
There are 1 products installed in this Oracle Home.

........................
OPatch succeeded.




Thursday, October 18, 2012

HOW TO APPLY ORACLE PATCH

================================================================================
HOW TO APPLY PATCH on a DATABASE
================================================================================
1) Make a note of the output of below command:
   ps -ef|grep pmon
   ps -ef|grep tns
2) Login to database and take the snaps of all the invalid objects as mention below:
   spool invalid_Object_pre.log
   set linesize 256
   set pagesize 256
   col object_name for a30
   select name from v$database;
   select owner, object_name, object_type from dba_objects where status <>'VALID' order by owner, object_name;
   spool off
3) Set OEM Agent blackouts on the server as follows :
 a) cd /prod01/app/oracle/product/AGENT/agent10g/bin
 b) ./emctl start blackout servername_date_time_maint-nodelevel
4) Stop OEM Agent on the database server as follows:
        a) cd /prod01/app/oracle/product/AGENT/agent10g/bin/
        b) ./emctl stop agent

5)  Shutdown all the databases under this ORACLE_HOME with below command;
  
   SHUTDOWN IMMEDIATE

6) stop all the LISTENER  under this ORACLE_HOME
7) Cross-Check the database and Listener are down with below command:
   ps -ef|grep pmon
   ps -ef|grep tns
8)Take the Backup of global inventory (oraInventory) and local inventory as menetion below:
To find global inventory
cat /etc/oraInst.loc
or
cat /var/opt/oracle/oraInst.loc
go to that path and cd ..
Ex:
tar -cvf oraInventory_today'sdate oraInventory
Each ORACLE_HOME has its own inventory, its called local inventory
Ex:
cd /opt/oracle/product/10.2.0.4
tar -cvf inventory_today'sdate inventory
9)Go to below Location:
        uname -a (Find the server details)
Download the patch from Oracle site  to ORACLE_HOME

To know the bit (whether 64 or 32) use the following command
$ getconf KERNEL_BITS  or getconf -a | grep KERNEL
 
unzip p9352224_92080_AIX64-5L.zip
10)Apply the Patch as mention below:
fuser -cu $ORACLE_HOME
 (A)  export PATH=$PATH:$ORACLE_HOME/OPatch
          export TMP=$ORACLE_HOME/tmp   
          export TMPDIR=$TMP
     export JDK_HOME=$ORACLE_HOME/jdk -- for upto 9i
     export PATH=$PATH:$JDK_HOME/bin:. -- -- for upto 9i
 (B) Check the which opatch version and opatch is pointing to, as mention below:
     opatch version (It should 1.0.0.0.57 or higher)
     which opatch   (It Should be /prod01/app/oracle/product/9.2/OPatch/opatch)
 (C) Apply the patch with below command:
     opatch apply  or opatch napply -skip_subset -skip_duplicate
11) Crosscheck the Patch is applied or not with below command:
    opatch lsinventory
12) startup the Database
    STARTUP
 cd $ORACLE_HOME/rdbms/admin
 sqlplus /nolog
 CONNECT / AS SYSDBA
 STARTUP
 @catbundle.sql psu apply
shutdown immediate
startup
++++  REPEAT the same steps for all databases. ++++++
IMP : Check the status of compoents after patching :
select COMP_NAME,STATUS from dba_registry;

13) Crosscheck the Patch is register in the database with below command:
    SELECT * from REGISTRY$HISTORY;
14) Cross check the invalid objects as mention below:
   spool invalid_Object_Post.log
   set linesize 256
   set pagesize 256
   col object_name for a30
   select name from v$database;
   select owner, object_name, object_type from dba_objects where status <>'VALID' order by owner, object_name;
   spool off
15) If the Output of invalid_Object_Post.log >(greater) than the output of invalid_Object_Pre.log then execute the below cmd:
    @$ORACLE_HOME/rdbms/admin/utlrp.sql;
    select owner, object_name,object_type from dba_objects where status <>'VALID' order by owner, object_name;
16) start the all listeners
17) Start OEM Agent on the database server as follows:
        a) cd /prod01/app/oracle/product/AGENT/agent10g/bin/
   b) ./emctl start agent
18) Remove OEM Agent blackouts on the server as follows:
 a) cd /prod01/app/oracle/product/AGENT/agent10g/bin/
 b) ./emctl stop blackout servername_date_time_maint-nodelevel.
19) Logout from the Server.

How to drop a Database

Hi ,
Please find the below steps.


HOW TO DROP DATABASE
===============================================
STEP1:  Shutdown the database immediately
SHUT IMMEDIATE
STEP2:  mount database
STARTUP MOUNT
STEP3:  Restrict the session
ALTER SYSTEM ENABLE RESTRICTED SESSION
STEP4:  Drop the database
DROP DATABASE;



======================================================
How TO DEINSTALL THE ORACLE SOFTWARE
======================================================
STEP1:  Goto ORACLE HOME directory
cd $ORACLE_HOME
Step 2: check the deinstall folder is there or not
cd deinstall
Step 3: Run the command
$./deinstall