ADD正在活动的数据库复制

本文详细介绍了一个使用RMAN工具进行Oracle数据库复制的过程。从准备阶段开始,包括参数文件配置、网络环境设置等,一直到数据库的复制操作及后续的调整步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.准备目标数据库的参数文件
[oracle@oel orcl1]$ export ORACLE_SID=orcl
[oracle@oel orcl1]$ sqlplus / as sysdba


SQL> create pfile from spfile;


File created.


[oracle@oel dbs]$ cp initorcl.ora initoaec.ora
:%s/orcl/oaec/g
db_file_name_convert=('/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/oaec')
log_file_name_convert=('/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/oaec')


log_archive_dest_1='location=/u02/oaecarch'
并且把相关目录都创建出来
[oracle@oracle admin]$ mkdir -p /u01/app/oracle/admin/oaec/{a,b,c,d}dump
[oracle@oracle admin]$ mkdir -p /u01/app/oracle/oradata/oaec
[oracle@oracle admin]$ mkdir -p /u01/app/oracle/flash_recovery_area/oaec
[oracle@oracle admin]$ mkdir -p /u01/app/oracle/diag/rdbms/ac/ac/trace
[oracle@oracle admin]$ mkdir -p /u02/oaecarch
2.创建口令文件
orapwd file=orapwoaec password=oracle


3.准备网络环境
oaec监听的静态注册
以及tnsnames.ora中名称解析


4.启动oaec到nomount
SQL> startup nomount
ORACLE instance started.


Total System Global Area  468701184 bytes
Fixed Size                  1337268 bytes
Variable Size             146802764 bytes
Database Buffers          314572800 bytes
Redo Buffers                5988352 bytes
SQL> exit


5.执行复制


[oracle@oel oradata]$ rman target sys/oracle@orcl auxiliary sys/oracle@oaec


Recovery Manager: Release 11.2.0.1.0 - Production on Wed Jun 8 15:08:06 2016


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


connected to target database: ORCL (DBID=1440654326)
connected to auxiliary database: OAEC (not mounted)


RMAN> duplicate target database to oaec from active database;


Starting Duplicate Db at 08-JUN-16
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=63 device type=DISK


contents of 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 = 
 ''OAEC'' 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/oaec/control01.ctl';
   restore clone controlfile to  '/u02/oaec/control02.ctl' from 
 '/u01/app/oracle/oradata/oaec/control01.ctl';
   alter clone database mount;
}
executing Memory Script


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


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


Oracle instance shut down


Oracle instance started


Total System Global Area     468701184 bytes


Fixed Size                     1337268 bytes
Variable Size                146802764 bytes
Database Buffers             314572800 bytes
Redo Buffers                   5988352 bytes


Starting backup at 08-JUN-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=7 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_orcl.f tag=TAG20160608T150843 RECID=56 STAMP=913993724
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 08-JUN-16


Starting restore at 08-JUN-16
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=63 device type=DISK


channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 08-JUN-16


database mounted


contents of Memory Script:
{
   set newname for datafile  1 to 
 "/u01/app/oracle/oradata/oaec/system01.dbf";
   set newname for datafile  2 to 
 "/u01/app/oracle/oradata/oaec/sysaux01.dbf";
   set newname for datafile  3 to 
 "/u01/app/oracle/oradata/oaec/undotbs01.dbf";
   set newname for datafile  4 to 
 "/u01/app/oracle/oradata/oaec/users01.dbf";
   set newname for datafile  5 to 
 "/u01/app/oracle/oradata/oaec/example01.dbf";
   set newname for datafile  6 to 
 "/u01/app/oracle/oradata/oaec/test.dbf";
   backup as copy reuse
   datafile  1 auxiliary format 
 "/u01/app/oracle/oradata/oaec/system01.dbf"   datafile 
 2 auxiliary format 
 "/u01/app/oracle/oradata/oaec/sysaux01.dbf"   datafile 
 3 auxiliary format 
 "/u01/app/oracle/oradata/oaec/undotbs01.dbf"   datafile 
 4 auxiliary format 
 "/u01/app/oracle/oradata/oaec/users01.dbf"   datafile 
 5 auxiliary format 
 "/u01/app/oracle/oradata/oaec/example01.dbf"   datafile 
 6 auxiliary format 
 "/u01/app/oracle/oradata/oaec/test.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


executing command: SET NEWNAME


Starting backup at 08-JUN-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
output file name=/u01/app/oracle/oradata/oaec/system01.dbf tag=TAG20160608T150852
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
output file name=/u01/app/oracle/oradata/oaec/sysaux01.dbf tag=TAG20160608T150852
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/orcl/undotbs01.dbf
output file name=/u01/app/oracle/oradata/oaec/undotbs01.dbf tag=TAG20160608T150852
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=/u01/app/oracle/oradata/orcl/example01.dbf
output file name=/u01/app/oracle/oradata/oaec/example01.dbf tag=TAG20160608T150852
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
output file name=/u01/app/oracle/oradata/oaec/users01.dbf tag=TAG20160608T150852
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00006 name=/u01/app/oracle/oradata/orcl/test.dbf
output file name=/u01/app/oracle/oradata/oaec/test.dbf tag=TAG20160608T150852
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 08-JUN-16


sql statement: alter system archive log current


contents of Memory Script:
{
   backup as copy reuse
   archivelog like  "/u02/ORCL/archivelog/2016_06_08/o1_mf_1_18_cohk69t6_.arc" auxiliary format 
 "/u02/oaecarch/1_18_913893487.dbf"   ;
   catalog clone archivelog  "/u02/oaecarch/1_18_913893487.dbf";
   switch clone datafile all;
}
executing Memory Script


Starting backup at 08-JUN-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=18 RECID=117 STAMP=913993801
output file name=/u02/oaecarch/1_18_913893487.dbf RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 08-JUN-16


cataloged archived log
archived log file name=/u02/oaecarch/1_18_913893487.dbf RECID=117 STAMP=913993803


datafile 1 switched to datafile copy
input datafile copy RECID=56 STAMP=913993803 file name=/u01/app/oracle/oradata/oaec/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=57 STAMP=913993803 file name=/u01/app/oracle/oradata/oaec/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=58 STAMP=913993803 file name=/u01/app/oracle/oradata/oaec/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=59 STAMP=913993803 file name=/u01/app/oracle/oradata/oaec/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=60 STAMP=913993803 file name=/u01/app/oracle/oradata/oaec/example01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=61 STAMP=913993803 file name=/u01/app/oracle/oradata/oaec/test.dbf


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


executing command: SET until clause


Starting recover at 08-JUN-16
using channel ORA_AUX_DISK_1


starting media recovery


archived log for thread 1 with sequence 18 is already on disk as file /u02/oaecarch/1_18_913893487.dbf
archived log file name=/u02/oaecarch/1_18_913893487.dbf thread=1 sequence=18
media recovery complete, elapsed time: 00:00:01
Finished recover at 08-JUN-16


contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
   sql clone "alter system set  db_name = 
 ''OAEC'' 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


database dismounted
Oracle instance shut down


connected to auxiliary database (not started)
Oracle instance started


Total System Global Area     468701184 bytes


Fixed Size                     1337268 bytes
Variable Size                146802764 bytes
Database Buffers             314572800 bytes
Redo Buffers                   5988352 bytes


sql statement: alter system set  db_name =  ''OAEC'' 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     468701184 bytes


Fixed Size                     1337268 bytes
Variable Size                146802764 bytes
Database Buffers             314572800 bytes
Redo Buffers                   5988352 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "OAEC" RESETLOGS ARCHIVELOG 
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( '/u01/app/oracle/oradata/oaec/redo01.log' ) SIZE 50 M  REUSE,
  GROUP  2 ( '/u01/app/oracle/oradata/oaec/redo02.log' ) SIZE 50 M  REUSE,
  GROUP  3 ( '/u01/app/oracle/oradata/oaec/redo03.log' ) SIZE 50 M  REUSE
 DATAFILE
  '/u01/app/oracle/oradata/oaec/system01.dbf'
 CHARACTER SET AL32UTF8




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


executing command: SET NEWNAME


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


cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/oaec/sysaux01.dbf RECID=1 STAMP=913993819
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/oaec/undotbs01.dbf RECID=2 STAMP=913993819
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/oaec/users01.dbf RECID=3 STAMP=913993819
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/oaec/example01.dbf RECID=4 STAMP=913993819
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/oaec/test.dbf RECID=5 STAMP=913993819


datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=913993819 file name=/u01/app/oracle/oradata/oaec/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=913993819 file name=/u01/app/oracle/oradata/oaec/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=913993819 file name=/u01/app/oracle/oradata/oaec/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=913993819 file name=/u01/app/oracle/oradata/oaec/example01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=5 STAMP=913993819 file name=/u01/app/oracle/oradata/oaec/test.dbf


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


database opened
Finished Duplicate Db at 08-JUN-16
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值