Cloning and the DBID

Over the last few years, people have been complaining about problems regarding the cloning of an Oracle 8 database. These problems are due to the fact under O8 and O9, each database contains a database identifier that is defined at the database creation time. This database identifier is NOT the same as the db_name parameter.

For the actual cloning procedure, click here.

You can view this value in an O8 database by querying the v$database dynamic view.


$ svrmgrl

Oracle Server Manager Release 3.0.5.0.0 - Production

(c) Copyright 1997, Oracle Corporation. 
SCT® and Banner® are registered trademarks of SCT Corporation.
Nyquest is not affiliated in any way with SCT.
All Rights Reserved.

Oracle8 Enterprise Edition Release 8.1.7.4.0 - Production
With the Partitioning option
PL/SQL Release 8.1.7.4.0 - Production

SVRMGR> connect internal
Connected.
SVRMGR> desc v$database
Column Name                    Null?    Type
------------------------------ -------- ----
DBID                                    NUMBER
NAME                                    VARCHAR2(9)
CREATED                                 DATE
RESETLOGS_CHANGE#                       NUMBER
RESETLOGS_TIME                          DATE
PRIOR_RESETLOGS_CHANGE#                 NUMBER
PRIOR_RESETLOGS_TIME                    DATE
LOG_MODE                                VARCHAR2(12)
CHECKPOINT_CHANGE#                      NUMBER
ARCHIVE_CHANGE#                         NUMBER
CONTROLFILE_TYPE                        VARCHAR2(7)
CONTROLFILE_CREATED                     DATE
CONTROLFILE_SEQUENCE#                   NUMBER
CONTROLFILE_CHANGE#                     NUMBER
CONTROLFILE_TIME                        DATE
OPEN_RESETLOGS                          VARCHAR2(11)
VERSION_TIME                            DATE

SVRMGR> select dbid from v$database;
DBID
----------
 427190255
1 row selected.

SVRMGR> exit


Unlike the db_name parameter, which is determined in the init.ora and can be changed in a CREATE CONTROLFILE SQL statement, the database identifier is determined by internal oracle routines during the CREATE DATABASE command, and (currently) no easy recipe exists for changing the value.

Talking to some of the reps at Oracle, they said the rationale for this dbid was due to the increasing use of databases over the internet. With the possibility of many databases connected over a TCP link, they wanted some method of uniquely labeling databases.

As you might expect, when you clone a database, the DBID comes over with the same value. This is fine, except when you try to attach two cloned database to newer Oracle utilities. New oracle apps, most notably Recovery Manager, uses the DBID for labeling and will complain if you try to use it with two cloned databases.


The work-around for this problem is as follows:

Recovery Manager (or RMAN) is a util by Oracle that assists the DBA
in the backup / recovery of O8 databases.

In order for RMAN to work, you need to attach to two databases.

The first database is known as the TARGET database and is the database
that you want to backup.

The second database is known as the REPOSITORY
database and contains the various parameters related to the backup of the
TARGET database, such as the frequency of backups, what to backup, where to
backup, etc.

The REPOSITORY should be a database that is used solely for RMAN purposes.

Before a database can be used as a repository, it must first be initialized. A database user with the DBA role must be created, and the script catrman.sql (located in $ORACLE_HOME/rdbms/admin for Unix & ORA_SID:[RDBMS.ADMIN] on OpenVMS) must be run as that user to setup all repository objects in that schema.

With non cloned databases, one user in the repository can control any
number of TARGET databases to be backed-up, since RMAN uses the DBID to
distinguish on database from another

However with cloned TARGET databases, (which all have the SAME DBID) RMAN
gets confused.

The work around for this is to create a new DBA user in the repository
database for each cloned target database that you wish to attach.
as stated earlier, EACH user in the repository MUST have the DBA role, and
you must run CATRMAN.SQL as each user.

When you invoke RMAN, the first thing you'll specify is the
username/password that RMAN is to use when connecting to the TARGET
database, and the username/password RMAN is to use when connecting to the
REPOSITORY database.


$ rman target \"system/manager@TARGET_DB\" \
>      rcvcat \"user1/password@REPOSITORY_DB\"

Now if you want to also connect a cloned database TARGET_CLONE_DB to
REPOSITORY_DB, you'll need to create another user, user2, for example in
REPOSITORY_DB (an run CATRMAN.SQL as user2)

$ rman target \"system/manager@TARGET_CLONE_DB\" \
>      rcvcat \"user2/password@REPOSITORY_DB\"

For information on how to use RMAN to copy a database with a different DBID, click here