Wednesday, March 27, 2013

How to avoid a failed duplicate to overwrite the online redologs of the target Database:


How to avoid a failed duplicate to overwrite the online redologs of the target Database[ID 1282984.1]
Error:

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.
SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-19838: Cannot use this control file to open database

Solution :

In 11.2 also 'DUPLICATE' can resume a failed duplicate, thus the need to perform the recover and open manually is alleviated.

If you would decide to still perform the steps manually, then you will need to create a new controlfile and provide the names of the online logs before opening the database.

Once db is open Need to change SID

How to Change the DBID and the DBNAME by using NID

Introduction
============

The NID (New Database ID)is a new utility introduced with Oracle 9.2.  The NID
utility allows you to change only the DBNAME, or only the DBID or both
DBNAME and DBID in the same command.

  1. If you change the DBID you must open the database with the RESETLOGS
     option, which re-creates the online redo logs and resets their sequence to 1.

  2. If you change the DBNAME without changing the DBID then this does not
     require you to open with the RESETLOGS option, so database backups and
     archived logs are not invalidated.  You must change the DB_NAME initialization
     parameter after a database name change to reflect the new name.  Also,
     you may have to re-create the Oracle password file.  If you restore an old
     backup of the control file (before the name change, then you should
     use the initialization parameter file and password file from before the
     database name change.

Change Only the DBID
====================

  1. Backup the database
  2. SHUTDOWN IMMEDIATE of the database
  3. STARTUP MOUNT
  4. Open one session and run NID with sysdba privileges
     % nid TARGET=SYS/password@test_db
  5. Shutdown IMMEDIATE of the database
  6. Set the DB_NAME initialization parameter in the initialization parameter
     file to the new database name
  7. Create a new password file
  8. Startup of the database with open resetlogs

1. set ORACLE_SID=TEST
sqlplus "/as sysdba"
SQL> startup pfile=D:\oracle\admin\TEST1BY\pfile\initTEST.ora
   ORACLE instance started.

2. check the DBID before change
   SQL> select dbid,name,open_mode,activation#,created from v$database;

3. SQL> shutdown immediate;

4. SQL> startup mount pfile=D:\oracle\admin\TEST1BY\pfile\initTEST1BY.ora
   ORACLE instance started.

5. execute NID

   [oracle@svruatebsdl1 ~]$nid target=sys/oracle@TEST1BY
Change database ID of database TEST1BY? (Y/[N]) => y
........
.......
Shut down database and open with RESETLOGS option.
   Succesfully changed database ID.
   DBNEWID - Completed succesfully.

6. SQL> shutdown immediate;

7. create the new passwordfile

8. SQL> startup mount pfile=$ORACLE_HOME/dbs/initTEST.ora
   ORACLE instance started.

9. SQL> alter database open resetlogs;
   Database altered.

10. check the new DBID

    SQL> select dbid,name,open_mode,activation#,created from v$database;

Change Only the DBNAME
======================

  1. Backup the database
  2. SHUTDOWN IMMEDIATE of the database
  3. STARTUP MOUNT
  4. Open one session and run NID with sysdba privileges
     % nid TARGET=SYS/password@test_db DBNAME=test_db2 SETNAME=Y
     - the value of DBNAME is the new dbname of the database
     - SETNAME must be set to Y. The default is N and causes the
       DBID to be changed also.
  5. shutdown IMMEDIATE of the database
  6. Set the DB_NAME initialization parameter in the initialization parameter
     file to the new database name
  7. Create a new password file

Change Both DBID and DBNAME
===========================

  1. Backup of the database.
  2. Shutdown IMMEDIATE of the database
  3. STARTUP MOUNT
  4. Open one session and run NID with sysdba privileges
     % nid TARGET=SYS/password@test_db DBNAME=test_db2
     - the value of DBNAME is the new dbname of the database
  5. After DBNEWID successfully changes the DBID,Shutdown IMMEDIATE of the database
  6. Set the DB_NAME initialization parameter in the
     initialization parameter file to the new database name.
  7. Create a new password file.
  8. Startup of the database with open resetlogs

  8. Startup of the database(without resetlogs)

Note:
 Run NID utility
   [oracle@svruatebsdl1 ~]$nid target=sys/oracle@test1 dbname=test1by logfile=[oracle@svruatebsdl1 ~]$/u01/oracle/base_uat/nid.log
+++++++++++++++++++++++++++++++++
1282984.1, 224266.1 ,360962.1   
+++++++++++++++++++++++++++++++++

No comments:

Post a Comment