冷克隆:源数据库在关机状态下,通过拷贝数据文件,重新创建控制文件,启动数据库,此时数据库的DBID和原来一样。
热克隆:源数据库在运行中,只能通过热备数据库(热备或RMAN),再进行恢复,启动数据库,此时数据库的DBNAME,DBID和原来不同。
冷克隆过程
http://www.dba-oracle.com/oracle_tips_db_copy.htm
A database cloning procedure is especially useful for the DBA who wants to give his developers a full-sized TEST and DEV instance by cloning the PROD instance into the development server areas.
This Oracle clone procedure can be use to quickly migrate a system from one UNIX server to another. It clones the Oracle database and this Oracle cloning procedures is often the fastest way to copy a Oracle database.
STEP 1: On the old system, go into SQL*Plus, sign on as SYSDBA and issue: “alter database backup controlfile to trace”. This will put the create database syntax in the trace file directory. The trace keyword tells oracle to generate a script containing a create controlfile command and store it in the trace directory identified in the user_dump_dest parameter of the init.ora file. It will look something like this:
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "OLDLSQ" NORESETLOGS
NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 240
MAXINSTANCES 1
MAXLOGHISTORY 113
LOGFILE
GROUP 1 ('/u03/oradata/oldlsq/log1a.dbf',
'/u03/oradata/olslsq/log1b.dbf') SIZE 30M,
GROUP 2 ('/u04/oradata/oldlsq/log2a.dbf',
'/u04/oradata/oldlsq/log2b.dbf') SIZE 30M
DATAFILE
'/u01/oradata/oldlsq/system01.dbf',
'/u01/oradata/oldlsq/mydatabase.dbf'
;
# Recovery is required if any of the datafiles are restored
# backups, or if the last shutdown was not normal or immediate.
RECOVER DATABASE
# Database can now be opened normally.
ALTER DATABASE OPEN;
STEP 2: Shutdown the old database
STEP 3: Copy all data files into the new directories on the new server. You may change the file names if you want, but you must edit the controlfile to reflect the new data files names on the new server.
rcp /u01/oradata/oldlsq/* newhost:/u01/oradata/newlsq
rcp /u01/oradata/oldlsq/* newhost:/u01/oradata/newlsq
rcp /u03/oradata/oldlsq/* newhost:/u03/oradata/newlsq
rcp /u04/oradata/oldlsq/* newhost:/u04/oradata/newlsq
STEP 4: Copy and Edit the Control file – Using the output syntax from STEP 1, modify the controlfile creation script by changing the following:
Old:
CREATE CONTROLFILE REUSE DATABASE "OLDLSQ" NORESETLOGS
New:
CREATE CONTROLFILE SET DATABASE "NEWLSQ" RESETLOGS
STEP 5: Remove the “recover database” and “alter database open” syntax
# Recovery is required if any of the datafiles are restored
# backups, or if the last shutdown was not normal or immediate.
RECOVER DATABASE
# Database can now be opened normally.
ALTER DATABASE OPEN;
STEP 6: Re-names of the data files names that have changed.
Save as db_create_controlfile.sql.
Old:
DATAFILE
'/u01/oradata/oldlsq/system01.dbf',
'/u01/oradata/oldlsq/mydatabase.dbf'
New:
DATAFILE
'/u01/oradata/newlsq/system01.dbf',
'/u01/oradata/newlsq/mydatabase.dbf'
STEP 7: Create the bdump, udump and cdump directories
cd $DBA/admin
mkdir newlsq
cd newlsq
mkdir bdump
mkdir udump
mkdir cdump
mkdir pfile
STEP 8: Copy-over the old init.ora file
rcp $DBA/admin/olslsq/pfile/*.ora newhost:/u01/oracle/admin/newlsq/pfile
STEP 9: Start the new database
@db_create_controlfile.sql
alter database open resetlogs;
STEP 10: Place the new database in archivelog mode
热克隆过程:Duplicate Database
http://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmdupdb.htm#BGBHJDEJ

上面4种方式可以热克隆数据库。
例子1-使用Duplicate Backups without target connect and recovery catalog connection方式。
源 库:Linux 5.5 x86-64 + Oracle 11.2.3 RAC (2节点) DBNAME=prod
目标库:Linux 5.5 x86-64 + Oracle 11.2.3 Single DBNAME=TEST
1,创建新库需要的audit目录,数据文件目录,trace文件目录,闪回恢复目录等。
2,创建密码文件,保持和源库完全一样。orapwd file=orapwTEST password=amaxgs
3,创建pfile,initTEST.ora,启动数据库,并创建spfile,重启数据库从spfile启动。
4,利用下面的Duplicate,注意BACKUP LOCATION路径最后必须有“/”,必须为‘/u01/’,否则‘/u01’会报错,找不到SPFILE或者CONTROLFILE等。
run{
SET NEWNAME FOR DATABASE TO '/prod/oracle/oradata/TEST/%b';
SET NEWNAME FOR TEMPFILE 1 TO '/prod/oracle/oradata/TEST/%b';
DUPLICATE DATABASE TO 'TEST' BACKUP LOCATION '/u01/';
}