RMAN duplicate迁移数据库(不同目录)

备份主数据库
----------------------------------------------------------------------------
run {
      configure retention policy to redundancy 2;
      allocate channel ch1 type disk;
      backup database
      format '/software/backup/%d_dbfile_%I_%T_%s'
      include current controlfile
      plus archivelog format='/software/backup/%d_arcfile_%I_%T_%s' delete input;
      delete noprompt obsolete;
      release channel ch1;
    }
----------------------------------------------------------------------------

配置监听(参考双实例监听设置)
listener.ora 文件
----------------------------------------------------------------------------
    (SID_DESC =
        (GLOBAL_DBNAME = oratest)
        (ORACLE_HOME = /u01/oracle/app/product)  
        (SID_NAME = oratest)
     )
    
    (SID_DESC =
        (GLOBAL_DBNAME = test)
        (ORACLE_HOME = /u01/oracle/app/product)  
        (SID_NAME = test)
     )
----------------------------------------------------------------------------

tnsnames.ora 文件
----------------------------------------------------------------------------
oratest =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.130)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = oratest)
    )
  )

test =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.130)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = test)
    )
  )
----------------------------------------------------------------------------

根据主数据库的参数文件创建辅助数据库参数文件
$ cat inittest.ora
----------------------------------------------------------------------------
test.__db_cache_size=92274688
test.__java_pool_size=4194304
test.__large_pool_size=4194304
test.__shared_pool_size=62914560
test.__streams_pool_size=0
*.audit_file_dest='/software/oracle/app2/admin/test/adump'
*.background_dump_dest='/software/oracle/app2/admin/test/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/software/oracle/app2/oradata/test/control01.ctl','/software/oracle/app2/oradata/test/control02.ctl','/software/oracle/app2/oradata/test/control03.ctl'
*.core_dump_dest='/software/oracle/app2/admin/test/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='test'
*.db_recovery_file_dest='/software/oracle/app2/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=testXDB)'
*.job_queue_processes=10
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=167772160
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/software/oracle/app2/admin/test/udump'
----------------------------------------------------------------------------

创建密码文件及相关目录
----------------------------------------------------------------------------
orapwd file=/u01/oracle/app/product/dbs/orapwtest password=password entries=3

mkdir -p /software/oracle/app2/oradata/test/
mkdir -p /software/oracle/app2/admin/test/adump
mkdir -p /software/oracle/app2/admin/test/bdump
mkdir -p /software/oracle/app2/admin/test/cdump
mkdir -p /software/oracle/app2/admin/test/udump
mkdir -p /software/oracle/app2/flash_recovery_area
----------------------------------------------------------------------------

查询主数据库控制文件、数据文件和临时表空间数据文件
-----------------------------------------------------
select name from v$controlfile;
select file#,name from v$datafile;
select file_id,file_name from dba_temp_files;
-----------------------------------------------------

启动建辅助数据库到nomount状态
-----------------------------------------------------------------
export ORACLE_SID=test
sqlplus / as sysdba
startup nomount pfile='/u01/oracle/app/product/dbs/inittest.ora'
exit;
-----------------------------------------------------------------

复制数据库
-----------------------------------------------------------------------------------------
export ORACLE_SID=test
rman target sys/password@oratest auxiliary sys/password@test
run {
 allocate auxiliary channel d1 type disk;
 set newname for datafile 1 to '/software/oracle/app2/oradata/test/system01.dbf';
 set newname for datafile 2 to '/software/oracle/app2/oradata/test/undotbs01.dbf';
 set newname for datafile 3 to '/software/oracle/app2/oradata/test/sysaux01.dbf';
 set newname for datafile 4 to '/software/oracle/app2/oradata/test/users01.dbf';
 set newname for tempfile 1 to '/software/oracle/app2/oradata/test/temp01.dbf';
 duplicate target database to "test"
 logfile
  '/software/oracle/app2/oradata/test/redo01.log' size 50M,
  '/software/oracle/app2/oradata/test/redo02.log' size 50M,
  '/software/oracle/app2/oradata/test/redo03.log' size 50M;
     }
-----------------------------------------------------------------------------------------

 

 

 


=========================================================================================
using target database control file instead of recovery catalog
allocated channel: d1
channel d1: sid=155 devtype=DISK

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting Duplicate Db at 15-APR-11

contents of Memory Script.:
{
   set until scn  483372;
   set newname for datafile  1 to
 "/software/oracle/app2/oradata/test/system01.dbf";
   set newname for datafile  2 to
 "/software/oracle/app2/oradata/test/undotbs01.dbf";
   set newname for datafile  3 to
 "/software/oracle/app2/oradata/test/sysaux01.dbf";
   set newname for datafile  4 to
 "/software/oracle/app2/oradata/test/users01.dbf";
   restore
   check readonly
   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

Starting restore at 15-APR-11

channel d1: starting datafile backupset restore
channel d1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /software/oracle/app2/oradata/test/system01.dbf
restoring datafile 00002 to /software/oracle/app2/oradata/test/undotbs01.dbf
restoring datafile 00003 to /software/oracle/app2/oradata/test/sysaux01.dbf
restoring datafile 00004 to /software/oracle/app2/oradata/test/users01.dbf
channel d1: reading from backup piece /software/backup/ORATEST_dbfile_3283858622_20110414_2
channel d1: restored backup piece 1
piece handle=/software/backup/ORATEST_dbfile_3283858622_20110414_2 tag=TAG20110414T230617
channel d1: restore complete, elapsed time: 00:00:36
Finished restore at 15-APR-11
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TEST" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 '/software/oracle/app2/oradata/test/redo01.log' SIZE 50 M ,
  GROUP  2 '/software/oracle/app2/oradata/test/redo02.log' SIZE 50 M ,
  GROUP  3 '/software/oracle/app2/oradata/test/redo03.log' SIZE 50 M
 DATAFILE
  '/software/oracle/app2/oradata/test/system01.dbf'
 CHARACTER SET AL32UTF8


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

datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=748508360 filename=/software/oracle/app2/oradata/test/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=748508360 filename=/software/oracle/app2/oradata/test/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=748508360 filename=/software/oracle/app2/oradata/test/users01.dbf

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

executing command: SET until clause

Starting recover at 15-APR-11

starting media recovery

archive log thread 1 sequence 4 is already on disk as file /u01/oracle/app/flash_recovery_area/ORATEST/archivelog/2011_04_15/o1_mf_1_4_6tgyvyw1_.arc
channel d1: starting archive log restore to default destination
channel d1: restoring archive log
archive log thread=1 sequence=3
channel d1: reading from backup piece /software/backup/ORATEST_arcfile_3283858622_20110414_4
channel d1: restored backup piece 1
piece handle=/software/backup/ORATEST_arcfile_3283858622_20110414_4 tag=TAG20110414T230731
channel d1: restore complete, elapsed time: 00:00:01
archive log filename=/software/oracle/app2/flash_recovery_area/TEST/archivelog/2011_04_15/o1_mf_1_3_6tgz2944_.arc thread=1 sequence=3
channel clone_default: deleting archive log(s)
archive log filename=/software/oracle/app2/flash_recovery_area/TEST/archivelog/2011_04_15/o1_mf_1_3_6tgz2944_.arc recid=1 stamp=748508361
archive log filename=/u01/oracle/app/flash_recovery_area/ORATEST/archivelog/2011_04_15/o1_mf_1_4_6tgyvyw1_.arc thread=1 sequence=4
media recovery complete, elapsed time: 00:00:07
Finished recover at 15-APR-11

contents of Memory Script.:
{
   shutdown clone;
   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     167772160 bytes

Fixed Size                     1218316 bytes
Variable Size                 71305460 bytes
Database Buffers              92274688 bytes
Redo Buffers                   2973696 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TEST" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 '/software/oracle/app2/oradata/test/redo01.log' SIZE 50 M ,
  GROUP  2 '/software/oracle/app2/oradata/test/redo02.log' SIZE 50 M ,
  GROUP  3 '/software/oracle/app2/oradata/test/redo03.log' SIZE 50 M
 DATAFILE
  '/software/oracle/app2/oradata/test/system01.dbf'
 CHARACTER SET AL32UTF8


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

executing command: SET NEWNAME

renamed temporary file 1 to /software/oracle/app2/oradata/test/temp01.dbf in control file

cataloged datafile copy
datafile copy filename=/software/oracle/app2/oradata/test/undotbs01.dbf recid=1 stamp=748508640

cataloged datafile copy
datafile copy filename=/software/oracle/app2/oradata/test/sysaux01.dbf recid=2 stamp=748508641

cataloged datafile copy
datafile copy filename=/software/oracle/app2/oradata/test/users01.dbf recid=3 stamp=748508641

datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=748508640 filename=/software/oracle/app2/oradata/test/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=748508641 filename=/software/oracle/app2/oradata/test/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=748508641 filename=/software/oracle/app2/oradata/test/users01.dbf

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

database opened
Finished Duplicate Db at 15-APR-11

RMAN>

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

转载于:http://blog.itpub.net/17012874/viewspace-693306/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值