Thursday, March 13, 2008

Change DBID

After you clone a database, it takes the same DBID from the source database. If you use same RMAN catalog to backup those two databases, it will not work because DBID has to be unique in one RMAN catalog.

Oracle provides the NID utility for changing DBNAME and DBID of RAC Database (9.0.1.4 to 10.2.0.4). See Metalink Note 464922.1 (2007) for detailed steps.

In 8i, there was a package for changing DBID. I post my old note here (and the Metalink Note number is not valid any more).

-- Change database's ID (Note: 174625.1)
-- 8/26/02

SVRMGR> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SVRMGR> startup mount;
ORACLE instance started.
Total System Global Area 561977372 bytes
Fixed Size 75804 bytes
Variable Size 293294080 bytes
Database Buffers 268435456 bytes
Redo Buffers 172032 bytes
Database mounted.

SVRMGR> alter database backup controlfile to trace;
Statement processed.

SVRMGR> select dbid, name from v$database;
DBID NAME
---------- ---------
463045413 OWXE2
1 row selected.

SVRMGR> execute dbms_backup_restore.zeroDbid(0);
Statement processed.

Note: the database MUST not be open.
Otherwise, the database is damaged by running this package.

SVRMGR> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.

SVRMGR> startup nomount;
ORACLE instance started.
Total System Global Area 561977372 bytes
Fixed Size 75804 bytes
Variable Size 293294080 bytes
Database Buffers 268435456 bytes
Redo Buffers 172032 bytes

SVRMGR> @f:\myfiles\rebuild_owxe2_control.sql
Statement processed.

CREATE CONTROLFILE SET DATABASE "OWXE2" RESETLOGS ARCHIVELOG
MAXLOGFILES 32
MAXLOGMEMBERS 2
MAXDATAFILES 100
MAXINSTANCES 1
MAXLOGHISTORY 29041
LOGFILE
GROUP 1 'D:\OWXE2\ORADATA\REDO01.LOG' SIZE 100M,
GROUP 2 'D:\OWXE2\ORADATA\REDO02.LOG' SIZE 100M,
GROUP 3 'D:\OWXE2\ORADATA\REDO03.LOG' SIZE 100M
DATAFILE
'D:\OWXE2\ORADATA\SYSTEM01.DBF',
'D:\OWXE2\ORADATA\RBS01.DBF',
......

SVRMGR> alter database open resetlogs;
Statement processed.

SVRMGR> select dbid, name from v$database;
DBID NAME
---------- ---------
1624780754 OWXE2
1 row selected.

No comments: