通过RMAN克隆数据库(基于备份)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了通过RMAN克隆数据库(基于备份)相关的知识,希望对你有一定的参考价值。

 
SQL> show parameter name;
 
NAME                                     TYPE        VALUE
------------------------------------ -----------------------------------------
db_file_name_convert                     string
db_name                            string         orcl
db_unique_name                            string         orcl
global_names                            boolean         FALSE
instance_name                            string         orcl
lock_name_space                     string
log_file_name_convert                     string
service_names                            string         orcl
 
SQL> select current_scn from v$database;
 
CURRENT_SCN
-----------
    1015897

 

 

备份数据库

[[email protected]]$ rman target /

 

RecoveryManager: Release 11.2.0.1.0 - Production on Wed Jan 27 23:18:24 2016

 

Copyright(c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

 

connectedto target database: ORCL (DBID=1426154421)

 

RMAN> run{
allocate channel c1 type disk;
allocate channel c2 type disk;
backup filesperset 3 database format‘/u01/app/backup/full_%d_%T_%s_%p‘;
sql ‘alter system archive log current‘;
sql ‘alter system archive log current‘;
sql ‘alter system archive log current‘;
backup archivelog all format‘/u01/app/backup/arch_%d_%T_%s_%p‘ delete input;
backup current controlfile format‘/u01/app/backup/ctl_%d_%T_%s_%p‘;
}


 

SQL> col file_name for a50
SQL> select FILE_ID,FILE_NAME,TABLESPACE_NAME fromdba_data_files;
 
   FILE_IDFILE_NAME                                              TABLESPACE_NAME
---------- --------------------------------------------------------------------------------
 4/u01/app/oracle/oradata/orcl/users01.dbf              USERS
 3/u01/app/oracle/oradata/orcl/undotbs01.dbf              UNDOTBS1
 2/u01/app/oracle/oradata/orcl/sysaux01.dbf              SYSAUX
 1/u01/app/oracle/oradata/orcl/system01.dbf              SYSTEM
 5/u01/app/oracle/oradata/orcl/example01.dbf              EXAMPLE
 6/u01/app/oracle/oradata/orcl/heleitbs01.dbf              HELEITBS
 
6 rows selected.

 

建立Pfile文件

SQL>create pfile from spfile;
 
Filecreated.

建立克隆库的目录

[[email protected] ~]$ mkdir -p$ORACLE_BASE/admin/clonedb/bdump
[[email protected] ~]$ mkdir -p$ORACLE_BASE/admin/clonedb/cdump
[[email protected] ~]$ mkdir -p$ORACLE_BASE/admin/clonedb/udump
[[email protected] ~]$ mkdir -p $ORACLE_BASE/oradata/clonedb


 

将主库pfile拷贝成名为克隆库名的文件,将其拷贝至备机,并在备机生成克隆库的口令文件

[[email protected]]$ cp initorcl.ora initclonedb.ora
[[email protected]]$ orapwd file=orapwclonedb password=MANAGER entries=30

vi initclonedb.ora

orcl替换为clonedb,并增加以下内容:

db_file_name_convert = ("/u01/app/oracle/oradata/db01","/u01/app/oracle/oradata/clonedb")log_file_name_convert =("/disk1/oradata/db01","/disk1/oradata/clonedb","/disk2/oradata/db01","/disk2/oradata/clonedb")

注:11g默认开启审计,我们这里不需要,所以上述克隆步骤不包含审计目录,如果没关审计功能,pfile注释掉*.audit_file_dest这行,*.audit_trail=‘none‘即可,

如何查看和关闭审计功能:

SQL>show parameter audi; 
 
NAME                                     TYPE        VALUE
----------------------------------------------- ------------------------------
audit_file_dest                    string        /u01/app/oracle/admin/orcl/adu
 mp
audit_sys_operations                    boolean         FALSE
audit_syslog_level                     string
audit_trail                            string         DB
SQL>alter system set audit_trail=none scope=spfile;
 
Systemaltered.
SQL>shutdown immediate;
Databaseclosed.
Databasedismounted.
ORACLEinstance shut down.
SQL>startup
ORACLEinstance started.

 

将主库之前创建的initclonedb拷贝到备库

clone库启动到nomount

[[email protected] dbs]$ export ORACLE_SID=clonedb
[[email protected] dbs]$ sqlplus / as sysdba
 
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jan 28 00:42:58 2016
 
Copyright (c) 1982, 2009, Oracle. All rights reserved.
 
Connected to an idle instance.
 
SQL> startup pfile=$ORACLE_HOME/dbs/initclonedb.ora nomount;
ORACLE instance started.

 

RMAN连接主库和clone

[[email protected]]$ rman target sys/[email protected] auxiliary sys/MANAGER
 
RecoveryManager: Release 11.2.0.1.0 - Production on Thu Jan 28 01:24:35 2016
 
Copyright(c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
 
connectedto target database: ORCL (DBID=1426154421)
connectedto auxiliary database: CLONEDB (not mounted)
 
RMAN>
RMAN>list backup;
 
 
Listof Backup Sets
===================
 
 
BSKey  Type LV Size       Device Type Elapsed Time Completion Time
----------- -- ---------- ----------- ------------ ---------------
1       Full   436.71M    DISK        00:01:02     27-JAN-16     
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20160127T231840
        Piece Name:/u01/app/backup/full_ORCL_20160127_2_1
  List of Datafiles in backup set 1
  File LV Type Ckp SCN    Ckp Time Name
  ---- -- ---- ---------- --------- ----
  2      Full 1015955    27-JAN-16/u01/app/oracle/oradata/orcl/sysaux01.dbf
  3      Full 1015955    27-JAN-16/u01/app/oracle/oradata/orcl/undotbs01.dbf
  6      Full 1015955    27-JAN-16/u01/app/oracle/oradata/orcl/heleitbs01.dbf
 
BSKey  Type LV Size       Device Type Elapsed Time Completion Time
----------- -- ---------- ----------- ------------ ---------------
2       Full   9.33M      DISK        00:00:08     27-JAN-16     
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20160127T231840
        Piece Name:/u01/app/backup/full_ORCL_20160127_3_1
  Control File Included: Ckp SCN: 1015986      Ckp time: 27-JAN-16
 
BSKey  Type LV Size       Device Type Elapsed Time Completion Time
----------- -- ---------- ----------- ------------ ---------------
3       Full   660.65M    DISK        00:01:22     27-JAN-16     
        BP Key: 3   Status: AVAILABLE  Compressed: NO  Tag: TAG20160127T231840
        Piece Name:/u01/app/backup/full_ORCL_20160127_1_1
  List of Datafiles in backup set 3
  File LV Type Ckp SCN    Ckp Time Name
  ---- -- ---- ---------- --------- ----
  1      Full 1015954    27-JAN-16/u01/app/oracle/oradata/orcl/system01.dbf
  4      Full 1015954    27-JAN-16/u01/app/oracle/oradata/orcl/users01.dbf
  5      Full 1015954    27-JAN-16/u01/app/oracle/oradata/orcl/example01.dbf
 
BSKey  Type LV Size       Device Type Elapsed Time Completion Time
----------- -- ---------- ----------- ------------ ---------------
4       Full   80.00K     DISK        00:00:04     27-JAN-16     
        BP Key: 4   Status: AVAILABLE  Compressed: NO  Tag: TAG20160127T231840
        Piece Name:/u01/app/backup/full_ORCL_20160127_4_1
  SPFILE Included: Modification time: 27-JAN-16
  SPFILE db_unique_name: ORCL
 
BSKey  Size       Device Type Elapsed Time Completion Time
----------------- ----------- ------------ ---------------
5       14.34M     DISK       00:00:01     27-JAN-16     
        BP Key: 5   Status: AVAILABLE  Compressed: NO  Tag: TAG20160127T232008
        Piece Name:/u01/app/backup/arch_ORCL_20160127_5_1
 
  List of Archived Logs in backup set 5
  Thrd Seq    Low SCN    Low Time  Next SCN  Next Time
  ---- ------- ---------- --------- -------------------
  1   5       1011640    13-DEC-15 1016002    27-JAN-16
 
BSKey  Size       Device Type Elapsed Time Completion Time
----------------- ----------- ------------ ---------------
6       3.00K      DISK        00:00:01     27-JAN-16     
        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20160127T232008
        Piece Name:/u01/app/backup/arch_ORCL_20160127_6_1
 
  List of Archived Logs in backup set 6
  Thrd Seq    Low SCN    Low Time  Next SCN  Next Time
  ---- ------- ---------- --------- -------------------
  1   6       1016002    27-JAN-16 1016011    27-JAN-16
  1   7       1016011    27-JAN-16 1016020    27-JAN-16
 
BSKey  Size       Device Type Elapsed Time Completion Time
----------------- ----------- ------------ ---------------
7       2.00K      DISK        00:00:01     27-JAN-16     
        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20160127T232008
        Piece Name:/u01/app/backup/arch_ORCL_20160127_7_1
 
  List of Archived Logs in backup set 7
  Thrd Seq    Low SCN    Low Time  Next SCN  Next Time
  ---- ------- ---------- --------- -------------------
  1   8       1016020    27-JAN-16 1016028    27-JAN-16
 
BSKey  Type LV Size       Device Type Elapsed Time Completion Time
----------- -- ---------- ----------- ------------ ---------------
8       Full   9.33M      DISK        00:00:01     27-JAN-16     
        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20160127T232010
        Piece Name:/u01/app/backup/ctl_ORCL_20160127_8_1
  Control File Included: Ckp SCN: 1016045      Ckp time: 27-JAN-16

 

将主库备份文件拷贝至备库相应备份目录后,执行RMAN复制

RMAN>duplicate target database to clonedb;
 
StartingDuplicate Db at 28-JAN-16
usingtarget database control file instead of recovery catalog
allocatedchannel: ORA_AUX_DISK_1
channelORA_AUX_DISK_1: SID=20 device type=DISK
 
contentsof Memory Script:
{
   sql clone "create spfile frommemory";
}
executingMemory Script
 
sqlstatement: create spfile from memory
 
contentsof Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
}
executingMemory Script
 
Oracleinstance shut down
 
connectedto auxiliary database (not started)
Oracleinstance started
 
TotalSystem Global Area     630501376 bytes
 
FixedSize                     2215984 bytes
VariableSize                188747728 bytes
DatabaseBuffers             436207616 bytes
RedoBuffers                   3330048 bytes
 
contentsof Memory Script:
{
   sql clone "alter system set  db_name =
 ‘‘ORCL‘‘ comment=
 ‘‘Modified by RMAN duplicate‘‘scope=spfile";
   sql clone "alter system set  db_unique_name =
 ‘‘CLONEDB‘‘ comment=
 ‘‘Modified by RMAN duplicate‘‘scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone primary controlfile;
   alter clone database mount;
}
executingMemory Script
 
sqlstatement: alter system set  db_name=  ‘‘ORCL‘‘ comment= ‘‘Modified by RMANduplicate‘‘ scope=spfile
 
sqlstatement: alter system set db_unique_name =  ‘‘CLONEDB‘‘comment= ‘‘Modified by RMAN duplicate‘‘ scope=spfile
 
Oracleinstance shut down
 
Oracleinstance started
 
TotalSystem Global Area     630501376 bytes
 
FixedSize                     2215984 bytes
VariableSize                188747728 bytes
DatabaseBuffers             436207616 bytes
RedoBuffers                   3330048 bytes
 
Startingrestore at 28-JAN-16
allocatedchannel: ORA_AUX_DISK_1
channelORA_AUX_DISK_1: SID=19 device type=DISK
 
channelORA_AUX_DISK_1: starting datafile backup set restore
channelORA_AUX_DISK_1: restoring control file
channelORA_AUX_DISK_1: reading from backup piece /u01/app/backup/ctl_ORCL_20160127_8_1
channelORA_AUX_DISK_1: piece handle=/u01/app/backup/ctl_ORCL_20160127_8_1tag=TAG20160127T232010
channelORA_AUX_DISK_1: restored backup piece 1
channelORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
outputfile name=/u01/app/oracle/oradata/clonedb/control01.ctl
outputfile name=/u01/app/oracle/oradata/clonedb/control02.ctl
Finishedrestore at 28-JAN-16
 
databasemounted
 
contentsof Memory Script:
{
   set until scn  1019371;
   set newname for datafile  1 to
 "/u01/app/oracle/oradata/clonedb/system01.dbf";
   set newname for datafile  2 to
 "/u01/app/oracle/oradata/clonedb/sysaux01.dbf";
   set newname for datafile  3 to
 "/u01/app/oracle/oradata/clonedb/undotbs01.dbf";
   set newname for datafile  4 to
 "/u01/app/oracle/oradata/clonedb/users01.dbf";
   set newname for datafile  5 to
 "/u01/app/oracle/oradata/clonedb/example01.dbf";
   set newname for datafile  6 to
 "/u01/app/oracle/oradata/clonedb/heleitbs01.dbf";
   restore
   clone database
   ;
}
executingMemory Script
 
executingcommand: SET until clause
 
executingcommand: SET NEWNAME
 
executingcommand: SET NEWNAME
 
executingcommand: SET NEWNAME
 
executingcommand: SET NEWNAME
 
executingcommand: SET NEWNAME
 
executingcommand: SET NEWNAME
 
Startingrestore at 28-JAN-16
usingchannel ORA_AUX_DISK_1
 
channelORA_AUX_DISK_1: starting datafile backup set restore
channelORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channelORA_AUX_DISK_1: restoring datafile 00002 to/u01/app/oracle/oradata/clonedb/sysaux01.dbf
channelORA_AUX_DISK_1: restoring datafile 00003 to/u01/app/oracle/oradata/clonedb/undotbs01.dbf
channelORA_AUX_DISK_1: restoring datafile 00006 to/u01/app/oracle/oradata/clonedb/heleitbs01.dbf
channelORA_AUX_DISK_1: reading from backup piece/u01/app/backup/full_ORCL_20160127_2_1
channelORA_AUX_DISK_1: piece handle=/u01/app/backup/full_ORCL_20160127_2_1tag=TAG20160127T231840
channelORA_AUX_DISK_1: restored backup piece 1
channelORA_AUX_DISK_1: restore complete, elapsed time: 00:00:56
channelORA_AUX_DISK_1: starting datafile backup set restore
channelORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channelORA_AUX_DISK_1: restoring datafile 00001 to/u01/app/oracle/oradata/clonedb/system01.dbf
channelORA_AUX_DISK_1: restoring datafile 00004 to/u01/app/oracle/oradata/clonedb/users01.dbf
channelORA_AUX_DISK_1: restoring datafile 00005 to/u01/app/oracle/oradata/clonedb/example01.dbf
channelORA_AUX_DISK_1: reading from backup piece/u01/app/backup/full_ORCL_20160127_1_1
channelORA_AUX_DISK_1: piece handle=/u01/app/backup/full_ORCL_20160127_1_1tag=TAG20160127T231840
channelORA_AUX_DISK_1: restored backup piece 1
channelORA_AUX_DISK_1: restore complete, elapsed time: 00:01:07
Finishedrestore at 28-JAN-16
 
contentsof Memory Script:
{
   switch clone datafile all;
}
executingMemory Script
 
datafile1 switched to datafile copy
inputdatafile copy RECID=8 STAMP=902341117 filename=/u01/app/oracle/oradata/clonedb/system01.dbf
datafile2 switched to datafile copy
inputdatafile copy RECID=9 STAMP=902341117 filename=/u01/app/oracle/oradata/clonedb/sysaux01.dbf
datafile3 switched to datafile copy
inputdatafile copy RECID=10 STAMP=902341117 filename=/u01/app/oracle/oradata/clonedb/undotbs01.dbf
datafile4 switched to datafile copy
inputdatafile copy RECID=11 STAMP=902341117 filename=/u01/app/oracle/oradata/clonedb/users01.dbf
datafile5 switched to datafile copy
inputdatafile copy RECID=12 STAMP=902341118 filename=/u01/app/oracle/oradata/clonedb/example01.dbf
datafile6 switched to datafile copy
inputdatafile copy RECID=13 STAMP=902341118 filename=/u01/app/oracle/oradata/clonedb/heleitbs01.dbf
 
contentsof Memory Script:
{
   set until scn  1019371;
   recover
   clone database
    delete archivelog
   ;
}
executingMemory Script
 
executingcommand: SET until clause
 
Startingrecover at 28-JAN-16
usingchannel ORA_AUX_DISK_1
 
startingmedia recovery
 
archivedlog for thread 1 with sequence 9 is already on disk as file/u01/archivelog/1_9_898373685.dbf
channelORA_AUX_DISK_1: starting archived log restore to default destination
channelORA_AUX_DISK_1: restoring archived log
archivedlog thread=1 sequence=5
channelORA_AUX_DISK_1: reading from backup piece/u01/app/backup/arch_ORCL_20160127_5_1
channelORA_AUX_DISK_1: piece handle=/u01/app/backup/arch_ORCL_20160127_5_1tag=TAG20160127T232008
channelORA_AUX_DISK_1: restored backup piece 1
channelORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
archivedlog file name=/u01/archivelog/1_5_898373685.dbf thread=1 sequence=5
channelclone_default: deleting archived log(s)
archivedlog file name=/u01/archivelog/1_5_898373685.dbf RECID=5 STAMP=902341120
channelORA_AUX_DISK_1: starting archived log restore to default destination
channelORA_AUX_DISK_1: restoring archived log
archivedlog thread=1 sequence=6
channelORA_AUX_DISK_1: restoring archived log
archivedlog thread=1 sequence=7
channelORA_AUX_DISK_1: reading from backup piece/u01/app/backup/arch_ORCL_20160127_6_1
channelORA_AUX_DISK_1: piece handle=/u01/app/backup/arch_ORCL_20160127_6_1tag=TAG20160127T232008
channelORA_AUX_DISK_1: restored backup piece 1
channelORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archivedlog file name=/u01/archivelog/1_6_898373685.dbf thread=1 sequence=6
channelclone_default: deleting archived log(s)
archivedlog file name=/u01/archivelog/1_6_898373685.dbf RECID=7 STAMP=902341122
archivedlog file name=/u01/archivelog/1_7_898373685.dbf thread=1 sequence=7
channelclone_default: deleting archived log(s)
archivedlog file name=/u01/archivelog/1_7_898373685.dbf RECID=6 STAMP=902341122
channelORA_AUX_DISK_1: starting archived log restore to default destination
channelORA_AUX_DISK_1: restoring archived log
archivedlog thread=1 sequence=8
channelORA_AUX_DISK_1: reading from backup piece/u01/app/backup/arch_ORCL_20160127_7_1
channelORA_AUX_DISK_1: piece handle=/u01/app/backup/arch_ORCL_20160127_7_1tag=TAG20160127T232008
channelORA_AUX_DISK_1: restored backup piece 1
channelORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archivedlog file name=/u01/archivelog/1_8_898373685.dbf thread=1 sequence=8
channelclone_default: deleting archived log(s)
archivedlog file name=/u01/archivelog/1_8_898373685.dbf RECID=8 STAMP=902341123
archivedlog file name=/u01/archivelog/1_9_898373685.dbf thread=1 sequence=9
mediarecovery complete, elapsed time: 00:00:05
Finishedrecover at 28-JAN-16
 
contentsof Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
   sql clone "alter system set  db_name =
 ‘‘CLONEDB‘‘ comment=
 ‘‘Reset to original value by RMAN‘‘scope=spfile";
   sql clone "alter system reset  db_unique_name scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executingMemory Script
 
databasedismounted
Oracleinstance shut down
 
connectedto auxiliary database (not started)
Oracleinstance started
 
TotalSystem Global Area     630501376 bytes
 
FixedSize                     2215984 bytes
VariableSize                188747728 bytes
DatabaseBuffers             436207616 bytes
RedoBuffers                   3330048 bytes
 
sqlstatement: alter system set  db_name=  ‘‘CLONEDB‘‘ comment= ‘‘Reset tooriginal value by RMAN‘‘ scope=spfile
 
sqlstatement: alter system reset db_unique_name scope=spfile
 
Oracleinstance shut down
 
connectedto auxiliary database (not started)
Oracleinstance started
 
TotalSystem Global Area     630501376 bytes
 
FixedSize                     2215984 bytes
VariableSize                188747728 bytes
DatabaseBuffers             436207616 bytes
RedoBuffers                   3330048 bytes
sqlstatement: CREATE CONTROLFILE REUSE SET DATABASE "CLONEDB" RESETLOGSARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP 1 ( ‘/u01/app/oracle/oradata/clonedb/redo01.log‘ ) SIZE 50 M  REUSE,
  GROUP 2 ( ‘/u01/app/oracle/oradata/clonedb/redo02.log‘ ) SIZE 50 M  REUSE,
  GROUP 3 ( ‘/u01/app/oracle/oradata/clonedb/redo03.log‘ ) SIZE 50 M  REUSE
 DATAFILE
 ‘/u01/app/oracle/oradata/clonedb/system01.dbf‘
 CHARACTER SET ZHS16GBK
 
 
contentsof Memory Script:
{
   set newname for tempfile  1 to
 "/u01/app/oracle/oradata/clonedb/temp01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy "/u01/app/oracle/oradata/clonedb/sysaux01.dbf",
 "/u01/app/oracle/oradata/clonedb/undotbs01.dbf",
 "/u01/app/oracle/oradata/clonedb/users01.dbf",
 "/u01/app/oracle/oradata/clonedb/example01.dbf",
 "/u01/app/oracle/oradata/clonedb/heleitbs01.dbf";
   switch clone datafile all;
}
executingMemory Script
 
executingcommand: SET NEWNAME
 
renamedtempfile 1 to /u01/app/oracle/oradata/clonedb/temp01.dbf in control file
 
catalogeddatafile copy
datafilecopy file name=/u01/app/oracle/oradata/clonedb/sysaux01.dbf RECID=1STAMP=902341136
catalogeddatafile copy
datafilecopy file name=/u01/app/oracle/oradata/clonedb/undotbs01.dbf RECID=2STAMP=902341136
catalogeddatafile copy
datafilecopy file name=/u01/app/oracle/oradata/clonedb/users01.dbf RECID=3STAMP=902341136
catalogeddatafile copy
datafilecopy file name=/u01/app/oracle/oradata/clonedb/example01.dbf RECID=4STAMP=902341136
catalogeddatafile copy
datafilecopy file name=/u01/app/oracle/oradata/clonedb/heleitbs01.dbf RECID=5STAMP=902341136
 
datafile2 switched to datafile copy
inputdatafile copy RECID=1 STAMP=902341136 filename=/u01/app/oracle/oradata/clonedb/sysaux01.dbf
datafile3 switched to datafile copy
inputdatafile copy RECID=2 STAMP=902341136 filename=/u01/app/oracle/oradata/clonedb/undotbs01.dbf
datafile4 switched to datafile copy
inputdatafile copy RECID=3 STAMP=902341136 filename=/u01/app/oracle/oradata/clonedb/users01.dbf
datafile5 switched to datafile copy
inputdatafile copy RECID=4 STAMP=902341136 filename=/u01/app/oracle/oradata/clonedb/example01.dbf
datafile6 switched to datafile copy
inputdatafile copy RECID=5 STAMP=902341136 filename=/u01/app/oracle/oradata/clonedb/heleitbs01.dbf
 
contentsof Memory Script:
{
   Alter clone database open resetlogs;
}
executingMemory Script
 
databaseopened
FinishedDuplicate Db at 28-JAN-16

 

 

 

克隆成功,打开克隆库查看

SQL>show parameter name;
 
NAME                                     TYPE        VALUE
----------------------------------------------- ------------------------------
db_file_name_convert                    string        /u01/app/oracle/oradata/orcl,
 /u01/app/oracle/oradata/cloned
 b
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        /u01/app/oracle/oradata/orcl,
 /u01/app/oracle/oradata/cloned
 b
 
NAME                                     TYPE        VALUE
----------------------------------------------- ------------------------------
service_names                            string         CLONEDB
SQL>select status from v$instance;
 
STATUS
------------
OPEN
 
SQL>select name from v$datafile;
 
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/clonedb/system01.dbf
/u01/app/oracle/oradata/clonedb/sysaux01.dbf
/u01/app/oracle/oradata/clonedb/undotbs01.dbf
/u01/app/oracle/oradata/clonedb/users01.dbf
/u01/app/oracle/oradata/clonedb/example01.dbf
/u01/app/oracle/oradata/clonedb/heleitbs01.dbf
 
6rows selected.
 
SQL>select * from v$log;
 
    GROUP#   THREAD#  SEQUENCE#      BYTES BLOCKSIZE          MEMBERS ARC
-------------------- ---------- ---------- ---------- ---------- ---
STATUS                FIRST_CHANGE# FIRST_TIME   NEXT_CHANGE#NEXT_TIME
----------------------------- ------------ ------------ ------------
 1           1               1  52428800          512                1NO
CURRENT               1019372 28-JAN-16      2.8147E+14
 
 2           1               0  52428800          512                1YES
UNUSED                            0                               0
 
 3           1               0  52428800          512                1YES
UNUSED                            0                               0
 
 
SQL>alter system switch logfile;
 
Systemaltered.
 
SQL>/
 
Systemaltered.
 
SQL>/
 
Systemaltered.
 
SQL>select * from v$log;
 
    GROUP#   THREAD#  SEQUENCE#      BYTES BLOCKSIZE          MEMBERS ARC
-------------------- ---------- ---------- ---------- ---------- ---
STATUS                FIRST_CHANGE# FIRST_TIME   NEXT_CHANGE#NEXT_TIME
----------------------------- ------------ ------------ ------------
 1           1               4  52428800          512                1NO
CURRENT               1020327 28-JAN-16      2.8147E+14
 
 2           1               2  52428800          512                1YES
INACTIVE               102032028-JAN-16         1020323 28-JAN-16
 
 3           1               3  52428800          512                1YES
INACTIVE               102032328-JAN-16         1020327 28-JAN-16



以上是关于通过RMAN克隆数据库(基于备份)的主要内容,如果未能解决你的问题,请参考以下文章

基于RMAN的异机数据库克隆(rman duplicate)

基于RMAN从活动数据库异机克隆(rman duplicate from active DB)

RMAN 前期准备工作和实例

记一次pg_rman备份postgresql数据库报段错误的处理过程

记一次pg_rman备份postgresql数据库报段错误的处理过程

记一次pg_rman备份postgresql数据库报段错误的处理过程