Oracle 使用RMAN制作数据库副本(DB_NAME一致的情况)

说明:本文为Oracle 11gR2下使用RMAN客户端的auxiliary连接方式执行duplicate命令制作数据库副本的指导手册
标签:制作数据库副本、复制数据库、修改数据库名称、Rman、auxiliary、duplicate、
相关文档:对于DB_NAME不一致以及两端路径不一致的情况,敬请期待作者后续更新
温馨提示:如果您发现本文哪里写的有问题或者有更好的写法请留言或私信我进行修改优化

大纲
--实验目的
--知识点
--测试环境
--准备环境
--执行duplicate命令
--验证
--常见问题
--相关输出日志(英文)
--相关输出日志(中文)


★ 实验目的
/////////////////////////////////////////////////////////
将RAC2中的数据库复制到RAC1上(本例中数据库副本的DB_NAME保持和源端一致)

★ 知识点
/////////////////////////////////////////////////////////
※ duplicate后的数据库和源数据拥有不同的DBID
※ Active database duplication功能是从11g开始引入的一个新功能,它通过网络传输副本
※ 数据库副本的DB_NAME可以和源端保持一致,也可以不一致(注意两端数据库路径问题)
※ 如果后期想修改数据库副本DB_NAME可以使用Oracle的其他功能修改,如NID

★ 测试环境
/////////////////////////////////////////////////////////
※ 数据库版本:11.2.0.4(源端和目标端必须一致,否则需要升级等操作)
※ 源端库   :IP:1.1.1.2  DB_NAME:rac2 类型:单实例
※ 目标端库 :IP:1.1.1.1  DB_NAME:rac1 类型:单实例
※ catalog库:IP:1.1.1.99 DB_NAME:win  类型:单实例


★ 准备环境
/////////////////////////////////////////////////////////
✔ 源端执行
SQL> create pfile from spfile;
scp /u01/app/oracle/product/11.2.0/db_1/dbs/initrac2.ora  1.1.1.1:/u01/app/oracle/product/11.2.0/db_1/dbs/initrac2.ora
scp /u01/app/oracle/product/11.2.0/db_1/dbs/orapwrac2     1.1.1.1:/u01/app/oracle/product/11.2.0/db_1/dbs/orapwrac2


✔ 目标端执行
vi listener.ora    配置静态监听(使用netmgr或者手动配置,详情略)
lsnrctl stop
lsnrctl start
vi initrac2.ora    修改部分参数/路径/db_create_file_dest
vi sqlnet.ora    修改登陆方式容许本地系统登陆:SQLNET.AUTHENTICATION_SERVICES = (ALL)
mkdir -p xxx
export ORACLE_SID=rac2
rlwrap sqlplus / as sysdba
create spfile from pfile;
startup nomount


※ 参数文件案例
*.audit_file_dest='/u01/app/oracle/admin/rac2/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/rac2/control01.ctl','/u01/app/oracle/fast_recovery_area/rac2/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='rac2'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=pubXDB)'
*.enable_goldengate_replication=TRUE
*.memory_target=734003200
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'


※ 静态监听案例
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = rac2)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = rac2)
    )
  )

※ 根据参数文件创建目录
mkdir -p /u01/app/oracle/admin/rac2/adump/
mkdir -p /u01/app/oracle/oradata/rac2/
mkdir -p /u01/app/oracle/fast_recovery_area/rac2/

※ 清理目录
rm -rf /u01/app/oracle/admin/rac2/adump/*
rm -rf /u01/app/oracle/oradata/rac2/*
rm -rf /u01/app/oracle/fast_recovery_area/rac2/*


✔ catalog端执行
SQL> create tablespace catalog datafile 'C:\APP\ADMINISTRATOR\ORADATA\WIN\catalog.dbf' size 5M autoextend on;
SQL> create user catalog identified by catalog default tablespace catalog;
SQL> grant dba,recovery_catalog_owner to catalog;


✔ 源端执行
[oracle]$ export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'
[oracle]$ export NLS_LANG=AMERICAN_AMERICA.AL32UTF8                    【英文】
[oracle]$ export NLS_LANG='SIMPLIFIED CHINESE_CHINA.AL32UTF8'        【中文】
[oracle]$ rlwrap rman target / auxiliary sys/[email protected]/rac2 catalog catalog/[email protected]:1521/win
RMAN> create catalog;
RMAN> unregister database noprompt;
RMAN> register database;
RMAN> resync catalog;


★ 执行duplicate命令(源端执行)
/////////////////////////////////////////////////////////
※ 温馨提示:不论两端路径是否一致,duplicate制作的副本名称都是正确的
✔ 如果两端路径一致
RMAN> duplicate target database to rac2 from active database nofilenamecheck;

✔ 如果两端路径不一致
(略)


★ 验证(目标端执行)
/////////////////////////////////////////////////////////
SQL> show parameter name
SQL> select status from v$instance;
SQL> select open_mode from v$database;
SQL> select count(*) from dba_users;
SQL> select name from v$datafile;

★ 常见问题
/////////////////////////////////////////////////////////
✔ 源端和目标端数据库版本不一致

※ 问题原因:
    ① 源端数据库版本和目标端数据库版本不一致(该错误案例中源端版本为:11.2.0.3,目标端版本为:11.2.0.4)
※ 相关提示:
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00601: fatal error in recovery manager
    RMAN-03004: 执行命令期间出现严重错误
    RMAN-10041: 无法在失败后重新创建轮询通道上下文。
    RMAN-10024: 设置 rpc 轮询时出错
    RMAN-10005: 打开游标时出错
    RMAN-10002: ORACLE 错误 : ORA-03114: not connected to ORACLE
    RMAN-03002: Duplicate Db 命令 (在 05/07/2020 12:47:49 上) 失败
    RMAN-05501: 终止复制目标数据库
    RMAN-03015: 在存储的脚本Memory Script中出现错误
    RMAN-06136: 来自辅助数据库的 ORACLE 错误: ORA-01092: ORACLE instance terminated. Disconnection forced
    ORA-00704: bootstrap process failure
    ORA-39700: database must be opened with UPGRADE option
    进程 ID: 11442
    会话 ID: 125 序列号: 9
    [oracle@localhost dbs]$ 

✔ RMAN在连接目标端监听时报错

※ 问题原因:
    ① RMAN后的串配置有问题(该案例中目标端的静态监听名为:rac2不是pub)
    ② 目标端静态监听配置有问题
※ 相关提示:
    [oracle@rac2 dbs]$ rlwrap rman target / auxiliary sys/[email protected]/pub catalog catalog/[email protected]:1521/win
    恢复管理器: Release 11.2.0.4.0 - Production on 星期四 5月 7 13:36:35 2020
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    已连接到目标数据库: RAC2 (DBID=940546915)
    连接到恢复目录数据库
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-00554: 内部恢复管理器程序包初始化失败
    RMAN-04006: 来自辅助数据库的错误: ORA-12528: TNS: 监听程序: 所有适用例程都无法建立新连接

✔ RMAN在往目标端传输副本时报错

※ 相关命令:
    RMAN> duplicate target database to pub from active database nofilenamecheck;
※ 问题原因:
    ① 源端和目标端路径不一致(详情:由于默认情况下,源端是将控制文件copy到目标端“相同控制文件路径下”,然后再利用传过去的该控制文件来恢复制作源端数据库的副本,所以数据库副本的数据文件和控制文件路径与源端保持一致,但是SID、DB_NAME等均变为了指定的名称)
※ 相关提示:
    Starting backup at 2020-05-07 15:05:43
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00001 name=/u01/app/oracle/oradata/rac2/system01.dbf
    RMAN-03009: failure of backup command on ORA_DISK_1 channel at 05/07/2020 15:05:45
    ORA-17628: Oracle error 19505 returned by remote Oracle server
    continuing other job steps, job failed will not be re-run
    ……
    Oracle instance shut down
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of Duplicate Db command at 05/07/2020 15:05:56
    RMAN-05501: aborting duplication of target database
    RMAN-03015: error occurred in stored script Memory Script
    RMAN-03009: failure of backup command on ORA_DISK_1 channel at 05/07/2020 15:05:49
    ORA-17628: Oracle error 19505 returned by remote Oracle server

★ 相关输出日志(英文)
/////////////////////////////////////////////////////////

[oracle@rac2 dbs]$ rlwrap rman target / auxiliary sys/[email protected]/rac2 catalog catalog/[email protected]:1521/win

Recovery Manager: Release 11.2.0.4.0 - Production on Thu May 7 13:56:36 2020

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

connected to target database: RAC2 (DBID=940546915)
connected to recovery catalog database
connected to auxiliary database: RAC2 (not mounted)

RMAN> duplicate target database to rac2 from active database nofilenamecheck;

Starting Duplicate Db at 2020-05-07 13:56:39
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK

contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''RAC2'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name = 
 ''RAC2'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   backup as copy current controlfile auxiliary format  '/u01/app/oracle/oradata/rac2/control01.ctl';
   restore clone controlfile to  '/u01/app/oracle/fast_recovery_area/rac2/control02.ctl' from 
 '/u01/app/oracle/oradata/rac2/control01.ctl';
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''RAC2'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''RAC2'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     730714112 bytes

Fixed Size                     2256832 bytes
Variable Size                478150720 bytes
Database Buffers             243269632 bytes
Redo Buffers                   7036928 bytes

Starting backup at 2020-05-07 13:56:48
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=25 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_rac2.f tag=TAG20200507T135649 RECID=2 STAMP=1039787809
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 2020-05-07 13:56:52

Starting restore at 2020-05-07 13:56:52
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=133 device type=DISK

channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 2020-05-07 13:56:53

database mounted

contents of Memory Script:
{
   set newname for datafile  1 to 
 "/u01/app/oracle/oradata/rac2/system01.dbf";
   set newname for datafile  2 to 
 "/u01/app/oracle/oradata/rac2/sysaux01.dbf";
   set newname for datafile  3 to 
 "/u01/app/oracle/oradata/rac2/undotbs01.dbf";
   set newname for datafile  4 to 
 "/u01/app/oracle/oradata/rac2/users01.dbf";
   set newname for datafile  5 to 
 "/home/oracle/ogg.dbf";
   backup as copy reuse
   datafile  1 auxiliary format 
 "/u01/app/oracle/oradata/rac2/system01.dbf"   datafile 
 2 auxiliary format 
 "/u01/app/oracle/oradata/rac2/sysaux01.dbf"   datafile 
 3 auxiliary format 
 "/u01/app/oracle/oradata/rac2/undotbs01.dbf"   datafile 
 4 auxiliary format 
 "/u01/app/oracle/oradata/rac2/users01.dbf"   datafile 
 5 auxiliary format 
 "/home/oracle/ogg.dbf"   ;
   sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting backup at 2020-05-07 13:56:58
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/rac2/system01.dbf
output file name=/u01/app/oracle/oradata/rac2/system01.dbf tag=TAG20200507T135658
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/rac2/sysaux01.dbf
output file name=/u01/app/oracle/oradata/rac2/sysaux01.dbf tag=TAG20200507T135658
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:26
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/rac2/undotbs01.dbf
output file name=/u01/app/oracle/oradata/rac2/undotbs01.dbf tag=TAG20200507T135658
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/home/oracle/ogg.dbf
output file name=/home/oracle/ogg.dbf tag=TAG20200507T135658
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/rac2/users01.dbf
output file name=/u01/app/oracle/oradata/rac2/users01.dbf tag=TAG20200507T135658
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2020-05-07 13:58:09

sql statement: alter system archive log current

contents of Memory Script:
{
   backup as copy reuse
   archivelog like  "/u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_14_hc78vkpt_.arc" auxiliary format 
 "/u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_14_%u_.arc"   ;
   catalog clone recovery area;
   switch clone datafile all;
}
executing Memory Script

Starting backup at 2020-05-07 13:58:10
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=14 RECID=8 STAMP=1039787889
output file name=/u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_14_0huvjprj_.arc RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 2020-05-07 13:58:12

searching for all files in the recovery area

List of Files Unknown to the Database
=====================================
File Name: /u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_13_0auvjon6_.arc
File Name: /u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_14_0huvjprj_.arc
File Name: /u01/app/oracle/fast_recovery_area/RAC2/onlinelog/o1_mf_2_hc77qslp_.log
File Name: /u01/app/oracle/fast_recovery_area/RAC2/onlinelog/o1_mf_1_hc77qrjh_.log
File Name: /u01/app/oracle/fast_recovery_area/RAC2/onlinelog/o1_mf_3_hc77qtl5_.log
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_13_0auvjon6_.arc
File Name: /u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_14_0huvjprj_.arc

List of Files Which Where Not Cataloged
=======================================
File Name: /u01/app/oracle/fast_recovery_area/RAC2/onlinelog/o1_mf_2_hc77qslp_.log
  RMAN-07518: Reason: Foreign database file DBID: 994130678  Database Name: RAC2
File Name: /u01/app/oracle/fast_recovery_area/RAC2/onlinelog/o1_mf_1_hc77qrjh_.log
  RMAN-07518: Reason: Foreign database file DBID: 994130678  Database Name: RAC2
File Name: /u01/app/oracle/fast_recovery_area/RAC2/onlinelog/o1_mf_3_hc77qtl5_.log
  RMAN-07518: Reason: Foreign database file DBID: 994130678  Database Name: RAC2

datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=1039787892 file name=/u01/app/oracle/oradata/rac2/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=1039787892 file name=/u01/app/oracle/oradata/rac2/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=1039787892 file name=/u01/app/oracle/oradata/rac2/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=1039787892 file name=/u01/app/oracle/oradata/rac2/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=6 STAMP=1039787892 file name=/home/oracle/ogg.dbf

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

executing command: SET until clause

Starting recover at 2020-05-07 13:58:12
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 14 is already on disk as file /u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_14_0huvjprj_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_14_0huvjprj_.arc thread=1 sequence=14
media recovery complete, elapsed time: 00:00:01
Finished recover at 2020-05-07 13:58:14
Oracle instance started

Total System Global Area     730714112 bytes

Fixed Size                     2256832 bytes
Variable Size                478150720 bytes
Database Buffers             243269632 bytes
Redo Buffers                   7036928 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''RAC2'' 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;
}
executing Memory Script

sql statement: alter system set  db_name =  ''RAC2'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset  db_unique_name scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     730714112 bytes

Fixed Size                     2256832 bytes
Variable Size                478150720 bytes
Database Buffers             243269632 bytes
Redo Buffers                   7036928 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "RAC2" RESETLOGS ARCHIVELOG 
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1  SIZE 50 M ,
  GROUP   2  SIZE 50 M ,
  GROUP   3  SIZE 50 M 
 DATAFILE
  '/u01/app/oracle/oradata/rac2/system01.dbf'
 CHARACTER SET AL32UTF8


contents of Memory Script:
{
   set newname for tempfile  1 to 
 "/u01/app/oracle/oradata/rac2/temp01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy  "/u01/app/oracle/oradata/rac2/sysaux01.dbf", 
 "/u01/app/oracle/oradata/rac2/undotbs01.dbf", 
 "/u01/app/oracle/oradata/rac2/users01.dbf", 
 "/home/oracle/ogg.dbf";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/rac2/temp01.dbf in control file

cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rac2/sysaux01.dbf RECID=1 STAMP=1039787904
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rac2/undotbs01.dbf RECID=2 STAMP=1039787904
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rac2/users01.dbf RECID=3 STAMP=1039787904
cataloged datafile copy
datafile copy file name=/home/oracle/ogg.dbf RECID=4 STAMP=1039787904

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=1039787904 file name=/u01/app/oracle/oradata/rac2/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=1039787904 file name=/u01/app/oracle/oradata/rac2/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=1039787904 file name=/u01/app/oracle/oradata/rac2/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=1039787904 file name=/home/oracle/ogg.dbf
Reenabling controlfile options for auxiliary database
Executing: alter database add supplemental log data
Executing: alter database force logging

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

database opened
Finished Duplicate Db at 2020-05-07 13:58:45

RMAN>

★ 相关输出日志(中文)
/////////////////////////////////////////////////////////

[oracle@rac2 dbs]$ rlwrap rman target / auxiliary sys/[email protected]/rac2 catalog catalog/[email protected]:1521/win

恢复管理器: Release 11.2.0.4.0 - Production on 星期四 5月 7 13:36:53 2020

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

已连接到目标数据库: RAC2 (DBID=940546915)
连接到恢复目录数据库
已连接到辅助数据库: RAC2 (未装载)

RMAN> duplicate target database to rac2 from active database nofilenamecheck;

启动 Duplicate Db 于 2020-05-07 13:37:00
分配的通道: ORA_AUX_DISK_1
通道 ORA_AUX_DISK_1: SID=10 设备类型=DISK

内存脚本的内容:
{
   sql clone "alter system set  db_name =  ''RAC2'' comment= ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =  ''RAC2'' comment= ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   backup as copy current controlfile auxiliary format  '/u01/app/oracle/oradata/rac2/control01.ctl';
   restore clone controlfile to  '/u01/app/oracle/fast_recovery_area/rac2/control02.ctl' from  '/u01/app/oracle/oradata/rac2/control01.ctl';
   alter clone database mount;
}
正在执行内存脚本

sql 语句: alter system set  db_name =  ''RAC2'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql 语句: alter system set  db_unique_name =  ''RAC2'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle 实例已关闭

Oracle 实例已启动

系统全局区域总计     730714112 字节

Fixed Size                     2256832 字节
Variable Size                478150720 字节
Database Buffers             243269632 字节
Redo Buffers                   7036928 字节

启动 backup 于 2020-05-07 13:37:10
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=145 设备类型=DISK
通道 ORA_DISK_1: 启动数据文件副本
复制当前控制文件
输出文件名=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_rac2.f 标记=TAG20200507T133710 RECID=1 STAMP=1039786631
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:03
完成 backup 于 2020-05-07 13:37:13

启动 restore 于 2020-05-07 13:37:14
分配的通道: ORA_AUX_DISK_1
通道 ORA_AUX_DISK_1: SID=133 设备类型=DISK

通道 ORA_AUX_DISK_1: 已复制控制文件副本
完成 restore 于 2020-05-07 13:37:15

数据库已装载

内存脚本的内容:
{
   set newname for datafile  1 to  "/u01/app/oracle/oradata/rac2/system01.dbf";
   set newname for datafile  2 to  "/u01/app/oracle/oradata/rac2/sysaux01.dbf";
   set newname for datafile  3 to  "/u01/app/oracle/oradata/rac2/undotbs01.dbf";
   set newname for datafile  4 to  "/u01/app/oracle/oradata/rac2/users01.dbf";
   set newname for datafile  5 to  "/home/oracle/ogg.dbf";
   backup as copy reuse
   datafile  1 auxiliary format  "/u01/app/oracle/oradata/rac2/system01.dbf"   
   datafile  2 auxiliary format  "/u01/app/oracle/oradata/rac2/sysaux01.dbf"   
   datafile  3 auxiliary format  "/u01/app/oracle/oradata/rac2/undotbs01.dbf"   
   datafile  4 auxiliary format  "/u01/app/oracle/oradata/rac2/users01.dbf"   
   datafile  5 auxiliary format  "/home/oracle/ogg.dbf"   ;
   sql 'alter system archive log current';
}
正在执行内存脚本

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

启动 backup 于 2020-05-07 13:37:20
使用通道 ORA_DISK_1
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件: 文件号=00001 名称=/u01/app/oracle/oradata/rac2/system01.dbf
输出文件名=/u01/app/oracle/oradata/rac2/system01.dbf 标记=TAG20200507T133720
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:35
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件: 文件号=00002 名称=/u01/app/oracle/oradata/rac2/sysaux01.dbf
输出文件名=/u01/app/oracle/oradata/rac2/sysaux01.dbf 标记=TAG20200507T133720
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:35
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件: 文件号=00003 名称=/u01/app/oracle/oradata/rac2/undotbs01.dbf
输出文件名=/u01/app/oracle/oradata/rac2/undotbs01.dbf 标记=TAG20200507T133720
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:07
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件: 文件号=00005 名称=/home/oracle/ogg.dbf
输出文件名=/home/oracle/ogg.dbf 标记=TAG20200507T133720
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:04
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件: 文件号=00004 名称=/u01/app/oracle/oradata/rac2/users01.dbf
输出文件名=/u01/app/oracle/oradata/rac2/users01.dbf 标记=TAG20200507T133720
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:01
完成 backup 于 2020-05-07 13:38:44

sql 语句: alter system archive log current

内存脚本的内容:
{
   backup as copy reuse
   archivelog like  "/u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_13_hc77q4h7_.arc" auxiliary format  "/u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_13_%u_.arc"   ;
   catalog clone recovery area;
   switch clone datafile all;
}
正在执行内存脚本

启动 backup 于 2020-05-07 13:38:46
使用通道 ORA_DISK_1
通道 ORA_DISK_1: 正在开始复制归档日志
输入归档日志线程=1 序列=13 RECID=7 STAMP=1039786725
输出文件名=/u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_13_0auvjon6_.arc RECID=0 STAMP=0
通道 ORA_DISK_1: 归档日志复制完成, 经过时间: 00:00:03
完成 backup 于 2020-05-07 13:38:49

搜索恢复区中的所有文件

数据库未知文件的列表
=====================================
文件名: /u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_13_0auvjon6_.arc
正在编制文件目录...
目录编制完毕

已列入目录的文件的列表
=======================
文件名: /u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_13_0auvjon6_.arc

数据文件 1 已转换成数据文件副本
输入数据文件副本 RECID=1 STAMP=1039786730 文件名=/u01/app/oracle/oradata/rac2/system01.dbf
数据文件 2 已转换成数据文件副本
输入数据文件副本 RECID=2 STAMP=1039786730 文件名=/u01/app/oracle/oradata/rac2/sysaux01.dbf
数据文件 3 已转换成数据文件副本
输入数据文件副本 RECID=3 STAMP=1039786730 文件名=/u01/app/oracle/oradata/rac2/undotbs01.dbf
数据文件 4 已转换成数据文件副本
输入数据文件副本 RECID=4 STAMP=1039786730 文件名=/u01/app/oracle/oradata/rac2/users01.dbf
数据文件 5 已转换成数据文件副本
输入数据文件副本 RECID=5 STAMP=1039786730 文件名=/home/oracle/ogg.dbf

内存脚本的内容:
{
   set until scn  1145605;
   recover
   clone database
    delete archivelog
   ;
}
正在执行内存脚本

正在执行命令: SET until clause

启动 recover 于 2020-05-07 13:38:50
使用通道 ORA_AUX_DISK_1

正在开始介质的恢复

线程 1 序列 13 的归档日志已作为文件 /u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_13_0auvjon6_.arc 存在于磁盘上
归档日志文件名=/u01/app/oracle/fast_recovery_area/RAC2/archivelog/2020_05_07/o1_mf_1_13_0auvjon6_.arc 线程=1 序列=13
介质恢复完成, 用时: 00:00:00
完成 recover 于 2020-05-07 13:38:51
Oracle 实例已启动

系统全局区域总计     730714112 字节

Fixed Size                     2256832 字节
Variable Size                478150720 字节
Database Buffers             243269632 字节
Redo Buffers                   7036928 字节

内存脚本的内容:
{
   sql clone "alter system set  db_name =  ''RAC2'' 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;
}
正在执行内存脚本

sql 语句: alter system set  db_name =  ''RAC2'' comment= ''Reset to original value by RMAN'' scope=spfile

sql 语句: alter system reset  db_unique_name scope=spfile

Oracle 实例已关闭

已连接到辅助数据库 (未启动)
Oracle 实例已启动

系统全局区域总计     730714112 字节

Fixed Size                     2256832 字节
Variable Size                478150720 字节
Database Buffers             243269632 字节
Redo Buffers                   7036928 字节

sql 语句: CREATE CONTROLFILE REUSE SET DATABASE "RAC2" RESETLOGS ARCHIVELOG 
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1  SIZE 50 M ,
  GROUP   2  SIZE 50 M ,
  GROUP   3  SIZE 50 M 
 DATAFILE
  '/u01/app/oracle/oradata/rac2/system01.dbf'
 CHARACTER SET AL32UTF8


内存脚本的内容:
{
   set newname for tempfile  1 to  "/u01/app/oracle/oradata/rac2/temp01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy  "/u01/app/oracle/oradata/rac2/sysaux01.dbf",  "/u01/app/oracle/oradata/rac2/undotbs01.dbf",  "/u01/app/oracle/oradata/rac2/users01.dbf",  "/home/oracle/ogg.dbf";
   switch clone datafile all;
}
正在执行内存脚本

正在执行命令: SET NEWNAME

临时文件 1 在控制文件中已重命名为 /u01/app/oracle/oradata/rac2/temp01.dbf

已将数据文件副本列入目录
数据文件副本文件名=/u01/app/oracle/oradata/rac2/sysaux01.dbf RECID=1 STAMP=1039786743
已将数据文件副本列入目录
数据文件副本文件名=/u01/app/oracle/oradata/rac2/undotbs01.dbf RECID=2 STAMP=1039786743
已将数据文件副本列入目录
数据文件副本文件名=/u01/app/oracle/oradata/rac2/users01.dbf RECID=3 STAMP=1039786743
已将数据文件副本列入目录
数据文件副本文件名=/home/oracle/ogg.dbf RECID=4 STAMP=1039786743

数据文件 2 已转换成数据文件副本
输入数据文件副本 RECID=1 STAMP=1039786743 文件名=/u01/app/oracle/oradata/rac2/sysaux01.dbf
数据文件 3 已转换成数据文件副本
输入数据文件副本 RECID=2 STAMP=1039786743 文件名=/u01/app/oracle/oradata/rac2/undotbs01.dbf
数据文件 4 已转换成数据文件副本
输入数据文件副本 RECID=3 STAMP=1039786743 文件名=/u01/app/oracle/oradata/rac2/users01.dbf
数据文件 5 已转换成数据文件副本
输入数据文件副本 RECID=4 STAMP=1039786743 文件名=/home/oracle/ogg.dbf
对辅助数据库重新启用控制文件选项
执行: alter database add supplemental log data
执行: alter database force logging

内存脚本的内容:
{
   Alter clone database open resetlogs;
}
正在执行内存脚本

数据库已打开
完成 Duplicate Db 于 2020-05-07 13:39:24

RMAN> 

※ 如果您觉得文章写的还不错, 别忘了在文末给作者点个赞哦 ~

over

原创文章 58 获赞 58 访问量 7080

猜你喜欢

转载自blog.csdn.net/zzt_2009/article/details/106000880
今日推荐