Database Reference
In-Depth Information
3.
Prepare the test database
a.
Create a controlfile
b.
Use DBMS_DNFS to rename the data files
4.
Open the database
The following sections provide more detail about the process. You may have seen reference to the above process
on My Oracle Support and the Internet before Oracle 12c has been released. However this is the first time that the
clonedb feature is in the official documentation set and therefore more generally available. Some of these steps need
to be executed each time a clone is needed, others are a one-time setup. Let's review the process in more detail.
Preparation
Creating an image copy of the database can be done in many ways, beginning with a cold backup which has been
taken using the well-known combination of tar and gzip or a simple Unix “cp” command to an RMAN image copy.
Below is an example for such a copy command using RMAN. The example assumes that appropriate settings have
been made in the RMAN catalog database such as parallelism and destination. The necessary image copy of the
database is created on the production host and stored in an NFS mount, namely /m/backups/ which in turn is
mounted to /u01/oraback on the production host.
RMAN> backup as copy database format '/u01/oraback/NCDB/%u';
As always it is a good idea to take backups of the database during quieter periods. If you are not using NFS you
need to make the backup available on your test database server. To say it in the words of a perl developer: “there is
more than one way to do it”. Unlike with the RMAN duplication the location of the backup on the test server does
not matter.
Next you will need to prepare the create controlfile statement for the clone database. The controlfile can be
created in a number of ways. You either create the controlfile using the command backup controlfile to trace
at '/path/to/script.sql' , or you use the Oracle-provided script clonedb.pl in $ORACLE_HOME/rdbms/install . The
use of clonedb.pl requires you to set a few environment variables, and you can execute the script on the production
host or the destination server. The following example demonstrates its use. The environment variables in the below
output are required and need to reflect the directory structure on the clone database's host. The MASTER_COPY_DIR
indicates the NFS mount with the production database backup, CLONE_FILE_CREATE_DEST points to the location
where you'd like to store the clone database's data files (which must be NFS mounted to the development host) and
finally the database name for the clone database.
[oracle@server2 install]$ perl clonedb.pl
usage: perl clonedb.pl <init.ora> [crtdb.sql] [rename.sql]
[oracle@server2 install]$ export MASTER_COPY_DIR=/media/backup/NCDB
[oracle@server2 install]$ export CLONE_FILE_CREATE_DEST=/u01/oradata/CLONE
[oracle@server2 install]$ export CLONEDB_NAME=CLONE
[oracle@server2 install]$ perl clonedb.pl /tmp/initNCDB.ora /tmp/crtdb.sql /tmp/rename.sql
Review the files created and amend them to suit your needs. The initNCDB.ora file in the above output is the
production database's initialization file. In addition to the two SQL scripts the perl script will create an initialization
file for the clone database in the directory indicated by the environment variable CLONE_FILE_CREATE_DEST. The
parameter file will also need amending to suit your needs. Following along the example the following parameter file
was used:
*.audit_file_dest='/u01/app/oracle/admin/CLONE/adump'
*.audit_trail='db'
 
Search WWH ::




Custom Search