Alejandro Vargas' Blog

  • January 8, 2008

ASM Database Clones Naming Issues

Alejandro Vargas
Technical Leader, ACS Global Delivery, Infrastructure & BigData

There are several ways to clone an ASM based database, some of them result in a directory structure that do not match the current database name, i.e, the source database directory structure is built this way:

... etc

When cloning we will keep the same directory structure and change the database name to testdb or devdb or repdb, some dba's do not feel comfortable having a "testdb" database on a directory like "+DATADG/proddb/..."

In this post I will mention 2 possible workarounds.

1) Using a generic unique_db_name to be shared by all clones
2) Creating a set of directories and moving the database oracle files over to it

1. Using a generic unique_db_name to be shared by all clones

The easiest one is to use a generic db_unique_name for the set of databases to be cloned.

For instance if the database to be cloned is a billing system we may set the db_unique_name at database creation to "billing", in this case we will get for all our clones a generic root directory named "billing" instead of one that is  the name of source database in the group.

When using Database Configuration Assistant (DBCA) you can set manually the parameter db_unique_name by choosing parameters -> advanced parameters configuration.

The static parameter  db_unique_name can be changed at any moment, it will require an instance restart to become active.

If you are using Oracle Managed Files (OMF) The new unique_db_name is used as root directory for any new oracle files created from the moment the new name is made active.

Following you can see an example of a database created with a db_unique_name='generic' and a db_name='redhorse'

SQL> select name from v$database;


    SQL> select * from global_name;


    SQL> select db_unique_name from v$database;

    SQL> select file_name from dba_data_files;


2. Creating a set of directories and moving the database oracle files over to it

This is a more laborious workaround than to set the db_unique_name of the clone to be the same as the db_name.

Once the clone is created you will manually create the directories matching the new name, and move the oracle files from the old directory to the new directory using rman, i.e.:
  • Create a set of directories reflecting the new database structure, in my case the original database was cpdg1 and the clone is cpdg2.

(it may happen that your spfile is siting on an alias with the name of the database, you will need to remove the alias to be able to create the directories)

ASMCMD> ls cpdg1

ASMCMD> mkdir cpdg2
ASMCMD> mkdir cpdg2/DATAFILE/
ASMCMD> mkdir cpdg2/TEMPFILE

  • From now on every create of an oracle file on database cpdg2 will go to the cpdg2 directory, i.e.

SQL> select name from v$database;


SQL> create tablespace users2;

Tablespace created.

SQL> select file_name from dba_data_files where tablespace='USERS2';


  • To move tablespaces based on the old directory cpdg1 set the tablespace offline and move the datafiles with rman

SQL> alter tablespace users offline;

Tablespace altered.

  • Start an rman session
RMAN> copy datafile '+DB3CLNDG/cpdg1/datafile/users.264.640191515' to

Starting backup at 06/01/2008 03:42:53
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004
output file name=+DB3CLNDG/cpdg2/datafile/users.268.643261377
tag=TAG20080106T034255 RECID=1 STAMP=643261380 channel ORA_DISK_1:
datafile copy complete, elapsed time: 00:00:07 Finished backup at
06/01/2008 03:43:03

RMAN> switch tablespace users to copy;

datafile 4 switched to datafile copy

  • Bring the tablespace online again
SQL> alter tablespace users online;

Tablespace altered.

SQL> select file_name from dba_data_files where tablespace_name='USERS';


  • Now you can delete the old file
{oracle} /oradisk/app01/oracle/product/11db/dbs [pollux.com] > asmcmd ls
{oracle} /oradisk/app01/oracle/product/11db/dbs [pollux.com] > asmcmd rm
{oracle} /oradisk/app01/oracle/product/11db/dbs [pollux.com] > asmcmd ls
ASMCMD-08002: entry 'users.264.640191515' does not exist in directory

Join the discussion

Comments ( 1 )
  • Dan Norris Tuesday, January 8, 2008
    Great tips, Alejandro. Thanks for putting this together. I'm sure the technical steps for these techniques are in the docs somewhere, but are there any Metalink notes or other "official" sources that pull all the steps together as neatly as you've done here?
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.