Monday, March 28, 2011

Duplicating Oracle 11g Database using Active database option


Source DB
===========
Host Name=oradbsrvr1
DB Name=racdb
Oracle Version=11.2.0.1.0
Oracle Home=/u01/oracle/product/11.2.0/db
dbfiles_loc=/u01/oradata/racdb

Target DB
===========
Host Name= oradbsrvr2
DB Name=testdb
Oracle Version=11.2.0.1.0
Oracle Home=/u01/oracle/product/11.2.0/db1
dbfiles_loc=/u02/oradata/testdb

Step1: Creating Init.ora File on target system
=================================================
*.audit_file_dest='/u01/oracle/oraclebase/admin/testdb/adump'
*.compatible='11.2.0'
*.control_files='/u02/oradata/testdb/control01.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u02/oradata'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='TESTDB'#Modified by RMAN duplicate
*.db_recovery_file_dest_size=2147483648
*.db_recovery_file_dest='/u02/oradata'
*.db_unique_name='TESTDB'#Modified by RMAN duplicate
*.diagnostic_dest='/u01/oracle/oraclebase'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=testdbXDB)'
*.java_pool_size=134217728
*.job_queue_processes=10
*.local_listener='(ADDRESS=(PROTOCOL=TCP)(HOST=oradbsrvr2)(PORT=1521))'
*.log_buffer=11485660
*.open_cursors=300
*.pga_aggregate_target=298844160
*.processes=600
*.remote_login_passwordfile='EXCLUSIVE'
*.session_cached_cursors=300
*.sga_target=897581056
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.db_file_name_convert='/u01/oradata/racdb/','/u02/oradata/testdb/'
*.log_file_name_convert='/u01/oradata/racdb/','/u02/oradata/testdb/'

Step2: Creating password files
==================================
orapwd file=orapwtestdb password=oracle ignorecase=y entries=5

Step3: Configuring Listener
==============================
First I tried to connect to database without adding any entries

oracle@oradbsrvr2:/appl/oracle>sqlplus sys/oracle@testdb as sysdba 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Mar 28 16:51:46 2011

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

ERROR:
ORA-12528: TNS:listener: all appropriate instances are blocking new connections

After this error I checked the listener status

oracle@oradbsrvr2:/appl/oracle>lsnrctl status    

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 28-MAR-2011 16:52:15

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                21-MAR-2011 19:16:26
Uptime                    6 days 21 hr. 35 min. 49 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /u01/oracle/product/11.2.0/grid/network/admin/listener.ora
Listener Log File         /u01/oracle/oraclebase/diag/tnslsnr/oradbsrvr2/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.100)(PORT=1521)))
Services Summary...
Service "testdb" has 1 instance(s).
  Instance "testdb", status BLOCKED, has 1 handler(s) for this service...
The command completed successfully

testdb instance status was blocked so I added sid_list_listener values

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/oracle/product/11.2.0/grid)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = testdb)
      (SID_NAME = testdb)
      (ORACLE_HOME = /u01/oracle/product/11.2.0/grid)
    )
  )

Then restarted the listener

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 28-MAR-2011 16:56:41
Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                28-MAR-2011 16:56:37
Uptime                    0 days 0 hr. 0 min. 4 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      ON
Listener Parameter File   /u01/oracle/product/11.2.0/grid/network/admin/listener.ora
Listener Log File         /u01/oracle/oraclebase/diag/tnslsnr/oradbsrvr2/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.100)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "testdb" has 1 instance(s).
  Instance "testdb", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

Step4: Duplicating Database
===============================

oracle@oradbsrvr2:/home/oracle>rman target sys/oracle@racdb auxiliary sys/oracle@testdb

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Mar 28 18:53:59 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: RACDB (DBID=3431901857)
connected to auxiliary database: TESTDB (not mounted)

RMAN> run
2>  {
duplicate target database to testdb from active database;
3> 4>  }

Starting Duplicate Db at 28-MAR-11
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=20 device type=DISK

contents of Memory Script:
{
   sql clone "alter system set  db_name =
''RACDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
''TESTDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   backup as copy current controlfile auxiliary format  '/u02/oradata/testdb/controlfile/control01.ctl';
   alter clone database mount;
}
executing Memory Script
sql statement: alter system set  db_name =  ''RACDB'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set  db_unique_name =  ''TESTDB'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started

Total System Global Area     893562880 bytes
Fixed Size                     2218512 bytes
Variable Size                343934448 bytes
Database Buffers             532676608 bytes
Redo Buffers                  14733312 bytes

Starting backup at 28-MAR-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=93 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 03/28/2011 18:54:32
RMAN-03015: error occurred in stored script Memory Script
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/28/2011 18:54:32
ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-12154: TNS:could not resolve the connect identifier specified
ORA-17629: Cannot connect to the remote database server

RMAN> exit

This error was occurred because the TNS entries of our auxiliary database were missing on the source database. This is required as we are duplicating the active database and it need connection to auxiliary database. After adding TNS entries, the rman process was started again

oracle@oradbsrvr2:/home/oracle>rman target sys/oracle@racdb auxiliary sys/oracle@testdb

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Mar 28 19:13:57 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: RACDB (DBID=3431901857)
connected to auxiliary database: TESTDB (not mounted)

RMAN> run
2>  {
3>  duplicate target database to testdb from active database;
4>  }

Starting Duplicate Db at 28-MAR-11
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK

contents of Memory Script:
{
   sql clone "alter system set  db_name =
''RACDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
''TESTDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   backup as copy current controlfile auxiliary format  '/u02/oradata/testdb/controlfile/control01.ctl';
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''RACDB'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set  db_unique_name =  ''TESTDB'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area     893562880 bytes
Fixed Size                     2218512 bytes
Variable Size                343934448 bytes
Database Buffers             532676608 bytes
Redo Buffers                  14733312 bytes

Starting backup at 28-MAR-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=93 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 03/28/2011 19:14:17
RMAN-03015: error occurred in stored script Memory Script
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/28/2011 19:14:17
ORA-17628: Oracle error 19505 returned by remote Oracle server

RMAN> exit

This error was occurred because the controlfile location was specified wrongly. After correcting the control file path, the script executed once again

oracle@oradbsrvr2:/home/oracle>rman target sys/oracle@racdb auxiliary sys/oracle@testdb

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Mar 28 19:17:12 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: RACDB (DBID=3431901857)
connected to auxiliary database: TESTDB (not mounted)

RMAN> run
2>  {
3>  duplicate target database to testdb from active database;
4>  }

Starting Duplicate Db at 28-MAR-11
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK

contents of Memory Script:
{
   sql clone "alter system set  db_name =
''RACDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
''TESTDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   backup as copy current controlfile auxiliary format  '/u02/oradata/testdb/control01.ctl';
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''RACDB'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''TESTDB'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     893562880 bytes

Fixed Size                     2218512 bytes
Variable Size                343934448 bytes
Database Buffers             532676608 bytes
Redo Buffers                  14733312 bytes

Starting backup at 28-MAR-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=107 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/oracle/product/11.2.0/db/dbs/snapcf_racdb.f tag=TAG20110328T191731 RECID=4 STAMP=746997451
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 28-MAR-11

database mounted

contents of Memory Script:
{
   set newname for datafile  1 to
"/u02/oradata/racdb/system01.dbf";
   set newname for datafile  2 to
"/u02/oradata/racdb/sysaux01.dbf";
   set newname for datafile  3 to
"/u02/oradata/racdb/undotbs01.dbf";
   set newname for datafile  4 to
"/u02/oradata/racdb/users01.dbf";
   set newname for datafile  5 to
"/u02/oradata/racdb/example01.dbf";
   set newname for datafile  6 to
"/u02/oradata/racdb/user_data01.dbf";
   backup as copy reuse
   datafile  1 auxiliary format
"/u02/oradata/racdb/system01.dbf"   datafile
2 auxiliary format
"/u02/oradata/racdb/sysaux01.dbf"   datafile
3 auxiliary format
"/u02/oradata/racdb/undotbs01.dbf"   datafile
4 auxiliary format
"/u02/oradata/racdb/users01.dbf"   datafile
5 auxiliary format
"/u02/oradata/racdb/example01.dbf"   datafile
6 auxiliary format
"/u02/oradata/racdb/user_data01.dbf"   ;
   sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting backup at 28-MAR-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/oradata/racdb/system01.dbf
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/28/2011 19:17:42
ORA-17628: Oracle error 19505 returned by remote Oracle server
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/oradata/racdb/sysaux01.dbf
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/28/2011 19:17:43
ORA-17628: Oracle error 19505 returned by remote Oracle server
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/oradata/racdb/example01.dbf
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/28/2011 19:17:45
ORA-17628: Oracle error 19505 returned by remote Oracle server
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/oradata/racdb/undotbs01.dbf
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/28/2011 19:17:46
ORA-17628: Oracle error 19505 returned by remote Oracle server
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/u01/oradata/racdb/user_data01.dbf
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/28/2011 19:17:47
ORA-17628: Oracle error 19505 returned by remote Oracle server
continuing other job steps, job failed will not be re-run
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/oradata/racdb/users01.dbf
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 03/28/2011 19:17:48
RMAN-03015: error occurred in stored script Memory Script
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 03/28/2011 19:17:48
ORA-17628: Oracle error 19505 returned by remote Oracle server

RMAN> exit

This time the duplicate process was failed because the two parameters were not specified in init.ora parameter file:

*.db_file_name_convert='/u01/oradata/racdb/','/u02/oradata/testdb/'
*.log_file_name_convert='/u01/oradata/racdb/','/u02/oradata/testdb/'

After putting these two parameters, the script was started once again

oracle@oradbsrvr2:/home/oracle>rman target sys/oracle@racdb auxiliary sys/oracle@testdb

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Mar 28 19:24:43 2011

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: RACDB (DBID=3431901857)
connected to auxiliary database: TESTDB (not mounted)

RMAN> run
2>  {
3>  duplicate target database to testdb from active database;
4>  }

Starting Duplicate Db at 28-MAR-11
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK

contents of Memory Script:
{
   sql clone "alter system set  db_name =
''RACDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
''TESTDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   backup as copy current controlfile auxiliary format  '/u02/oradata/testdb/control01.ctl';
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''RACDB'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set  db_unique_name =  ''TESTDB'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area     893562880 bytes
Fixed Size                     2218512 bytes
Variable Size                343934448 bytes
Database Buffers             532676608 bytes
Redo Buffers                  14733312 bytes
Starting backup at 28-MAR-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=96 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/oracle/product/11.2.0/db/dbs/snapcf_racdb.f tag=TAG20110328T192504 RECID=5 STAMP=746997905
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 28-MAR-11

database mounted

contents of Memory Script:
{
   set newname for datafile  1 to
"/u02/oradata/testdb/system01.dbf";
   set newname for datafile  2 to
"/u02/oradata/testdb/sysaux01.dbf";
   set newname for datafile  3 to
"/u02/oradata/testdb/undotbs01.dbf";
   set newname for datafile  4 to
"/u02/oradata/testdb/users01.dbf";
   set newname for datafile  5 to
"/u02/oradata/testdb/example01.dbf";
   set newname for datafile  6 to
"/u02/oradata/testdb/user_data01.dbf";
   backup as copy reuse
   datafile  1 auxiliary format
"/u02/oradata/testdb/system01.dbf"   datafile
2 auxiliary format
"/u02/oradata/testdb/sysaux01.dbf"   datafile
3 auxiliary format
"/u02/oradata/testdb/undotbs01.dbf"   datafile
4 auxiliary format
"/u02/oradata/testdb/users01.dbf"   datafile
5 auxiliary format
"/u02/oradata/testdb/example01.dbf"   datafile
6 auxiliary format
"/u02/oradata/testdb/user_data01.dbf"   ;
   sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting backup at 28-MAR-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/oradata/racdb/system01.dbf
output file name=/u02/oradata/testdb/system01.dbf tag=TAG20110328T192512
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:06
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/oradata/racdb/sysaux01.dbf
output file name=/u02/oradata/testdb/sysaux01.dbf tag=TAG20110328T192512
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:05
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/oradata/racdb/example01.dbf
output file name=/u02/oradata/testdb/example01.dbf tag=TAG20110328T192512
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/oradata/racdb/undotbs01.dbf
output file name=/u02/oradata/testdb/undotbs01.dbf tag=TAG20110328T192512
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/u01/oradata/racdb/user_data01.dbf
output file name=/u02/oradata/testdb/user_data01.dbf tag=TAG20110328T192512
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/oradata/racdb/users01.dbf
output file name=/u02/oradata/testdb/users01.dbf tag=TAG20110328T192512
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 28-MAR-11

sql statement: alter system archive log current

contents of Memory Script:
{
   backup as copy reuse
   archivelog like  "/u01/flash_recovery/RACDB/archivelog/2011_03_28/o1_mf_1_143_6s26j8mh_.arc" auxiliary format
"/u02/oradata/TESTDB/archivelog/2011_03_28/o1_mf_1_143_%u_.arc"   ;
   catalog clone recovery area;
   switch clone datafile all;
}
executing Memory Script

Starting backup at 28-MAR-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=143 RECID=272 STAMP=746998218
output file name=/u02/oradata/TESTDB/archivelog/2011_03_28/o1_mf_1_143_1am8ciee_.arc RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:07
Finished backup at 28-MAR-11

searching for all files in the recovery area

List of Files Unknown to the Database
=====================================
File Name: /u02/oradata/TESTDB/archivelog/2011_03_28/o1_mf_1_143_1am8ciee_.arc
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u02/oradata/TESTDB/archivelog/2011_03_28/o1_mf_1_143_1am8ciee_.arc

datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=746998230 file name=/u02/oradata/testdb/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=746998230 file name=/u02/oradata/testdb/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=746998231 file name=/u02/oradata/testdb/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=746998231 file name=/u02/oradata/testdb/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=9 STAMP=746998231 file name=/u02/oradata/testdb/example01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=10 STAMP=746998231 file name=/u02/oradata/testdb/user_data01.dbf

contents of Memory Script:
{
   set until scn  4176301;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 28-MAR-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 device type=DISK

starting media recovery

archived log for thread 1 with sequence 143 is already on disk as file /u02/oradata/TESTDB/archivelog/2011_03_28/o1_mf_1_143_1am8ciee_.arc
archived log file name=/u02/oradata/TESTDB/archivelog/2011_03_28/o1_mf_1_143_1am8ciee_.arc thread=1 sequence=143
media recovery complete, elapsed time: 00:00:01
Finished recover at 28-MAR-11

contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
   sql clone "alter system set  db_name =
''TESTDB'' comment=
''Reset to original value by RMAN'' scope=spfile";
   sql clone "alter system reset  db_unique_name scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     893562880 bytes

Fixed Size                     2218512 bytes
Variable Size                343934448 bytes
Database Buffers             532676608 bytes
Redo Buffers                  14733312 bytes

sql statement: alter system set  db_name =  ''TESTDB'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset  db_unique_name scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     893562880 bytes

Fixed Size                     2218512 bytes
Variable Size                343934448 bytes
Database Buffers             532676608 bytes
Redo Buffers                  14733312 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TESTDB" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
LOGFILE
  GROUP  1 ( '/u02/oradata/testdb/redo01.log' ) SIZE 50 M  REUSE,
  GROUP  2 ( '/u02/oradata/testdb/redo02.log' ) SIZE 50 M  REUSE,
  GROUP  3 ( '/u02/oradata/testdb/redo03.log' ) SIZE 50 M  REUSE
DATAFILE
  '/u02/oradata/testdb/system01.dbf'
CHARACTER SET WE8MSWIN1252

contents of Memory Script:
{
   set newname for tempfile  1 to
"/u02/oradata/testdb/temp01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy  "/u02/oradata/testdb/sysaux01.dbf",
"/u02/oradata/testdb/undotbs01.dbf",
"/u02/oradata/testdb/users01.dbf",
"/u02/oradata/testdb/example01.dbf",
"/u02/oradata/testdb/user_data01.dbf";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u02/oradata/testdb/temp01.dbf in control file

cataloged datafile copy
datafile copy file name=/u02/oradata/testdb/sysaux01.dbf RECID=1 STAMP=746998255
cataloged datafile copy
datafile copy file name=/u02/oradata/testdb/undotbs01.dbf RECID=2 STAMP=746998255
cataloged datafile copy
datafile copy file name=/u02/oradata/testdb/users01.dbf RECID=3 STAMP=746998255
cataloged datafile copy
datafile copy file name=/u02/oradata/testdb/example01.dbf RECID=4 STAMP=746998255
cataloged datafile copy
datafile copy file name=/u02/oradata/testdb/user_data01.dbf RECID=5 STAMP=746998255

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=746998255 file name=/u02/oradata/testdb/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=746998255 file name=/u02/oradata/testdb/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=746998255 file name=/u02/oradata/testdb/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=746998255 file name=/u02/oradata/testdb/example01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=746998255 file name=/u02/oradata/testdb/user_data01.dbf

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at 28-MAR-11

RMAN>exit

This time we were succeeded in duplicating the database with active database option.

Hope this help

Sunday, February 20, 2011

NFS Configuration for Oracle RAC

Today I was going to Install/configure Oracle 11gR2 RAC without using shared storage on Red Hat Enterprise Linux. I had read about that before but never tested so I tried and failed first time but after some re-configuration, I was able to configure clusterware and was able to store OCR Voting and database files on NFS mount points.

Step 1
=========
On First node e.g. RAC node1, create the following directory. You can use any directory as your NFS source mount point.

mkdir /u01/shared_config
chown -R oracle:oinstall /u01/shared_config

Step 2
=========
Add the following lines to the /etc/exports file.

vi /etc/exports
------------------------------------------------
/u01/shared_config  *(rw,sync,no_wdelay,insecure_locks,no_root_squash)

Step 3
========
Run the following command to export the NFS shares.
Check that the NFS server will get started during boot of this server.

chkconfig --level 345 nfs on

Now, start the NFS server process on the NFS server.
service nfs start

Check, if the directory is exported correctly by issuing the exportfs –v command:
/usr/sbin/exportfs -v

Step 4
========
On both node1 and node2 create the directories in which the Oracle configuration files will be created.

mkdir /shared_config
chown -R oracle:oinstall /shared_config
chmod -R 775 /shared_config

Step 5
=======
Add the following lines to the "/etc/fstab" file.
---------------------------------------------------------------
racnode1:/u01/shared_config /shared_config  nfs  rw,bg,hard,nointr,tcp,vers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0  0 0

Note: I used following Oracle recommended settings for nfs share and at the end my ocr and voting disks configuration process was failed:
racnode1:/u01/shared_config /shared_config  nfs  rw,bg,hard,intr,rsize=32768,wsize=32768,tcp,noac,vers=3,timeo=600 0 0

Step 6
=======
Mount the NFS shares on all servers.

mount /shared_config

Make sure the permissions on the shared directories are correct i.e oracle.
Check, if the NFS export is correctly mounted with the mount command.
# mount
It will give you output like this:
esidbapoc01:/sharedconfig on /shared_config type nfs (rw,bg,hard,nointr,tcp,nfsvers=3,timeo=600,rsize=32768,wsize=32768,actimeo=0,addr=192.168.1.3)


Hope this will help…………

Thursday, January 27, 2011

Remote Telnet on Unix Servers


I have created simple script which will telnet to any unix server and will perform the tasks required.

#Remote_Telnet.sh
------------------------------------
#!/bin/ksh
. ~/.profile

HOST='192.168.1.100'
DELAY=3
USER='oracle'
PASSWORD='oracle'
COMMAND1='cd /home/oracle'

(
sleep 3
print "${USER}"
sleep 3
print "${PASSWORD}"
sleep 3
print "Starting Patch Deployment on ${HOST}"
sleep 1
print "cd /app/dbsrvr"
print ". ./dbenv.sh"
print "cd bin"
print "./stop_server.sh"
print "cd /app/dbserver/patches"
print "opatch apply"
print "cd /app/dbsrvr/bin"
print "./start_server.sh"
sleep 1
print "exit"
sleep 3
) | telnet "${HOST}"$

------------------------------------

Currently I have hard-coded IP and user details but you can change this to enter the values at run time and change the script to accept those values and connect to that specific server.
for example:
#Remote_Telnet.sh `192.168.1.100` oracle password
------------------------------------
#!/bin/ksh
. ~/.profile

HOST='$1'
DELAY=3
USER='$2'
PASSWORD='$3'
------------------------------------