1.查看主库ZDJS并使用RMAM进行备份
[oracle@std ~]$ sqlplus '/as sysdba'SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 14 14:13:14 2015Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to an idle instance.SQL> startupORACLE instance started.Total System Global Area 608174080 bytesFixed Size 1220820 bytesVariable Size 159387436 bytesDatabase Buffers 440401920 bytesRedo Buffers 7163904 bytesDatabase mounted.Database opened.
SQL> show parameter nameNAME TYPE VALUE------------------------------------ ----------- ------------------------------db_file_name_convert stringdb_name string ZDJSdb_unique_name string ZDJSglobal_names boolean FALSEinstance_name string ZDJSlock_name_space stringlog_file_name_convert stringservice_names string ZDJS
[oracle@std ~]$ rman target /Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 14 14:26:58 2015Copyright (c) 1982, 2005, Oracle. All rights reserved.connected to target database: ZDJS (DBID=3486931402)RMAN> run {2> allocate channel c1 type disk;3> allocate channel c2 type disk;4> backup full database format '/u01/rman_bak/%d_%s_%t.bak'; 5> backup archivelog all format '/u01/rman_bak/arch_%s.bak';6> backup current controlfile format '/u01/rman_bak/ctl_%s.bak';7> }using target database control file instead of recovery catalogallocated channel: c1channel c1: sid=143 devtype=DISKallocated channel: c2channel c2: sid=142 devtype=DISKStarting backup at 14-JAN-15channel c1: starting full datafile backupsetchannel c1: specifying datafile(s) in backupsetinput datafile fno=00001 name=/u02/app/oradata/ZDJS/system01.dbfinput datafile fno=00006 name=/u02/app/oradata/ZDJS/plat01.dbfinput datafile fno=00008 name=/u02/app/oradata/ZDJS/rlsm01.dbfinput datafile fno=00002 name=/u02/app/oradata/ZDJS/undotbs01.dbfinput datafile fno=00004 name=/u02/app/oradata/ZDJS/users01.dbfchannel c1: starting piece 1 at 14-JAN-15channel c2: starting full datafile backupsetchannel c2: specifying datafile(s) in backupsetinput datafile fno=00003 name=/u02/app/oradata/ZDJS/sysaux01.dbfinput datafile fno=00010 name=/u02/app/oradata/ZDJS/qhrlst01.dbfinput datafile fno=00005 name=/u02/app/oradata/ZDJS/example01.dbfinput datafile fno=00007 name=/u02/app/oradata/ZDJS/rlst01.dbfinput datafile fno=00009 name=/u02/app/oradata/ZDJS/rlsc01.dbfchannel c2: starting piece 1 at 14-JAN-15channel c1: finished piece 1 at 14-JAN-15piece handle=/u01/rman_bak/ZDJS_6_868976951.bak tag=TAG20150114T142911 comment=NONEchannel c1: backup set complete, elapsed time: 00:01:07channel c1: starting full datafile backupsetchannel c1: specifying datafile(s) in backupsetincluding current control file in backupsetchannel c1: starting piece 1 at 14-JAN-15channel c1: finished piece 1 at 14-JAN-15piece handle=/u01/rman_bak/ZDJS_8_868977018.bak tag=TAG20150114T142911 comment=NONEchannel c1: backup set complete, elapsed time: 00:00:03channel c1: starting full datafile backupsetchannel c1: specifying datafile(s) in backupsetincluding current SPFILE in backupsetchannel c1: starting piece 1 at 14-JAN-15channel c1: finished piece 1 at 14-JAN-15piece handle=/u01/rman_bak/ZDJS_9_868977021.bak tag=TAG20150114T142911 comment=NONEchannel c1: backup set complete, elapsed time: 00:00:02channel c2: finished piece 1 at 14-JAN-15piece handle=/u01/rman_bak/ZDJS_7_868976952.bak tag=TAG20150114T142911 comment=NONEchannel c2: backup set complete, elapsed time: 00:01:18Finished backup at 14-JAN-15Starting backup at 14-JAN-15current log archivedchannel c1: starting archive log backupsetchannel c1: specifying archive log(s) in backup setinput archive log thread=1 sequence=49 recid=1 stamp=868977033channel c1: starting piece 1 at 14-JAN-15channel c1: finished piece 1 at 14-JAN-15piece handle=/u01/rman_bak/arch_10.bak tag=TAG20150114T143033 comment=NONEchannel c1: backup set complete, elapsed time: 00:00:03Finished backup at 14-JAN-15Starting backup at 14-JAN-15channel c1: starting full datafile backupsetchannel c1: specifying datafile(s) in backupsetincluding current control file in backupsetchannel c1: starting piece 1 at 14-JAN-15channel c1: finished piece 1 at 14-JAN-15piece handle=/u01/rman_bak/ctl_11.bak tag=TAG20150114T143038 comment=NONEchannel c1: backup set complete, elapsed time: 00:00:02Finished backup at 14-JAN-15released channel: c1released channel: c2
SQL> col file_name for a50SQL> select file_id,file_name,tablespace_name from dba_data_files; FILE_ID FILE_NAME TABLESPACE_NAME---------- -------------------------------------------------- ------------------------------ 4 /u02/app/oradata/ZDJS/users01.dbf USERS 3 /u02/app/oradata/ZDJS/sysaux01.dbf SYSAUX 2 /u02/app/oradata/ZDJS/undotbs01.dbf UNDOTBS1 1 /u02/app/oradata/ZDJS/system01.dbf SYSTEM 5 /u02/app/oradata/ZDJS/example01.dbf EXAMPLE 6 /u02/app/oradata/ZDJS/plat01.dbf PLAT 7 /u02/app/oradata/ZDJS/rlst01.dbf RLST 8 /u02/app/oradata/ZDJS/rlsm01.dbf RLSM 9 /u02/app/oradata/ZDJS/rlsc01.dbf RLSC 10 /u02/app/oradata/ZDJS/qhrlst01.dbf QHRLST10 rows selected.
SQL> create pfile from spfile;File created.
3.建立克隆库的目录
[oracle@std oradata]$ mkdir -p $ORACLE_BASE/admin/clonedb/{a,b,c,u}dump[oracle@std oradata]$ mkdir -p $ORACLE_BASE/oradata/clonedb/
4.将主库pfile拷贝生成克隆库的pfile,并生成克隆库的口令文件
##红字部分是修改的部分,蓝字部分是需要增加的
[oracle@std dbs]$ cp initZDJS.ora initclonedb.ora[oracle@std dbs]$ vi initclonedb.ora [oracle@std dbs]$ cat initclonedb.ora *.audit_file_dest='/u02/app/admin/clonedb/adump'*.background_dump_dest='/u02/app/admin/clonedb/bdump'*.compatible='10.2.0.1.0'*.control_files='/u02/app/oradata/clonedb/control01.ctl','/u02/app/oradata/clonedb/control02.ctl','/u02/app/oradata/clonedb/control03.ctl'*.core_dump_dest='/u02/app/admin/clonedb/cdump'*.db_block_size=8192*.db_domain=''*.db_file_multiblock_read_count=16*.db_name='clonedb'*.dispatchers='(PROTOCOL=TCP) (SERVICE=ZDJSXDB)'*.job_queue_processes=10*.log_archive_dest_1='location=/u01/clonedb_arch'*.open_cursors=300*.pga_aggregate_target=201326592*.processes=150*.remote_login_passwordfile='EXCLUSIVE'*.sga_target=605028352*.undo_management='AUTO'*.undo_tablespace='UNDOTBS1'*.user_dump_dest='/u02/app/admin/clonedb/udump'db_file_name_convert=("/u02/app/oradata/ZDJS","/u02/app/oradata/clonedb")log_file_name_convert=("/u02/app/oradata/ZDJS","/u02/app/oradata/clonedb")
[oracle@std dbs]$ orapwd file=orapwclonedb password=oracle [oracle@std dbs]$ lshc_clonedb.dat hc_PROD.dat hc_ZDJS.dat initclonedb.ora initZDJS.ora lkZDJS orapwclonedb orapwZDJS snapcf_ZDJS.f spfileZDJS.ora
5.将克隆库启动到nomount状态
[oracle@std dbs]$ export ORACLE_SID=clonedb[oracle@std dbs]$ sqlplus '/as sysdba'SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 14 15:02:30 2015Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to an idle instance.SQL> startup nomountORACLE instance started.Total System Global Area 608174080 bytesFixed Size 1220820 bytesVariable Size 163581740 bytesDatabase Buffers 436207616 bytesRedo Buffers 7163904 bytes
SQL> show parameter nameNAME TYPE VALUE------------------------------------ ----------- ------------------------------db_file_name_convert string /u02/app/oradata/ZDJS, /u02/ap p/oradata/clonedbdb_name string clonedbdb_unique_name string clonedbglobal_names boolean FALSEinstance_name string clonedblock_name_space stringlog_file_name_convert string /u02/app/oradata/ZDJS, /u02/ap p/oradata/clonedbservice_names string clonedb
6.对主库的日志进行归档,并将归档日志拷贝到克隆库的归档目录下
[oracle@std dbs]$ export ORACLE_SID=ZDJS[oracle@std dbs]$ sqlplus '/as sysdba'SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 14 15:06:09 2015Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, Oracle Label Security, OLAP and Data Mining optionsSQL> select group#,sequence#,status from v$log; GROUP# SEQUENCE# STATUS---------- ---------- ---------------- 1 50 CURRENT 2 48 INACTIVE 3 49 INACTIVE SQL> alter system archive log current;System altered.SQL> select group#,sequence#,status from v$log; GROUP# SEQUENCE# STATUS---------- ---------- ---------------- 1 50 ACTIVE 2 51 CURRENT 3 49 INACTIVE
[oracle@std dbs]$ cd /u01/ZDJS_ARCH/[oracle@std ZDJS_ARCH]$ ls1_49_854875280.dbf 1_50_854875280.dbf[oracle@std ZDJS_ARCH]$ cp * ../clonedb_arch/[oracle@std ZDJS_ARCH]$ ll ../clonedb_arch/total 26216-rw-r----- 1 oracle oinstall 19859456 Jan 14 15:09 1_49_854875280.dbf-rw-r----- 1 oracle oinstall 6945792 Jan 14 15:09 1_50_854875280.dbf
7.使用rman连接主库和clone库
[oracle@std admin]$ cat tnsnames.ora # tnsnames.ora Network Configuration File: /u02/app/product/10.2.0/db_1/network/admin/tnsnames.ora# Generated by Oracle configuration tools.EXTPROC_CONNECTION_DATA = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) ) (CONNECT_DATA = (SID = PLSExtProc) (PRESENTATION = RO) ) )ZDJS=(DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=std)(PORT=1521)) (CONNECT_DATA= (SERVICE_NAME=ZDJS) ) )
[oracle@std admin]$ export ORACLE_SID=clonedb[oracle@std admin]$ target sys/oracle@zdjs auxiliary sys/oracle-bash: target: command not found[oracle@std admin]$ rman target sys/oracle@zdjs auxiliary sys/oracleRecovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 14 15:18:47 2015Copyright (c) 1982, 2005, Oracle. All rights reserved.connected to target database: ZDJS (DBID=3486931402)connected to auxiliary database: CLONEDB (not mounted)RMAN> list backup;using target database control file instead of recovery catalogList of Backup Sets===================BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------1 Full 6.77M DISK 00:00:02 14-JAN-15 BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20150114T142445 Piece Name: /u01/rman_bak/ZDJS_3_868976686.bak Control File Included: Ckp SCN: 1756176 Ckp time: 14-JAN-15BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------2 Full 80.00K DISK 00:00:00 14-JAN-15 BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20150114T142445 Piece Name: /u01/rman_bak/ZDJS_5_868976688.bak SPFILE Included: Modification time: 14-JAN-15BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------3 Full 514.59M DISK 00:01:00 14-JAN-15 BP Key: 3 Status: AVAILABLE Compressed: NO Tag: TAG20150114T142911 Piece Name: /u01/rman_bak/ZDJS_6_868976951.bak List of Datafiles in backup set 3 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 Full 1756642 14-JAN-15 /u02/app/oradata/ZDJS/system01.dbf 2 Full 1756642 14-JAN-15 /u02/app/oradata/ZDJS/undotbs01.dbf 4 Full 1756642 14-JAN-15 /u02/app/oradata/ZDJS/users01.dbf 6 Full 1756642 14-JAN-15 /u02/app/oradata/ZDJS/plat01.dbf 8 Full 1756642 14-JAN-15 /u02/app/oradata/ZDJS/rlsm01.dbfBS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------4 Full 6.77M DISK 00:00:02 14-JAN-15 BP Key: 4 Status: AVAILABLE Compressed: NO Tag: TAG20150114T142911 Piece Name: /u01/rman_bak/ZDJS_8_868977018.bak Control File Included: Ckp SCN: 1756665 Ckp time: 14-JAN-15BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------5 Full 80.00K DISK 00:00:02 14-JAN-15 BP Key: 5 Status: AVAILABLE Compressed: NO Tag: TAG20150114T142911 Piece Name: /u01/rman_bak/ZDJS_9_868977021.bak SPFILE Included: Modification time: 14-JAN-15BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------6 Full 453.63M DISK 00:01:17 14-JAN-15 BP Key: 6 Status: AVAILABLE Compressed: NO Tag: TAG20150114T142911 Piece Name: /u01/rman_bak/ZDJS_7_868976952.bak List of Datafiles in backup set 6 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 3 Full 1756644 14-JAN-15 /u02/app/oradata/ZDJS/sysaux01.dbf 5 Full 1756644 14-JAN-15 /u02/app/oradata/ZDJS/example01.dbf 7 Full 1756644 14-JAN-15 /u02/app/oradata/ZDJS/rlst01.dbf 9 Full 1756644 14-JAN-15 /u02/app/oradata/ZDJS/rlsc01.dbf 10 Full 1756644 14-JAN-15 /u02/app/oradata/ZDJS/qhrlst01.dbfBS Key Size Device Type Elapsed Time Completion Time------- ---------- ----------- ------------ ---------------7 18.94M DISK 00:00:02 14-JAN-15 BP Key: 7 Status: AVAILABLE Compressed: NO Tag: TAG20150114T143033 Piece Name: /u01/rman_bak/arch_10.bak List of Archived Logs in backup set 7 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- --------- ---------- --------- 1 49 1750460 19-DEC-14 1756675 14-JAN-15BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------8 Full 6.77M DISK 00:00:02 14-JAN-15 BP Key: 8 Status: AVAILABLE Compressed: NO Tag: TAG20150114T143038 Piece Name: /u01/rman_bak/ctl_11.bak Control File Included: Ckp SCN: 1756683 Ckp time: 14-JAN-15
8.使用rman命令克隆数据库
RMAN> duplicate target database to clonedb;Starting Duplicate Db at 14-JAN-15allocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: sid=156 devtype=DISKcontents of Memory Script:{ set until scn 1758326; set newname for datafile 1 to "/u02/app/oradata/clonedb/system01.dbf"; set newname for datafile 2 to "/u02/app/oradata/clonedb/undotbs01.dbf"; set newname for datafile 3 to "/u02/app/oradata/clonedb/sysaux01.dbf"; set newname for datafile 4 to "/u02/app/oradata/clonedb/users01.dbf"; set newname for datafile 5 to "/u02/app/oradata/clonedb/example01.dbf"; set newname for datafile 6 to "/u02/app/oradata/clonedb/plat01.dbf"; set newname for datafile 7 to "/u02/app/oradata/clonedb/rlst01.dbf"; set newname for datafile 8 to "/u02/app/oradata/clonedb/rlsm01.dbf"; set newname for datafile 9 to "/u02/app/oradata/clonedb/rlsc01.dbf"; set newname for datafile 10 to "/u02/app/oradata/clonedb/qhrlst01.dbf"; restore check readonly clone database ;}executing Memory Scriptexecuting command: SET until clauseexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEStarting restore at 14-JAN-15using channel ORA_AUX_DISK_1channel ORA_AUX_DISK_1: starting datafile backupset restorechannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setrestoring datafile 00001 to /u02/app/oradata/clonedb/system01.dbfrestoring datafile 00002 to /u02/app/oradata/clonedb/undotbs01.dbfrestoring datafile 00004 to /u02/app/oradata/clonedb/users01.dbfrestoring datafile 00006 to /u02/app/oradata/clonedb/plat01.dbfrestoring datafile 00008 to /u02/app/oradata/clonedb/rlsm01.dbfchannel ORA_AUX_DISK_1: reading from backup piece /u01/rman_bak/ZDJS_6_868976951.bakchannel ORA_AUX_DISK_1: restored backup piece 1piece handle=/u01/rman_bak/ZDJS_6_868976951.bak tag=TAG20150114T142911channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:47channel ORA_AUX_DISK_1: starting datafile backupset restorechannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setrestoring datafile 00003 to /u02/app/oradata/clonedb/sysaux01.dbfrestoring datafile 00005 to /u02/app/oradata/clonedb/example01.dbfrestoring datafile 00007 to /u02/app/oradata/clonedb/rlst01.dbfrestoring datafile 00009 to /u02/app/oradata/clonedb/rlsc01.dbfrestoring datafile 00010 to /u02/app/oradata/clonedb/qhrlst01.dbfchannel ORA_AUX_DISK_1: reading from backup piece /u01/rman_bak/ZDJS_7_868976952.bakchannel ORA_AUX_DISK_1: restored backup piece 1piece handle=/u01/rman_bak/ZDJS_7_868976952.bak tag=TAG20150114T142911channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45Finished restore at 14-JAN-15sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONEDB" RESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 ( '/u02/app/oradata/clonedb/redo01.log' ) SIZE 50 M REUSE, GROUP 2 ( '/u02/app/oradata/clonedb/redo02.log' ) SIZE 50 M REUSE, GROUP 3 ( '/u02/app/oradata/clonedb/redo03.log' ) SIZE 50 M REUSE DATAFILE '/u02/app/oradata/clonedb/system01.dbf' CHARACTER SET ZHS16GBKcontents of Memory Script:{ switch clone datafile all;}executing Memory Scriptreleased channel: ORA_AUX_DISK_1datafile 2 switched to datafile copyinput datafile copy recid=1 stamp=868980188 filename=/u02/app/oradata/clonedb/undotbs01.dbfdatafile 3 switched to datafile copyinput datafile copy recid=2 stamp=868980188 filename=/u02/app/oradata/clonedb/sysaux01.dbfdatafile 4 switched to datafile copyinput datafile copy recid=3 stamp=868980188 filename=/u02/app/oradata/clonedb/users01.dbfdatafile 5 switched to datafile copyinput datafile copy recid=4 stamp=868980188 filename=/u02/app/oradata/clonedb/example01.dbfdatafile 6 switched to datafile copyinput datafile copy recid=5 stamp=868980188 filename=/u02/app/oradata/clonedb/plat01.dbfdatafile 7 switched to datafile copyinput datafile copy recid=6 stamp=868980189 filename=/u02/app/oradata/clonedb/rlst01.dbfdatafile 8 switched to datafile copyinput datafile copy recid=7 stamp=868980189 filename=/u02/app/oradata/clonedb/rlsm01.dbfdatafile 9 switched to datafile copyinput datafile copy recid=8 stamp=868980189 filename=/u02/app/oradata/clonedb/rlsc01.dbfdatafile 10 switched to datafile copyinput datafile copy recid=9 stamp=868980189 filename=/u02/app/oradata/clonedb/qhrlst01.dbfcontents of Memory Script:{ set until scn 1758326; recover clone database delete archivelog ;}executing Memory Scriptexecuting command: SET until clauseStarting recover at 14-JAN-15allocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: sid=156 devtype=DISKstarting media recoveryarchive log thread 1 sequence 49 is already on disk as file /u01/ZDJS_ARCH/1_49_854875280.dbfarchive log thread 1 sequence 50 is already on disk as file /u01/ZDJS_ARCH/1_50_854875280.dbfarchive log filename=/u01/ZDJS_ARCH/1_49_854875280.dbf thread=1 sequence=49archive log filename=/u01/ZDJS_ARCH/1_50_854875280.dbf thread=1 sequence=50media recovery complete, elapsed time: 00:00:11Finished recover at 14-JAN-15contents of Memory Script:{ shutdown clone; startup clone nomount ;}executing Memory Scriptdatabase dismountedOracle instance shut downconnected to auxiliary database (not started)Oracle instance startedTotal System Global Area 608174080 bytesFixed Size 1220820 bytesVariable Size 163581740 bytesDatabase Buffers 436207616 bytesRedo Buffers 7163904 bytessql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONEDB" RESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 ( '/u02/app/oradata/clonedb/redo01.log' ) SIZE 50 M REUSE, GROUP 2 ( '/u02/app/oradata/clonedb/redo02.log' ) SIZE 50 M REUSE, GROUP 3 ( '/u02/app/oradata/clonedb/redo03.log' ) SIZE 50 M REUSE DATAFILE '/u02/app/oradata/clonedb/system01.dbf' CHARACTER SET ZHS16GBKcontents of Memory Script:{ set newname for tempfile 1 to "/u02/app/oradata/clonedb/temp01.dbf"; switch clone tempfile all; catalog clone datafilecopy "/u02/app/oradata/clonedb/undotbs01.dbf"; catalog clone datafilecopy "/u02/app/oradata/clonedb/sysaux01.dbf"; catalog clone datafilecopy "/u02/app/oradata/clonedb/users01.dbf"; catalog clone datafilecopy "/u02/app/oradata/clonedb/example01.dbf"; catalog clone datafilecopy "/u02/app/oradata/clonedb/plat01.dbf"; catalog clone datafilecopy "/u02/app/oradata/clonedb/rlst01.dbf"; catalog clone datafilecopy "/u02/app/oradata/clonedb/rlsm01.dbf"; catalog clone datafilecopy "/u02/app/oradata/clonedb/rlsc01.dbf"; catalog clone datafilecopy "/u02/app/oradata/clonedb/qhrlst01.dbf"; switch clone datafile all;}executing Memory Scriptexecuting command: SET NEWNAMErenamed temporary file 1 to /u02/app/oradata/clonedb/temp01.dbf in control filecataloged datafile copydatafile copy filename=/u02/app/oradata/clonedb/undotbs01.dbf recid=1 stamp=868980219cataloged datafile copydatafile copy filename=/u02/app/oradata/clonedb/sysaux01.dbf recid=2 stamp=868980220cataloged datafile copydatafile copy filename=/u02/app/oradata/clonedb/users01.dbf recid=3 stamp=868980221cataloged datafile copydatafile copy filename=/u02/app/oradata/clonedb/example01.dbf recid=4 stamp=868980221cataloged datafile copydatafile copy filename=/u02/app/oradata/clonedb/plat01.dbf recid=5 stamp=868980222cataloged datafile copydatafile copy filename=/u02/app/oradata/clonedb/rlst01.dbf recid=6 stamp=868980223cataloged datafile copydatafile copy filename=/u02/app/oradata/clonedb/rlsm01.dbf recid=7 stamp=868980224cataloged datafile copydatafile copy filename=/u02/app/oradata/clonedb/rlsc01.dbf recid=8 stamp=868980224cataloged datafile copydatafile copy filename=/u02/app/oradata/clonedb/qhrlst01.dbf recid=9 stamp=868980225datafile 2 switched to datafile copyinput datafile copy recid=1 stamp=868980219 filename=/u02/app/oradata/clonedb/undotbs01.dbfdatafile 3 switched to datafile copyinput datafile copy recid=2 stamp=868980220 filename=/u02/app/oradata/clonedb/sysaux01.dbfdatafile 4 switched to datafile copyinput datafile copy recid=3 stamp=868980221 filename=/u02/app/oradata/clonedb/users01.dbfdatafile 5 switched to datafile copyinput datafile copy recid=4 stamp=868980221 filename=/u02/app/oradata/clonedb/example01.dbfdatafile 6 switched to datafile copyinput datafile copy recid=5 stamp=868980222 filename=/u02/app/oradata/clonedb/plat01.dbfdatafile 7 switched to datafile copyinput datafile copy recid=6 stamp=868980223 filename=/u02/app/oradata/clonedb/rlst01.dbfdatafile 8 switched to datafile copyinput datafile copy recid=7 stamp=868980224 filename=/u02/app/oradata/clonedb/rlsm01.dbfdatafile 9 switched to datafile copyinput datafile copy recid=8 stamp=868980224 filename=/u02/app/oradata/clonedb/rlsc01.dbfdatafile 10 switched to datafile copyinput datafile copy recid=9 stamp=868980225 filename=/u02/app/oradata/clonedb/qhrlst01.dbfcontents of Memory Script:{ Alter clone database open resetlogs;}executing Memory Scriptdatabase openedFinished Duplicate Db at 14-JAN-15
9.打开克隆库,确认克隆成功
[oracle@std admin]$ sqlplus '/as sysdba'SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 14 15:25:33 2015Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, Oracle Label Security, OLAP and Data Mining optionsSQL> select status from v$instance;STATUS------------OPENSQL> select name from v$datafile;NAME--------------------------------------------------------------------------------/u02/app/oradata/clonedb/system01.dbf/u02/app/oradata/clonedb/undotbs01.dbf/u02/app/oradata/clonedb/sysaux01.dbf/u02/app/oradata/clonedb/users01.dbf/u02/app/oradata/clonedb/example01.dbf/u02/app/oradata/clonedb/plat01.dbf/u02/app/oradata/clonedb/rlst01.dbf/u02/app/oradata/clonedb/rlsm01.dbf/u02/app/oradata/clonedb/rlsc01.dbf/u02/app/oradata/clonedb/qhrlst01.dbf10 rows selected.SQL> select group#,sequence#,status from v$log; GROUP# SEQUENCE# STATUS---------- ---------- ---------------- 1 0 UNUSED 2 0 UNUSED 3 1 CURRENTSQL> alter system switch logfile;System altered.SQL> /System altered.SQL> /System altered.SQL> select group#,sequence#,status from v$log; GROUP# SEQUENCE# STATUS---------- ---------- ---------------- 1 2 INACTIVE 2 3 ACTIVE 3 4 CURRENT
SQL> show parameter nameNAME TYPE VALUE------------------------------------ ----------- ------------------------------db_file_name_convert string /u02/app/oradata/ZDJS, /u02/ap p/oradata/clonedbdb_name string clonedbdb_unique_name string clonedbglobal_names boolean FALSEinstance_name string clonedblock_name_space stringlog_file_name_convert string /u02/app/oradata/ZDJS, /u02/ap p/oradata/clonedbservice_names string clonedb