RAMN复制数据库

target:rhel6  auxiliary:enmo




在auxiliary上面


建立一个参数文件让实例可以启动到nomount
[oracle@enmo dbs]$ vi initenmo.ora
db_name=enmo(就可以了)


密码文件必须得有
[oracle@enmo dbs]$ orapwd file='orapwenmo' password=oracle entries=10


然后依照target库建好路径,配置好监听和tnsnames.ora


[oracle@enmo admin]$ cat listener.ora 
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.


LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.180.13)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=enmo)
      (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME=enmo)))


ADR_BASE_LISTENER = /u01/app/oracle


[oracle@enmo admin]$ cat tnsnames.ora 


enmo =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.180.13)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = enmo)
    )
  )




rhel6 =(可以没有的)
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.180.12)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = rhel6)
    )
  )




[oracle@rhel6 admin]$ vi listener.ora 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = rhel6)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )
SID_LIST_LISTENER=
  (SID_LIST=
    (SID_DESC=
      (GLOBAL_DBNAME=rhel6)
      (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME=rhel6)))


[oracle@rhel6 admin]$ vi tnsnames.ora 


rhel6 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = rhel6)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = rhel6)
    )
  )




enmo =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.180.13)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = enmo)
    )
  )


执行命令


auxiliary库起到nomount


[oracle@enmo admin]$ sqlplus / as sysdba


SQL*Plus: Release 11.2.0.3.0 Production on Wed May 13 21:39:10 2015


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


startup nomConnected to an idle instance.


startup nomount
ORACLE instance started.


Total System Global Area  534462464 bytes
Fixed Size    2230072 bytes
Variable Size  343935176 bytes
Database Buffers  180355072 bytes
Redo Buffers    7942144 bytes






[oracle@rhel6 dbs]$ rman target sys/oracle@rhel6 auxiliary sys/oracle@enmo


Recovery Manager: Release 11.2.0.3.0 - Production on Wed May 13 20:54:33 2015


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


connected to target database: RHEL6 (DBID=1996153548)
connected to auxiliary database: ENMO (not mounted)


RMAN> duplicate database to enmo from active database password file spfile nofilenamecheck;


Starting Duplicate Db at 13-MAY-15
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK


contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwrhel6' auxiliary format 
 '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwenmo'   targetfile 
 '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilerhel6.ora' auxiliary format 
 '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileenmo.ora'   ;
   sql clone "alter system set spfile= ''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileenmo.ora''";
}
executing Memory Script


Starting backup at 13-MAY-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=130 device type=DISK
Finished backup at 13-MAY-15


sql statement: alter system set spfile= ''/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfileenmo.ora''


contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''ENMO'' comment=
 ''duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
}
executing Memory Script


sql statement: alter system set  db_name =  ''ENMO'' comment= ''duplicate'' scope=spfile


Oracle instance shut down


connected to auxiliary database (not started)
Oracle instance started


Total System Global Area     534462464 bytes


Fixed Size                     2230072 bytes
Variable Size                322963656 bytes
Database Buffers             201326592 bytes
Redo Buffers                   7942144 bytes


contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''RHEL6'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name = 
 ''ENMO'' 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/rhel6/control01.ctl';
   restore clone controlfile to  '/u01/app/oracle/fast_recovery_area/rhel6/control02.ctl' from 
 '/u01/app/oracle/oradata/rhel6/control01.ctl';
   restore clone controlfile to  '/u01/app/oracle/oradata/rhel6/control03.ctl' from 
 '/u01/app/oracle/oradata/rhel6/control01.ctl';
   alter clone database mount;
}
executing Memory Script


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


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


Oracle instance shut down


Oracle instance started


Total System Global Area     534462464 bytes


Fixed Size                     2230072 bytes
Variable Size                322963656 bytes
Database Buffers             201326592 bytes
Redo Buffers                   7942144 bytes


Starting backup at 13-MAY-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_rhel6.f tag=TAG20150513T205454 RECID=7 STAMP=879627295
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 13-MAY-15


Starting restore at 13-MAY-15
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 13-MAY-15


Starting restore at 13-MAY-15
using channel ORA_AUX_DISK_1


channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 13-MAY-15


database mounted
RMAN-05538: WARNING: implicitly using DB_FILE_NAME_CONVERT


contents of Memory Script:
{
   set newname for datafile  1 to 
 "/u01/app/oracle/oradata/rhel6/system01.dbf";
   set newname for datafile  2 to 
 "/u01/app/oracle/oradata/rhel6/sysaux01.dbf";
   set newname for datafile  3 to 
 "/u01/app/oracle/oradata/rhel6/undotbs01.dbf";
   set newname for datafile  4 to 
 "/u01/app/oracle/oradata/rhel6/users01.dbf";
   set newname for datafile  5 to 
 "/u01/app/oracle/oradata/rhel6/example01.dbf";
   backup as copy reuse
   datafile  1 auxiliary format 
 "/u01/app/oracle/oradata/rhel6/system01.dbf"   datafile 
 2 auxiliary format 
 "/u01/app/oracle/oradata/rhel6/sysaux01.dbf"   datafile 
 3 auxiliary format 
 "/u01/app/oracle/oradata/rhel6/undotbs01.dbf"   datafile 
 4 auxiliary format 
 "/u01/app/oracle/oradata/rhel6/users01.dbf"   datafile 
 5 auxiliary format 
 "/u01/app/oracle/oradata/rhel6/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 13-MAY-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/rhel6/system01.dbf
output file name=/u01/app/oracle/oradata/rhel6/system01.dbf tag=TAG20150513T205511
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:27
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/rhel6/undotbs01.dbf
output file name=/u01/app/oracle/oradata/rhel6/undotbs01.dbf tag=TAG20150513T205511
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:07:00
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/rhel6/sysaux01.dbf
output file name=/u01/app/oracle/oradata/rhel6/sysaux01.dbf tag=TAG20150513T205511
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:12:17
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/rhel6/example01.dbf
output file name=/u01/app/oracle/oradata/rhel6/example01.dbf tag=TAG20150513T205511
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:42
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/rhel6/users01.dbf
output file name=/u01/app/oracle/oradata/rhel6/users01.dbf tag=TAG20150513T205511
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 13-MAY-15


sql statement: alter system archive log current


contents of Memory Script:
{
   backup as copy reuse
   archivelog like  "/u01/app/oracle/fast_recovery_area/RHEL6/archivelog/2015_05_13/o1_mf_1_11_bo6mqxnv_.arc" auxiliary format 
 "/u01/app/oracle/fast_recovery_area/ENMO/archivelog/2015_05_13/o1_mf_1_11_%u_.arc"   ;
   catalog clone recovery area;
   switch clone datafile all;
}
executing Memory Script


Starting backup at 13-MAY-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread=1 sequence=11 RECID=22 STAMP=879628679
output file name=/u01/app/oracle/fast_recovery_area/ENMO/archivelog/2015_05_13/o1_mf_1_11_0vq6s4cb_.arc RECID=0 STAMP=0
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 13-MAY-15


searching for all files in the recovery area


List of Files Unknown to the Database
=====================================
File Name: /u01/app/oracle/fast_recovery_area/ENMO/archivelog/2015_05_13/o1_mf_1_11_0vq6s4cb_.arc
cataloging files...
cataloging done


List of Cataloged Files
=======================
File Name: /u01/app/oracle/fast_recovery_area/ENMO/archivelog/2015_05_13/o1_mf_1_11_0vq6s4cb_.arc


datafile 1 switched to datafile copy
input datafile copy RECID=7 STAMP=879628687 file name=/u01/app/oracle/oradata/rhel6/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=8 STAMP=879628687 file name=/u01/app/oracle/oradata/rhel6/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=9 STAMP=879628687 file name=/u01/app/oracle/oradata/rhel6/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=10 STAMP=879628687 file name=/u01/app/oracle/oradata/rhel6/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=11 STAMP=879628687 file name=/u01/app/oracle/oradata/rhel6/example01.dbf


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


executing command: SET until clause


Starting recover at 13-MAY-15
using channel ORA_AUX_DISK_1


starting media recovery


archived log for thread 1 with sequence 11 is already on disk as file /u01/app/oracle/fast_recovery_area/ENMO/archivelog/2015_05_13/o1_mf_1_11_0vq6s4cb_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/ENMO/archivelog/2015_05_13/o1_mf_1_11_0vq6s4cb_.arc thread=1 sequence=11
media recovery complete, elapsed time: 00:00:02
Finished recover at 13-MAY-15
Oracle instance started


Total System Global Area     534462464 bytes


Fixed Size                     2230072 bytes
Variable Size                339740872 bytes
Database Buffers             184549376 bytes
Redo Buffers                   7942144 bytes


contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''ENMO'' 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 =  ''ENMO'' 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     534462464 bytes


Fixed Size                     2230072 bytes
Variable Size                339740872 bytes
Database Buffers             184549376 bytes
Redo Buffers                   7942144 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ENMO" 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/rhel6/system01.dbf'
 CHARACTER SET AL32UTF8




contents of Memory Script:
{
   catalog clone datafilecopy  "/u01/app/oracle/oradata/rhel6/sysaux01.dbf", 
 "/u01/app/oracle/oradata/rhel6/undotbs01.dbf", 
 "/u01/app/oracle/oradata/rhel6/users01.dbf", 
 "/u01/app/oracle/oradata/rhel6/example01.dbf";
   switch clone datafile all;
}
executing Memory Script


cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rhel6/sysaux01.dbf RECID=1 STAMP=879628714
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rhel6/undotbs01.dbf RECID=2 STAMP=879628717
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rhel6/users01.dbf RECID=3 STAMP=879628718
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/rhel6/example01.dbf RECID=4 STAMP=879628719


datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=879628714 file name=/u01/app/oracle/oradata/rhel6/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=879628717 file name=/u01/app/oracle/oradata/rhel6/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=879628718 file name=/u01/app/oracle/oradata/rhel6/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=879628719 file name=/u01/app/oracle/oradata/rhel6/example01.dbf


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


database opened
Finished Duplicate Db at 13-MAY-15


最后 


SQL> show parameter name;


NAME     TYPE VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert     string
db_name     string ENMO
db_unique_name     string ENMO
global_names     boolean FALSE
instance_name     string enmo
lock_name_space     string
log_file_name_convert     string
processor_group_name     string
service_names     string ENMO


SQL> select status from v$instance;


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


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30166973/viewspace-1657287/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30166973/viewspace-1657287/

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值