Oracle9i Database Utilities Release 2 (9.2) Part Number A96652-01 |
|
DBNEWID is a database utility that can change the internal database identifier (DBID) and the database name (DBNAME) for an operational database.
This chapter contains the following sections:
Prior to the introduction of the DBNEWID utility, you could manually create a copy of a database and give it a new database name (DBNAME) by re-creating the control file. However, you could not give the database a new identifier (DBID). The DBID is an internal, unique identifier for a database. Because Recovery Manager (RMAN) distinguishes databases by DBID, you could not register a seed database and a manually copied database together in the same RMAN repository. The DBNEWID utility solves this problem by allowing you to change any of the following:
Changing the DBID of a database is a serious procedure. When the DBID of a database is changed, all previous backups and archived logs of the database become unusable. After 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 (see the Oracle9i Database Administrator's Guide). Consequently, you should make a backup of the whole database immediately after changing the DBID.
Changing the DBNAME without changing the DBID does not require you to open with the RESETLOGS
option, so database backups and archived logs are not invalidated. However, changing the DBNAME does have consequences. 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.
This section contains these topics:
The following steps describe how to change the DBID of a database. Optionally, you can change the database name as well.
SHUTDOWN IMMEDIATE STARTUP MOUNT
SYSDBA
privilege. For example:
% nid TARGET=SYS/oracle@test_db
To change the database name in addition to the DBID, specify the DBNAME
parameter. This example changes the name to test_db2
:
% nid TARGET=SYS/oracle@test DBNAME=test_db2
The DBNEWID utility performs validations in the headers of the datafiles and control files before attempting I/O to the files. If validation is successful, then DBNEWID prompts you to confirm the operation (unless you specify a log file, in which case it does not prompt), changes the DBID for each datafile (including offline normal and read-only datafiles), and then exits. The database is left mounted but is not yet usable. For example:
DBNEWID: Release 9.2.0.1.0 (c) Copyright 2002 Oracle Corporation. All rights reserved. Connected to database TEST_DB (DBID=3942195360) Control Files in database: /oracle/dbs/cf1.f /oracle/dbs/cf2.f Change database id of database SOLARIS? (Y/[N]) => y Proceeding with operation Datafile /oracle/dbs/tbs_01.f - changed Datafile /oracle/dbs/tbs_02.f - changed Datafile /oracle/dbs/tbs_11.f - changed Datafile /oracle/dbs/tbs_12.f - changed Datafile /oracle/dbs/tbs_21.f - changed New DBID for database TEST_DB is 3942196782. All previous backups and archived redo logs for this database are unusable Proceed to shutdown database and open with RESETLOGS option. DBNEWID - Database changed.
If validation is not successful, then DBNEWID terminates and leaves the target database intact. You can open the database, fix the error, and then either resume the DBNEWID operation or continue using the database without changing its DBID.
SHUTDOWN IMMEDIATE
STARTUP MOUNT
RESETLOGS
mode and resume normal use. For example:
ALTER DATABASE OPEN RESETLOGS;
Make a new database backup. Because you reset the online redo logs, the old backups and archived logs are no longer usable in the current incarnation of the database.
The following steps describe how to change the database name without changing the DBID.
SHUTDOWN IMMEDIATE STARTUP MOUNT
SYSDBA
privilege. You must specify both the DBNAME
and SETNAME
parameters. This example changes the name to test_db2
:
% nid TARGET=SYS/oracle@test_db DBNAME=test_db2 SETNAME=YES
DBNEWID performs validations in the headers of the control files (not the datafiles) before attempting I/O to the files. If validation is successful, then DBNEWID prompts for confirmation, changes the database name in the control files, and exits. After DBNEWID completes successfully, the database is left mounted but is not yet usable.
DBNEWID: Release 9.2.0.1.0 (c) Copyright 2002 Oracle Corporation. All rights reserved. Connected to database TEST_DB (DBID=3942196782) Control Files in database: /oracle/dbs/cf1.f /oracle/dbs/cf2.f Change database name of database TEST_DB to TEST_DB2? (Y/[N]) => Y Proceeding with operation Database name changed from TEST_DB to TEST_DB2 - database needs to be shutdown. Modify parameter file and generate a new password file before restarting. DBNEWID - Successfully changed database name
If validation is not successful, then DBNEWID terminates and leaves the target database intact. You can open the database, fix the error, and then either resume the DBNEWID operation or continue using the database without changing the database name.
SHUTDOWN IMMEDIATE
DB_NAME
initialization parameter in the initialization parameter file to the new database name.STARTUP
If the DBNEWID utility succeeds in its validation stage but detects an error while changing the DBID, then the utility stops and leaves the database in the middle of the change. In this case, you cannot open the database until the DBNEWID operation is either completed or reverted. DBNEWID displays messages indicating the status of the operation.
Before continuing or reverting, fix the underlying cause of the error. Sometimes the only solution is to restore the whole database from a recent backup and perform recovery to the point in time before DBNEWID was started. This underscores the importance of having a recent backup available before running DBNEWID.
If you choose to continue the DBID change operation rather than revert it, reexecute your original command. The DBNEWID utility resumes and attempts to continue the change until all datafiles and control files have the new DBID. At this point, the database is left mounted. You should shut it down and then mount it again prior to opening it with the RESETLOGS
option.
If you choose to revert a DBNEWID operation, and if the reversion succeeds, then DBNEWID reverts all performed changes and leaves the database in a mounted state.
To revert a stalled DBID change operation, run the DBNEWID utility again, specifying the REVERT
keyword. For example:
% nid TARGET=SYS/oracle REVERT=YES LOGFILE=$HOME/nid.log
If you specify that only the database name should be changed (and not the DBID), then the validation process is the same as for a DBID change except that DBNEWID checks only the control files. It does not read the datafiles. If the validation encounters a problem, then the database is left mounted.
It is possible for validation to succeed, but for the actual database name change to fail. The possible failure scenarios depend on how many control files are in the database, as follows:
CONTROL_FILES
locations, or revert by copying the unchanged control files to all CONTROL_FILES
locations.The following diagrams show the syntax for the DBNEWID utility.
Text description of the illustration nid.gif
Text description of the illustration nid2.gif
Text description of the illustration nid3.gif
Table 14-1 describes the parameters in the DBNEWID syntax.
The DBNEWID utility has the following restrictions:
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.NOPARALLEL
mode.RESETLOGS
option after changing the DBID. Note that you do not have to open with the RESETLOGS
option after changing only the database name.REVERT
when changing only the DBID.The following example connects with operating system authentication and changes only the DBID:
% nid TARGET=/
The following example connects as user SYS
and changes the DBID and also changes the database name to test2
:
% nid TARGET=SYS/oracle@test1 DBNAME=test2
The following example connects as user SYSTEM
and changes only the database name, and also specifies a log file for the output:
% nid TARGET=SYSTEM/manager@test2 DBNAME=test3 SETNAME=YES LOGFILE=dbid.out
|
Copyright © 1996, 2002 Oracle Corporation. All Rights Reserved. |
|