duplicate(异机复制)

系统: redhat6.3
oracle版本: Release 11.2.0.1.0
俩虚拟机:
1、主机名为ACE的机器:装有数据库软件,且存在想要复制的目标数据库。
IP:192.168.0.3
2、主机名为LUFFY机器:存在数据库软件,但没建库。
IP:192.168.0.11
在LUFFY机器上的操作:
找到ACE上的口令文件(orapwtest)使用scp命令将其拷贝到LUFFY的相应目录
[oracle@LUFFY dbs]$ scp oracle@192.168.0.3:/u01/app/oracle/product/11.2.0/db_1/dbs/orapw* .


看下ACE上的inittest.ora文件
[oracle@ACE dbs]$ cat inittest.ora 
test.__db_cache_size=314572800
test.__java_pool_size=4194304
test.__large_pool_size=4194304
test.__oracle_base='/u01/app/oracle'
#ORACLE_BASE set from environment
test.__pga_aggregate_target=318767104
test.__sga_target=469762048
test.__shared_io_pool_size=0
test.__shared_pool_size=138412032
test.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/test/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/test/control01.ctl','/u01/app/oracle/flash_recovery_area/test/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='test'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4070572032
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=testXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=786432000
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
保证上面的路径在LUFFY上都存在


在LUFFY上配置静态监听(否则rman可能连不上来):
[oracle@LUFFY test]$ cat /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.


SID_LIST_TEST =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = test)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = test)
    )
  )  (SID_DESC =
    (GLOBAL_DBANAME = test)
    (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
    (SID_NAME = test)
  )
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ACE)(PORT = 1521))
    )
  )
ADR_BASE_LISTENER = /u01/app/oracle


需要添加的内容:
SID_LIST_LISTENER =
  ( SID_LIST =
      (SID_DESC =
         (GLOBAL_DBNAME = test)
  (ORACLE_HOME = /u01/app/oracle)  
/*路径根据你的.bash_profile视情况而定*/
         (SID_NAME = test)
      )
  )
ACE上的静态监听可配可不配


在ACE上的操作:
全备份数据库
注意要开启控制文件自动备份:
RMAN> show all;


RMAN configuration parameters for database with db_unique_name TEST are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/u01/bak/%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_test.f'; # default
没开启就configure CONTROLFILE AUTOBACKUP on;
然后全备:
RMAN> backup database plus archivelog delete input format '/u01/bak/dup_%U';
注意:照搬命令的孩子 注意 你是否存在/u01/bak目录  = =
在LUFFY机器上的操作:
将刚刚全备产生的四个备份集全部拷贝过来:
[oracle@LUFFY u01]$ cd bak/
[oracle@LUFFY bak]$ scp oracle@192.168.0.3:/u01/bak/dup_0ap45b01_1_1 .
oracle@192.168.0.3's password: 
dup_0ap45b01_1_1                              100%  148KB 147.5KB/s   00:00    
[oracle@LUFFY bak]$ scp oracle@192.168.0.3:/u01/bak/dup_0cp45b0i_1_1 .
oracle@192.168.0.3's password: 
dup_0cp45b0i_1_1                              100% 4096     4.0KB/s   00:00    
[oracle@LUFFY bak]$ scp oracle@192.168.0.3:/u01/bak/c-2140370986-20140326-01 .
oracle@192.168.0.3's password: 
c-2140370986-20140326-01                      100% 9600KB   9.4MB/s   00:00    
[oracle@LUFFY bak]$ scp oracle@192.168.0.3:/u01/app/oracle/flash_recovery_area/TEST/backupset/2014_03_26/o1_mf_nnndf_TAG20140326T143650_9m4xd2m4_.bkp .
oracle@192.168.0.3's password: 
o1_mf_nnndf_TAG20140326T143650_9m4xd2m4_.bkp  100% 1039MB  17.9MB/s   00:58    
[oracle@LUFFY bak]$ ls
c-2140370986-20140326-01  dup_0cp45b0i_1_1
dup_0ap45b01_1_1          o1_mf_nnndf_TAG20140326T143650_9m4xd2m4_.bkp


在/u01/app/oracle/product/11.2.0/db_1/dbs下建立参数文件 inittest.ora
编辑里面的内容为:
db_name=test
(仅此一句)
然后启动到nomount状态
连上rman
rman auxiliary /


RMAN> run{allocate auxiliary channel sup1 type disk;
duplicate database to 'test' spfile backup location '/u01/bak' nofilenamecheck;
}


重点来了:
注意看下面的rman都做了些什么。。。。。。
RMAN> 
Starting Duplicate Db at 26-MAR-14


contents of Memory Script:
{
   restore clone spfile to  '/u01/app/oracle/product/11.2.0/db_1/dbs/spfiletest.ora' from 
 '/u01/bak/c-2140370986-20140326-01';
   sql clone "alter system set spfile= ''/u01/app/oracle/product/11.2.0/db_1/dbs/spfiletest.ora''";
}
executing Memory Script


Starting restore at 26-MAR-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=19 device type=DISK


channel ORA_AUX_DISK_1: restoring spfile from AUTOBACKUP /u01/bak/c-2140370986-20140326-01
channel ORA_AUX_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 26-MAR-14


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


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


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


Oracle instance shut down


connected to auxiliary database (not started)
Oracle instance started


Total System Global Area     784998400 bytes


Fixed Size                     2217464 bytes
Variable Size                486541832 bytes
Database Buffers             293601280 bytes
Redo Buffers                   2637824 bytes


contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''TEST'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name = 
 ''TEST'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone primary controlfile from  '/u01/bak/c-2140370986-20140326-01';
   alter clone database mount;
}
executing Memory Script


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


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


Oracle instance shut down


Oracle instance started


Total System Global Area     784998400 bytes


Fixed Size                     2217464 bytes
Variable Size                486541832 bytes
Database Buffers             293601280 bytes
Redo Buffers                   2637824 bytes


Starting restore at 26-MAR-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 device type=DISK


channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/oracle/oradata/test/control01.ctl
output file name=/u01/app/oracle/flash_recovery_area/test/control02.ctl
Finished restore at 26-MAR-14


database mounted
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 device type=DISK
RMAN-05538: WARNING: implicitly using DB_FILE_NAME_CONVERT


contents of Memory Script:
{
   set until scn  1319128;
   set newname for datafile  1 to 
 "/u01/app/oracle/oradata/test/system01.dbf";
   set newname for datafile  2 to 
 "/u01/app/oracle/oradata/test/sysaux01.dbf";
   set newname for datafile  3 to 
 "/u01/app/oracle/oradata/test/undotbs01.dbf";
   set newname for datafile  4 to 
 "/u01/app/oracle/oradata/test/users01.dbf";
   set newname for datafile  5 to 
 "/u01/app/oracle/oradata/test/example01.dbf";
   restore
   clone database
   ;
}
executing Memory Script


executing command: SET until clause


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


executing command: SET NEWNAME


Starting restore at 26-MAR-14
using channel ORA_AUX_DISK_1


channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/test/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/test/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/test/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/test/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/test/example01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/bak/o1_mf_nnndf_TAG20140326T143650_9m4xd2m4_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/bak/o1_mf_nnndf_TAG20140326T143650_9m4xd2m4_.bkp tag=TAG20140326T143650
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:26
Finished restore at 26-MAR-14


contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script


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


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


executing command: SET until clause


Starting recover at 26-MAR-14
using channel ORA_AUX_DISK_1


starting media recovery


channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=21
channel ORA_AUX_DISK_1: reading from backup piece /u01/bak/dup_0cp45b0i_1_1
channel ORA_AUX_DISK_1: piece handle=/u01/bak/dup_0cp45b0i_1_1 tag=TAG20140326T143705
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
archived log file name=/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_03_26/o1_mf_1_21_9m4zp7qp_.arc thread=1 sequence=21
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oracle/flash_recovery_area/TEST/archivelog/2014_03_26/o1_mf_1_21_9m4zp7qp_.arc RECID=1 STAMP=843232584
media recovery complete, elapsed time: 00:00:03
Finished recover at 26-MAR-14


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


Fixed Size                     2217464 bytes
Variable Size                486541832 bytes
Database Buffers             293601280 bytes
Redo Buffers                   2637824 bytes


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


Fixed Size                     2217464 bytes
Variable Size                486541832 bytes
Database Buffers             293601280 bytes
Redo Buffers                   2637824 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TEST" 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/test/system01.dbf'
 CHARACTER SET WE8MSWIN1252




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


executing command: SET NEWNAME


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


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


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


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


database opened
Finished Duplicate Db at 26-MAR-14

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值