示例在同一台机器上使用RMAN克隆数据库

1.查看主库ZDJS并使用RMAM进行备份

[oracle@std ~]$ sqlplus '/as sysdba'

SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 14 14:13:14 2015

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  608174080 bytes
Fixed Size                  1220820 bytes
Variable Size             159387436 bytes
Database Buffers          440401920 bytes
Redo Buffers                7163904 bytes
Database mounted.
Database opened.
SQL> show parameter name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string
db_name                              string      ZDJS
db_unique_name                       string      ZDJS
global_names                         boolean     FALSE
instance_name                        string      ZDJS
lock_name_space                      string
log_file_name_convert                string
service_names                        string      ZDJS
[oracle@std ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 14 14:26:58 2015

Copyright (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 catalog
allocated channel: c1
channel c1: sid=143 devtype=DISK

allocated channel: c2
channel c2: sid=142 devtype=DISK

Starting backup at 14-JAN-15
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u02/app/oradata/ZDJS/system01.dbf
input datafile fno=00006 name=/u02/app/oradata/ZDJS/plat01.dbf
input datafile fno=00008 name=/u02/app/oradata/ZDJS/rlsm01.dbf
input datafile fno=00002 name=/u02/app/oradata/ZDJS/undotbs01.dbf
input datafile fno=00004 name=/u02/app/oradata/ZDJS/users01.dbf
channel c1: starting piece 1 at 14-JAN-15
channel c2: starting full datafile backupset
channel c2: specifying datafile(s) in backupset
input datafile fno=00003 name=/u02/app/oradata/ZDJS/sysaux01.dbf
input datafile fno=00010 name=/u02/app/oradata/ZDJS/qhrlst01.dbf
input datafile fno=00005 name=/u02/app/oradata/ZDJS/example01.dbf
input datafile fno=00007 name=/u02/app/oradata/ZDJS/rlst01.dbf
input datafile fno=00009 name=/u02/app/oradata/ZDJS/rlsc01.dbf
channel c2: starting piece 1 at 14-JAN-15
channel c1: finished piece 1 at 14-JAN-15
piece handle=/u01/rman_bak/ZDJS_6_868976951.bak tag=TAG20150114T142911 comment=NONE
channel c1: backup set complete, elapsed time: 00:01:07
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
including current control file in backupset
channel c1: starting piece 1 at 14-JAN-15
channel c1: finished piece 1 at 14-JAN-15
piece handle=/u01/rman_bak/ZDJS_8_868977018.bak tag=TAG20150114T142911 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:03
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel c1: starting piece 1 at 14-JAN-15
channel c1: finished piece 1 at 14-JAN-15
piece handle=/u01/rman_bak/ZDJS_9_868977021.bak tag=TAG20150114T142911 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:02
channel c2: finished piece 1 at 14-JAN-15
piece handle=/u01/rman_bak/ZDJS_7_868976952.bak tag=TAG20150114T142911 comment=NONE
channel c2: backup set complete, elapsed time: 00:01:18
Finished backup at 14-JAN-15

Starting backup at 14-JAN-15
current log archived
channel c1: starting archive log backupset
channel c1: specifying archive log(s) in backup set
input archive log thread=1 sequence=49 recid=1 stamp=868977033
channel c1: starting piece 1 at 14-JAN-15
channel c1: finished piece 1 at 14-JAN-15
piece handle=/u01/rman_bak/arch_10.bak tag=TAG20150114T143033 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:03
Finished backup at 14-JAN-15

Starting backup at 14-JAN-15
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
including current control file in backupset
channel c1: starting piece 1 at 14-JAN-15
channel c1: finished piece 1 at 14-JAN-15
piece handle=/u01/rman_bak/ctl_11.bak tag=TAG20150114T143038 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:02
Finished backup at 14-JAN-15
released channel: c1
released channel: c2
SQL> col file_name for a50
SQL> 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                 QHRLST

10 rows selected.


2.建立pfile文件

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]$ ls
hc_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 2015

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area  608174080 bytes
Fixed Size                  1220820 bytes
Variable Size             163581740 bytes
Database Buffers          436207616 bytes
Redo Buffers                7163904 bytes
SQL> show parameter name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string      /u02/app/oradata/ZDJS, /u02/ap
                                                 p/oradata/clonedb
db_name                              string      clonedb
db_unique_name                       string      clonedb
global_names                         boolean     FALSE
instance_name                        string      clonedb
lock_name_space                      string
log_file_name_convert                string      /u02/app/oradata/ZDJS, /u02/ap
                                                 p/oradata/clonedb
service_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 2015

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining options


SQL> 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]$ ls
1_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/oracle

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Jan 14 15:18:47 2015

Copyright (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 catalog

List 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-15

BS 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-15

BS 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.dbf

BS 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-15

BS 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-15

BS 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.dbf

BS 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-15

BS 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-15
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=156 devtype=DISK

contents 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 Script

executing command: SET until clause

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 14-JAN-15
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u02/app/oradata/clonedb/system01.dbf
restoring datafile 00002 to /u02/app/oradata/clonedb/undotbs01.dbf
restoring datafile 00004 to /u02/app/oradata/clonedb/users01.dbf
restoring datafile 00006 to /u02/app/oradata/clonedb/plat01.dbf
restoring datafile 00008 to /u02/app/oradata/clonedb/rlsm01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman_bak/ZDJS_6_868976951.bak
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/rman_bak/ZDJS_6_868976951.bak tag=TAG20150114T142911
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:47
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00003 to /u02/app/oradata/clonedb/sysaux01.dbf
restoring datafile 00005 to /u02/app/oradata/clonedb/example01.dbf
restoring datafile 00007 to /u02/app/oradata/clonedb/rlst01.dbf
restoring datafile 00009 to /u02/app/oradata/clonedb/rlsc01.dbf
restoring datafile 00010 to /u02/app/oradata/clonedb/qhrlst01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/rman_bak/ZDJS_7_868976952.bak
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u01/rman_bak/ZDJS_7_868976952.bak tag=TAG20150114T142911
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 14-JAN-15
sql 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 ZHS16GBK


contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

released channel: ORA_AUX_DISK_1
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=868980188 filename=/u02/app/oradata/clonedb/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=868980188 filename=/u02/app/oradata/clonedb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=868980188 filename=/u02/app/oradata/clonedb/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=868980188 filename=/u02/app/oradata/clonedb/example01.dbf
datafile 6 switched to datafile copy
input datafile copy recid=5 stamp=868980188 filename=/u02/app/oradata/clonedb/plat01.dbf
datafile 7 switched to datafile copy
input datafile copy recid=6 stamp=868980189 filename=/u02/app/oradata/clonedb/rlst01.dbf
datafile 8 switched to datafile copy
input datafile copy recid=7 stamp=868980189 filename=/u02/app/oradata/clonedb/rlsm01.dbf
datafile 9 switched to datafile copy
input datafile copy recid=8 stamp=868980189 filename=/u02/app/oradata/clonedb/rlsc01.dbf
datafile 10 switched to datafile copy
input datafile copy recid=9 stamp=868980189 filename=/u02/app/oradata/clonedb/qhrlst01.dbf

contents of Memory Script:
{
   set until scn  1758326;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 14-JAN-15
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=156 devtype=DISK

starting media recovery

archive log thread 1 sequence 49 is already on disk as file /u01/ZDJS_ARCH/1_49_854875280.dbf
archive log thread 1 sequence 50 is already on disk as file /u01/ZDJS_ARCH/1_50_854875280.dbf
archive log filename=/u01/ZDJS_ARCH/1_49_854875280.dbf thread=1 sequence=49
archive log filename=/u01/ZDJS_ARCH/1_50_854875280.dbf thread=1 sequence=50
media recovery complete, elapsed time: 00:00:11
Finished recover at 14-JAN-15

contents of Memory Script:
{
   shutdown clone;
   startup clone nomount ;
}
executing Memory Script

database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     608174080 bytes

Fixed Size                     1220820 bytes
Variable Size                163581740 bytes
Database Buffers             436207616 bytes
Redo Buffers                   7163904 bytes
sql 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 ZHS16GBK


contents 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 Script

executing command: SET NEWNAME

renamed temporary file 1 to /u02/app/oradata/clonedb/temp01.dbf in control file

cataloged datafile copy
datafile copy filename=/u02/app/oradata/clonedb/undotbs01.dbf recid=1 stamp=868980219

cataloged datafile copy
datafile copy filename=/u02/app/oradata/clonedb/sysaux01.dbf recid=2 stamp=868980220

cataloged datafile copy
datafile copy filename=/u02/app/oradata/clonedb/users01.dbf recid=3 stamp=868980221

cataloged datafile copy
datafile copy filename=/u02/app/oradata/clonedb/example01.dbf recid=4 stamp=868980221

cataloged datafile copy
datafile copy filename=/u02/app/oradata/clonedb/plat01.dbf recid=5 stamp=868980222

cataloged datafile copy
datafile copy filename=/u02/app/oradata/clonedb/rlst01.dbf recid=6 stamp=868980223

cataloged datafile copy
datafile copy filename=/u02/app/oradata/clonedb/rlsm01.dbf recid=7 stamp=868980224

cataloged datafile copy
datafile copy filename=/u02/app/oradata/clonedb/rlsc01.dbf recid=8 stamp=868980224

cataloged datafile copy
datafile copy filename=/u02/app/oradata/clonedb/qhrlst01.dbf recid=9 stamp=868980225

datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=868980219 filename=/u02/app/oradata/clonedb/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=868980220 filename=/u02/app/oradata/clonedb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=868980221 filename=/u02/app/oradata/clonedb/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=868980221 filename=/u02/app/oradata/clonedb/example01.dbf
datafile 6 switched to datafile copy
input datafile copy recid=5 stamp=868980222 filename=/u02/app/oradata/clonedb/plat01.dbf
datafile 7 switched to datafile copy
input datafile copy recid=6 stamp=868980223 filename=/u02/app/oradata/clonedb/rlst01.dbf
datafile 8 switched to datafile copy
input datafile copy recid=7 stamp=868980224 filename=/u02/app/oradata/clonedb/rlsm01.dbf
datafile 9 switched to datafile copy
input datafile copy recid=8 stamp=868980224 filename=/u02/app/oradata/clonedb/rlsc01.dbf
datafile 10 switched to datafile copy
input datafile copy recid=9 stamp=868980225 filename=/u02/app/oradata/clonedb/qhrlst01.dbf

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished 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 2015

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining options

SQL> select status from v$instance;

STATUS
------------
OPEN

SQL> 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.dbf

10 rows selected.

SQL> select group#,sequence#,status from v$log;

    GROUP#  SEQUENCE# STATUS
---------- ---------- ----------------
         1          0 UNUSED
         2          0 UNUSED
         3          1 CURRENT

SQL> 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 name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string      /u02/app/oradata/ZDJS, /u02/ap
                                                 p/oradata/clonedb
db_name                              string      clonedb
db_unique_name                       string      clonedb
global_names                         boolean     FALSE
instance_name                        string      clonedb
lock_name_space                      string
log_file_name_convert                string      /u02/app/oradata/ZDJS, /u02/ap
                                                 p/oradata/clonedb
service_names                        string      clonedb

 

posted @ 2015-01-14 15:18  蚂蚁快跑  阅读(467)  评论(0)    收藏  举报