ORACLE RMAN ACTIVE COPY

11G 环境

1. 环境准备
TARGET: 192.168.102.188
ORACLE_SID: orcl

AUX: 192.168.102.189
ORACLE_SID: orcl

2. 在AUX端创建PFILE文件

[oracle@localhost ~]$ cd $ORACLE_HOME/dbs
[oracle@localhost dbs]$ vi initorcl.ora
DB_NAME=orcl


3. 在AUX端创建口令文件(在这里要注意密码文件的格式:orapw+$ORACLE_SID)

[oracle@localhost dbs]$ orapwd file=orapworcl password=admin
[oracle@localhost dbs]$ 


4. 在AUX端创建数据文件目录

[oracle@localhost ~]$ mkdir -p oradata/orcl
[oracle@localhost ~]$ 


5. 启动AUX端以NOMOUNT状态:

[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Tue Oct 30 20:18:57 2012

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

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  150667264 bytes
Fixed Size                  1335080 bytes
Variable Size              92274904 bytes
Database Buffers           50331648 bytes
Redo Buffers                6725632 bytes


6. 在AUX端都配置ORACLE NET(LISTENER, TNS)

LISTENER:
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.102.189)(PORT = 1521))
    )
  )
ADR_BASE_LISTENER = /home/oracle
SID_LIST_LISTENER = 
  (SID_LIST = 
    (SID_DESC = 
      (GLOBAL_DBNAME = orcl) 
      (ORACLE_HOME = /home/oracle/product/11.2.0/db_1) 
      (SID_NAME = orcl) 
    ) 
  )
TNS:
target =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.102.188)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

aux =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.102.189)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )


7. 用RMAN连接数据库

[oracle@localhost admin]$ rman target sys/admin@target auxiliary sys/admin@aux

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Oct 30 20:39:30 2012

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

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


8。COPY数据库

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

Starting Duplicate Db at 30-OCT-12
using channel ORA_AUX_DISK_1

contents of Memory Script:
{
   sql clone "create spfile from memory";
}
executing Memory Script

sql statement: create spfile from memory

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

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     150667264 bytes

Fixed Size                     1335080 bytes
Variable Size                 92274904 bytes
Database Buffers              50331648 bytes
Redo Buffers                   6725632 bytes

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 = 
 ''ORCL'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   backup as copy current controlfile auxiliary format  '/home/oracle/product/11.2.0/db_1/dbs/cntrlorcl.dbf';
   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 =  ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     150667264 bytes

Fixed Size                     1335080 bytes
Variable Size                 92274904 bytes
Database Buffers              50331648 bytes
Redo Buffers                   6725632 bytes

Starting backup at 30-OCT-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=21 device type=DISK
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/home/oracle/product/11.2.0/db_1/dbs/snapcf_orcl.f tag=TAG20121030T205241 RECID=2 STAMP=798065569
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:16
Finished backup at 30-OCT-12

database mounted

contents of Memory Script:
{
   set newname for datafile  1 to 
 "/home/oracle/oradata/orcl/system01.dbf";
   set newname for datafile  2 to 
 "/home/oracle/oradata/orcl/sysaux01.dbf";
   set newname for datafile  3 to 
 "/home/oracle/oradata/orcl/undotbs01.dbf";
   set newname for datafile  4 to 
 "/home/oracle/oradata/orcl/users01.dbf";
   set newname for datafile  5 to 
 "/home/oracle/oradata/orcl/example01.dbf";
   backup as copy reuse
   datafile  1 auxiliary format 
 "/home/oracle/oradata/orcl/system01.dbf"   datafile 
 2 auxiliary format 
 "/home/oracle/oradata/orcl/sysaux01.dbf"   datafile 
 3 auxiliary format 
 "/home/oracle/oradata/orcl/undotbs01.dbf"   datafile 
 4 auxiliary format 
 "/home/oracle/oradata/orcl/users01.dbf"   datafile 
 5 auxiliary format 
 "/home/oracle/oradata/orcl/example01.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 30-OCT-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/home/oracle/oradata/orcl/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=798065803 file name=/home/oracle/oradata/orcl/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=798065803 file name=/home/oracle/oradata/orcl/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=798065803 file name=/home/oracle/oradata/orcl/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=6 STAMP=798065803 file name=/home/oracle/oradata/orcl/example01.dbf

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

executing command: SET until clause

Starting recover at 30-OCT-12
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=96 device type=DISK

starting media recovery

archived log for thread 1 with sequence 7 is already on disk as file /home/oracle/product/11.2.0/db_1/dbs/arch1_7_798062273.dbf
archived log file name=/home/oracle/product/11.2.0/db_1/dbs/arch1_7_798062273.dbf thread=1 sequence=7
media recovery complete, elapsed time: 00:00:03
Finished recover at 30-OCT-12

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

Fixed Size                     1335080 bytes
Variable Size                 92274904 bytes
Database Buffers              50331648 bytes
Redo Buffers                   6725632 bytes

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

Fixed Size                     1335080 bytes
Variable Size                 92274904 bytes
Database Buffers              50331648 bytes
Redo Buffers                   6725632 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL" RESETLOGS ARCHIVELOG 
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( '/home/oracle/oradata/orcl/redo01.log' ) SIZE 50 M  REUSE,
  GROUP  2 ( '/home/oracle/oradata/orcl/redo02.log' ) SIZE 50 M  REUSE,
  GROUP  3 ( '/home/oracle/oradata/orcl/redo03.log' ) SIZE 50 M  REUSE
 DATAFILE
  '/home/oracle/oradata/orcl/system01.dbf'
 CHARACTER SET ZHS16GBK


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

executing command: SET NEWNAME

renamed tempfile 1 to /home/oracle/oradata/orcl/temp01.dbf in control file

cataloged datafile copy
datafile copy file name=/home/oracle/oradata/orcl/sysaux01.dbf RECID=1 STAMP=798065839
cataloged datafile copy
datafile copy file name=/home/oracle/oradata/orcl/undotbs01.dbf RECID=2 STAMP=798065839
cataloged datafile copy
datafile copy file name=/home/oracle/oradata/orcl/users01.dbf RECID=3 STAMP=798065839
cataloged datafile copy
datafile copy file name=/home/oracle/oradata/orcl/example01.dbf RECID=4 STAMP=798065839

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=798065839 file name=/home/oracle/oradata/orcl/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=798065839 file name=/home/oracle/oradata/orcl/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=798065839 file name=/home/oracle/oradata/orcl/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=798065839 file name=/home/oracle/oradata/orcl/example01.dbf

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

database opened
Finished Duplicate Db at 30-OCT-12


9. 查看数据库状态

SQL> select status from v$instance;

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

 


 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值