How to Change the DBID and the DBNAME by using NID [ID 224266.1] |
||
|
||
|
Modified 16-JUL-2009 Type PROBLEM Status PUBLISHED |
|
Checked for relevance on 05-March-08
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.
Purpose
=======
It is useful to troubleshoot from the situation when duplicate database ID's
cause errors such as the following.
RMAN-20002: target database already registered in recovery catalog
Cause: target database is already registered in the recovery catalog
Action: If the target database is really registered, there is no need to
register it again. Note that the recovery catalog enforces that
all databases have a unique DBID. If the new database was created
by copying files from an existing database, it will have the same
DBID as the original database and cannot be registered in the
same recovery catalog.
RMAN-20011, 1, "target database incarnation is not current in recovery catalog"
RMAN-20009, 1, "database incarnation already registered"
-or-
SQLPLUS> alter database mount standby database;
alter database mount standby database
*
ORA-01102: cannot mount database in EXCLUSIVE mode
Restrictions and Usage Notes
============================
The DBNEWID utility has the following restrictions:
- The utility is available only on the UNIX and Windows NT operating systems.
- The NID executable file should be owned and run by the Oracle owner because
it needs direct access to the datafiles and control files.
- If another user runs the utility, then set the user ID to the owner of the datafiles and control files.
- The DBNEWID utility must access the datafiles of the database directly through a local connection.
Although DBNEWID can accept a net service name, it cannot change the DBID of a nonlocal database.
- To change the DBID of a database, the database must be mounted and must have been shut down consistently
prior to mounting. In the case of an Oracle Real Application Clusters database, the database must be
mounted in NOPARALLEL mode. i.e set the init parameter CLUSTER_DATABASE=FALSE and then mount the database
- You must open the database with the RESETLOGS option after changing the DBID.
- Note that you do not have to open with the RESETLOGS option after changing only the database name.
- No other process should be running against the database when DBNEWID is executing.
If another session shuts down and starts the database, then DBNEWID aborts.
- All online datafiles should be consistent without needing recovery.
- Normal offline datafiles should be accessible and writable.
If this is not the case, you must drop these files before invoking the DBNEWID utility.
- All read-only tablespaces must be accessible and made writable at the operating system level prior
to invoking DBNEWID. If these tablespaces cannot be made writable (for example, they are on a CD-ROM),
then you must unplug the tablespaces using the transportable tablespace feature and then plug them back
in the database before invoking the DBNEWID utility (see the Oracle9i Database Administrator's Guide).
- You can only specify REVERT when changing only the DBID.
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
Example:
========
1. C:/>set ORACLE_SID=TEST1BY
C:/>sqlplus "/as sysdba"
SQL*Plus: Release 9.2.0.1.0 - Production on Tue Dec 24 11:16:52 2002
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to an idle instance.
SQL> startup pfile=D:/oracle/admin/TEST1BY/pfile/initTEST1BY.ora
ORACLE instance started.
Total System Global Area 135338868 bytes
Fixed Size 453492 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
2. check the DBID before change
SQL> select dbid,name,open_mode,activation#,created from v$database;
DBID NAME OPEN_MODE ACTIVATION# CREATED
---------- --------- ---------- ----------- ---------
1395399949 TEST1BY READ WRITE 1395404134 10-SEP-02
3. SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
4. SQL> startup mount pfile=D:/oracle/admin/TEST1BY/pfile/initTEST1BY.ora
ORACLE instance started.
Total System Global Area 135338868 bytes
Fixed Size 453492 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
Database mounted.
SQL>exit
5. execute NID
C:/>nid target=sys/oracle@TEST1BY
DBNEWID: Release 9.2.0.1.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
Connected to database TEST1BY (DBID=1395399949)
Control Files in database:
D:/ORACLE/BASE_TEST/TEST1BYCONTROL01.CTL
Change database ID of database TEST1BY? (Y/[N]) => y
Proceeding with operation
Changing database ID from 1395399949 to 1397190693
Control File D:/ORACLE/BASE_TEST/TEST1BYCONTROL01.CTL - modified
Datafile D:/ORACLE/BASE_TEST/TEST1BY/SYSTEM01.DBF - dbid changed
Datafile D:/ORACLE/BASE_TEST/TEST1BY/UNDOTBS01.DBF - dbid changed
Datafile D:/ORACLE/BASE_TEST/TEST1BY/DRSYS01.DBF - dbid changed
Datafile D:/ORACLE/BASE_TEST/TEST1BY/EXAMPLE01.DBF - dbid changed
Datafile D:/ORACLE/BASE_TEST/TEST1BY/INDX01.DBF - dbid changed
Datafile D:/ORACLE/BASE_TEST/TEST1BY/TOOLS01.DBF - dbid changed
Datafile D:/ORACLE/BASE_TEST/TEST1BY/USERS01.DBF - dbid changed
Datafile D:/ORACLE/BASE_TEST/TEST1BY/XDB01.DBF - dbid changed
Control File D:/ORACLE/BASE_TEST/TEST1BYCONTROL01.CTL - dbid changed
Database ID for database TEST1BY changed to 1397190693.
All previous backups and archived redo logs for this database are unusable.
Shut down database and open with RESETLOGS option.
Succesfully changed database ID.
DBNEWID - Completed succesfully.
6. SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
7. create the new passwordfile
8. SQL> startup mount pfile=D:/oracle/admin/TEST1BY/pfile/initTEST1BY.ora
ORACLE instance started.
Total System Global Area 135338868 bytes
Fixed Size 453492 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
Database mounted.
9. SQL> alter database open resetlogs;
Database altered.
10. check the new DBID
SQL> select dbid,name,open_mode,activation#,created from v$database;
DBID NAME OPEN_MODE ACTIVATION# CREATED
---------- --------- ---------- ----------- ---------
1397190693 TEST1BY READ WRITE 1397188261 10-SEP-02
NOTE: The NID change the OLD DBID 1395399949 to the NEW DBID 1397190693
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
8. Startup of the database(without resetlogs)
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
Example:
========
1. Shutdown the databse
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
2. Mount the database
SQL> startup mount pfile=d:/oracle/admin/test1by/pfile/inittest1by.ora
ORACLE instance started.
Total System Global Area 135338868 bytes
Fixed Size 453492 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
Database mounted.
startup mount
3. Run NID utility
C:/>nid target=sys/oracle@test1 dbname=test1by logfile=d:/oracle/base_test/nid.log
DBNEWID: Release 9.2.0.1.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation. All rights reserved.
Connected to database TEST1 (DBID=849281895)
Control Files in database:
D:/ORACLE/BASE_TEST/TEST1BYCONTROL01.CTL
Changing database ID from 849281895 to 1395399949
Changing database name from TEST1 to TEST1BY
Control File D:/ORACLE/BASE_TEST/TEST1BYCONTROL01.CTL - modified
Datafile D:/ORACLE/BASE_TEST/TEST1BY/SYSTEM01.DBF - dbid changed, wrote new name
Datafile D:/ORACLE/BASE_TEST/TEST1BY/UNDOTBS01.DBF - dbid changed, wrote new name
Datafile D:/ORACLE/BASE_TEST/TEST1BY/DRSYS01.DBF - dbid changed, wrote new name
Datafile D:/ORACLE/BASE_TEST/TEST1BY/EXAMPLE01.DBF - dbid changed, wrote new name
Datafile D:/ORACLE/BASE_TEST/TEST1BY/INDX01.DBF - dbid changed, wrote new name
Datafile D:/ORACLE/BASE_TEST/TEST1BY/TOOLS01.DBF - dbid changed, wrote new name
Datafile D:/ORACLE/BASE_TEST/TEST1BY/USERS01.DBF - dbid changed, wrote new name
Datafile D:/ORACLE/BASE_TEST/TEST1BY/XDB01.DBF - dbid changed, wrote new name
Control File D:/ORACLE/BASE_TEST/TEST1BYCONTROL01.CTL - dbid changed, wrote new name
Database name changed to TEST1BY.
Modify parameter file and generate a new password file before restarting.
Database ID for database TEST1BY changed to 1395399949.
All previous backups and archived redo logs for this database are unusable.
Shut down database and open with RESETLOGS option.
Succesfully changed database name and ID.
DBNEWID - Completed succesfully.
4. Shutdown immediate of the database
5. Modfiy the file init.ora of the database
change the parameter BD_NAME=TEST1 TO DBNAME=TEST1BY
6. create a new password file
Usage: orapwd file=<fname> password=<password> entries=<users>
where
file - name of password file (mand),
password - password for SYS (mand),
entries - maximum number of distinct DBA and OPERs (opt),
7. mount the database
SQL> startup mount pfile=d:/oracle/admin/test1by/pfile/inittest1by.ora
ORACLE instance started.
Total System Global Area 135338868 bytes
Fixed Size 453492 bytes
Variable Size 109051904 bytes
Database Buffers 25165824 bytes
Redo Buffers 667648 bytes
Database mounted.
8. Open the databse with RESETLOGS
SQL> alter database open resetlogs;
Database altered.
9. check the dictionary view for the new DBID and DBNAME
select dbid, name, open_mode, activation#, created from v$database;
Other Useful Information
========================
Except the parameters like LOGFILE=, APPEND, HELP, there is a specific option
REVERT which allows us to go back on the steps of executing. If the value of
REVERT is YES that means that a failed change of DBID should be reverted but a
successfully completed change of DBID cannot be reverted. REVERT=YES is only
valid when a DBID change failed. Default value is NO.
In 10.2 and higher the database may automatically shut down after a change.
Do not be alarmed if this occurs.
Documentation
=============
Oracle9i Database Utilities Release 2 (9.2)
Related |
------------------------------------------------------------------------------