Monday, 13 June 2016

Cloning the RAC database to Non-RAC databse

To replicate your production envirionment to that patch testing can be done in the cloned environment.

soruce                                                   traget 
-------------------------------------------------------------------------
rac                                                         non-rac
oracle:oinstall                                     oracle:dba
11.2.0.2.0                                            11.2.0.2.0
/u01/app/orcle/product/11.2.0       /u02/app/oracle/11.2.0
alpha, beta                                          gama
ASM                                                     non-ASM

steps:
1. Ensure that the target server(gama) meets oracle software requirements.
 a. os must be certified
 b. kernel parameters must be set
 c. mandatory os packages should be installed
 d. os limits should be set
2. create the group/user (dba/oracle)
3. copy the software(oralce_home) from the source(either from alpha or beta)
to the target server(gama) and change the ownership if required( do not user cp/scp).
4. extract the software on the target host(gama) in the desired path (/tmp) and create directories
   a. mkdir -p /u02/app/oracle/11.2.0
   b. chown -R oralce:dba /u02/app/oracle/11.2.0
 c. ssh root@alpha  "(cd /u02/app/oracle/11.2.0 : tar -cf - 11.2.0|gzip)" |gunzip | tar -xf -
5. set the environment variables (ORACLE_HOME, ORACLE_BASE, ORACLE_SID, PATH, LD_LIBRARY_PATH etc) on the target host(gama)
-------------------------------
problem 1:
UID/GID of the owner is different
Try to login to sqlplus / as sysdba => if complains "Insufficient privileges"
 because groupNames between source(oinstall) and target (dba) are different.
Fix it:
a. take a backup of $ORACLE_HOME/rdbms/lib/config.o file.
this is where the groupName(oinstall) is hardcoded. its a binary file.
corrent the text version: vi $ORACLE_HOME/rdbms/lib/config.c (in linux)
generate a new config.o from modified config.c
  $ORACLE_HOME/bin
 #relink all
try to login to sqlplus / as sysdba  => it will work.
--------------------------------
problem 2:
Try to set a dummy pfile (initdevdb.ora) and startup nomount the dummay db.
it cant start even in nomount ==> ORA-29702 error occurs because cluster group service operation
why?  software is rac enabled but on the target nod (gama) there is no GI for cluster installed.
fix it:
ADD                                                         REMOVE
rac_on      RAC_APPLI_CLUSTER        rac_off
                  GCS and GES 
                (provided by libskgxp and libskgxn2)
rat_on      REAL_APPLI_TESTING       rat_off
part_on    PARTITIONING                    part_off
olap_on   OLAP                                     olap_off
dm_on     DATA_MINING                    dm_off
                 CORE RDBMS ENGINE

b. How can we enable/disable a specific feature?
 oracle has provied you a make script.
 $ORACLE_HOME/rdbms/lib/ins_rdbms.mk
c. How to disable RAC feature?
 cd $ORACLE_HOME/rdbms/lib
 make -f ins_rdbms.mk rac_off
d. what do i need to do next after adding/removing a specific feature?
 you must relink the oracle executable after enabling/disabling a specific feature.
 cd $ORACLE_HOME/rdbms/lib
 make -f ins_rdbms.mk ioracle or "relink all"
e. try to startup nomount the dummy instance and it should work.
-----------------------------------------------
problem 3:
a. Oracle Home path is different
Multiple script/files under ORACLE_HOME would point to invalid source path.
ex: dbca, dbua, netmgr
some softlinks also point to invalid source path.
b. After copying the software from SOURCE TO TARGET node.
The CENTROL INVENTARY (oraInventory) is not created/updated.
fix it:
a. Oracle provides a clining utility $ORACLE_HOME/clone/bin/clone.pl.
its a perl script
b. run the cloning s riipt to fix all the problems related to
 - groupName mismatch
 - path mispatch and invalid softlinks
 - Inventory updates
 - relinking
c. on the target host(gama) set the environment and goto $ORACLE_HOME/clone/bin
d. perl clone.pl ORACLE_BASE=/u02/app/oracle ORACLE_HOME=/u02/app/oracle/11.2.0 ORACLE_HOME_NAME=XXXX OS_DBA_GRP=oracle OS_OPER_GRP=dba
        - oraInventory/orainstRoot.sh
 - /u02/app/oracle/11.2.0/root.sh
you have to manually rectify the $oraInventory/ContentXML/inventory.xml
and remove the "NODES" section from it.
opatch -lsinventory
Loacl inventory still has a file: $ORACLE_HOME/inventory/ContentsXML/
oraclehomeproperties.xml
and remove the cluster_info secton from it.
-------------------------------------------
problem 4:
Choosing Cloneing Method
fix it:
a. Either invoke a 11g method to clone -- Active database clone
b. ensure the backup are locally (on gama) accessible in the same path from the target host(gama) and then invoke rman duplicate
-----------------------------------------------
DATABASE Backup:
On alpha take a hot backup of the database RACDB.
NOTE: it must be in ARCHIVELOG mode for this to happen.
rman target /
run {
allocate channel ch1 device type disk;
allocate channel ch2 device type disk;
backup a compressed backupset format='/tmp/clone_db_%U.rman' tag='DBF_CLONE' database;
backup a compressed backupset format='/tmp/clone_arc_%U.rman' tag=ARC_CLONE' archivelog all skip inaccessible;
release channel ch1;
release channel ch2;
}
copy the backup pieces to the same location on the target host (gama)
start the target instance (devdb) with a dummy pfile in NOMOUNT state on the target host (gama).
ensure that the pfile contains the parameter : "_no_recovery_through_resetlogs"=true
   to recovery of database using redolog files fails using one NODE.
Define a TNS Entry on the target host(gama) which points to the SOURCE INSTANCE (RACDB1) running on alpha.
test that the TNS Entry works on gama and allows you a remote SYSDBA login to RACDB1 running on alpha.
sqlplus sys/<password>@TNSEntry as sysdba
- if this fails then fix it by creating a password file on RACDB@alpha
bounce the instance if required.
- ensure that the parameter on RACDB1 "remote_login_passwordfile" is set appropriately
now start the rman sessoin from gama.
rman target sys/<password>@TNSentry auxiliary /
-------------------------------------------------------
RAC to Non-RAC clones could fail due to
RMAN-06136: oracle error from auxiliary database
ORA-38856: cannot mark instance UNNAMED_INSTANCE_2 (redo thread2) as enabled.
fix it :
add a hidden parameter "_no_recovery_through_resetlogs"=true
PROD1 : redo thread1
PROD2 : redo thered2
-------------------------------------
for PITR "set until scn '4545453';"
run{
allocate channel ch1 device type disk;
allocate auxiliary channel aux1 device type disk;
set newname datafile 1 to '/u02/app/oradata/system.dbf';
set newname datafile 2 to '/u02/app/oradata/sysaux.dbf';
set newname datafile 3 to '/u02/app/oradata/users.dbf';
set newname datafile 4 to '/u02/app/oradata/example.dbf';
set newname datafile 5 to '/u02/app/oradata/undotbs1.dbf';
set newname datafile 6 to '/u02/app/oradata/undotbs2.dbf';
set newname datafile '+DATA/racdb/tempfile/temp.263.83654525' to '/u02/app/oradata/temp01.dbf';
duplicate target database to 'devdb'
logfile
group 1 ('/u02/app/oradata/redo01.log') size 50M,
group 2 ('/u02/app/oradata/redo02.log') size 50M,
group 3 ('/u02/app/oradata/redo03.log') size 50M,
group 4 ('/u02/app/oradata/redo04.log') size 50M;
}
---------------------------------------------

Post requisites after clone
1. if required DBID is same then change it for the target database using $ORACLE_HOME/bin/nid command.
2. if ORACLE_HOME path has changed between the source and the target, the library objects would fail.
 sql>select owner, library_name, file_spec from dba_libraries where file_spce is not null;
3. if libraries are pointing to invalid files change them on the target database to appropriate paths
   create or replace library ORDSYS.ORADIMLIBS AS '/u02/app/oracle/11.2.0/lib/libordim11.so';
4. compile the invalid objects.
  sql> exec utl_recomp.recomp_parallel(2);
  sql> select count(*) from dba_objects where status='INVALID';
 this should match between source and target database.
5. correct all the DIRECTORY objects dba_directories;
 sql> select dierectory_name, directory_path from dba_directories;
 sql> create or replace directory <dirname> as <corrent_path>;
6. fix all db_links. if not taken care of it could lead to disaster.
7. drop unwanted UNDO tablespaces.
8. register the target database (devdb) with rman recovery catalog (optional)

 

No comments:

Post a Comment

Optimizer Access Paths using Indexes

Introduction In this tutorial you will use the Optimizer Access Paths for the following cases (scenarios): Case 1: With and Without Index Ca...