ORACLE RMAN ACTIVE COPY

来源:互联网 发布:求马士兵java视频教程 编辑:程序博客网 时间:2024/06/01 19:29

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.oraDB_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 sysdbaSQL*Plus: Release 11.2.0.1.0 Production on Tue Oct 30 20:18:57 2012Copyright (c) 1982, 2009, Oracle.  All rights reserved.Connected to an idle instance.SQL> startup nomount;ORACLE instance started.Total System Global Area  150667264 bytesFixed Size                  1335080 bytesVariable Size              92274904 bytesDatabase Buffers           50331648 bytesRedo 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/oracleSID_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@auxRecovery Manager: Release 11.2.0.1.0 - Production on Tue Oct 30 20:39:30 2012Copyright (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-12using channel ORA_AUX_DISK_1contents of Memory Script:{   sql clone "create spfile from memory";}executing Memory Scriptsql statement: create spfile from memorycontents of Memory Script:{   shutdown clone immediate;   startup clone nomount;}executing Memory ScriptOracle instance shut downconnected to auxiliary database (not started)Oracle instance startedTotal System Global Area     150667264 bytesFixed Size                     1335080 bytesVariable Size                 92274904 bytesDatabase Buffers              50331648 bytesRedo Buffers                   6725632 bytescontents 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 Scriptsql statement: alter system set  db_name =  ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfilesql statement: alter system set  db_unique_name =  ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfileOracle instance shut downOracle instance startedTotal System Global Area     150667264 bytesFixed Size                     1335080 bytesVariable Size                 92274904 bytesDatabase Buffers              50331648 bytesRedo Buffers                   6725632 bytesStarting backup at 30-OCT-12allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=21 device type=DISKchannel ORA_DISK_1: starting datafile copycopying current control fileoutput file name=/home/oracle/product/11.2.0/db_1/dbs/snapcf_orcl.f tag=TAG20121030T205241 RECID=2 STAMP=798065569channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:16Finished backup at 30-OCT-12database mountedcontents 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 Scriptexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEStarting backup at 30-OCT-12using channel ORA_DISK_1channel ORA_DISK_1: starting datafile copyinput datafile file number=00001 name=/home/oracle/oradata/orcl/system01.dbfdatafile 2 switched to datafile copyinput datafile copy RECID=3 STAMP=798065803 file name=/home/oracle/oradata/orcl/sysaux01.dbfdatafile 3 switched to datafile copyinput datafile copy RECID=4 STAMP=798065803 file name=/home/oracle/oradata/orcl/undotbs01.dbfdatafile 4 switched to datafile copyinput datafile copy RECID=5 STAMP=798065803 file name=/home/oracle/oradata/orcl/users01.dbfdatafile 5 switched to datafile copyinput datafile copy RECID=6 STAMP=798065803 file name=/home/oracle/oradata/orcl/example01.dbfcontents of Memory Script:{   set until scn  838430;   recover   clone database    delete archivelog   ;}executing Memory Scriptexecuting command: SET until clauseStarting recover at 30-OCT-12allocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: SID=96 device type=DISKstarting media recoveryarchived 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.dbfarchived log file name=/home/oracle/product/11.2.0/db_1/dbs/arch1_7_798062273.dbf thread=1 sequence=7media recovery complete, elapsed time: 00:00:03Finished recover at 30-OCT-12contents 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 Scriptdatabase dismountedOracle instance shut downconnected to auxiliary database (not started)Oracle instance startedTotal System Global Area     150667264 bytesFixed Size                     1335080 bytesVariable Size                 92274904 bytesDatabase Buffers              50331648 bytesRedo Buffers                   6725632 bytessql statement: alter system set  db_name =  ''ORCL'' comment= ''Reset to original value by RMAN'' scope=spfilesql statement: alter system reset  db_unique_name scope=spfileOracle instance shut downconnected to auxiliary database (not started)Oracle instance startedTotal System Global Area     150667264 bytesFixed Size                     1335080 bytesVariable Size                 92274904 bytesDatabase Buffers              50331648 bytesRedo Buffers                   6725632 bytessql 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 ZHS16GBKcontents 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 Scriptexecuting command: SET NEWNAMErenamed tempfile 1 to /home/oracle/oradata/orcl/temp01.dbf in control filecataloged datafile copydatafile copy file name=/home/oracle/oradata/orcl/sysaux01.dbf RECID=1 STAMP=798065839cataloged datafile copydatafile copy file name=/home/oracle/oradata/orcl/undotbs01.dbf RECID=2 STAMP=798065839cataloged datafile copydatafile copy file name=/home/oracle/oradata/orcl/users01.dbf RECID=3 STAMP=798065839cataloged datafile copydatafile copy file name=/home/oracle/oradata/orcl/example01.dbf RECID=4 STAMP=798065839datafile 2 switched to datafile copyinput datafile copy RECID=1 STAMP=798065839 file name=/home/oracle/oradata/orcl/sysaux01.dbfdatafile 3 switched to datafile copyinput datafile copy RECID=2 STAMP=798065839 file name=/home/oracle/oradata/orcl/undotbs01.dbfdatafile 4 switched to datafile copyinput datafile copy RECID=3 STAMP=798065839 file name=/home/oracle/oradata/orcl/users01.dbfdatafile 5 switched to datafile copyinput datafile copy RECID=4 STAMP=798065839 file name=/home/oracle/oradata/orcl/example01.dbfcontents of Memory Script:{   Alter clone database open resetlogs;}executing Memory Scriptdatabase openedFinished Duplicate Db at 30-OCT-12


9. 查看数据库状态

SQL> select status from v$instance;STATUS------------OPEN 


 

 

原创粉丝点击