ITPub博客

首页 > Linux操作系统 > Linux操作系统 > RMAN实战系列之一:用duplicate复制数据库

RMAN实战系列之一:用duplicate复制数据库

原创 Linux操作系统 作者:husthxd 时间:2004-09-22 00:00:00 0 删除 编辑

rman实验(1)


本文可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本声明

http://blog.itpub.net/post/11/2317

RMAN实战系列之一:用duplicate复制数据库

源平台:

windows 2000

hostname=host1

ORACLE_BASE=e:oracle

目标平台:

windows 2000

hostname=host2

ORACLE_BASE=d:oracle

db_name=hyb

数据库版本:Oracle 9.0.1

目的:在host2上复制host1的数据库

 

1.       假定在host2上已经安装好了数据库软件,以OFA的结构建立新数据库的目录架构,把host1上的初始化参数文件拷贝到host2上,修改以下参数:

control_files/user_dump_dest/ background_dump_dest/ core_dump_dest

以及其他必须的参数。如

background_dump_dest=D:oracleadminhybbdump

core_dump_dest=D:oracleadminhybcdump

user_dump_dest=D:oracleadminhybudump

control_files=("D:oracleoradatahybCONTROL01.CTL", "D:oracleoradatahybCONTROL02.CTL", "D:oracleoradatahybCONTROL03.CTL")

oradim创建windows服务:

oradmin –new –sid hyb –pfile d:oracleadminhybpfileinit.ora

orapwd创建密码文件:

orapwd file=d:oracleora90databasepwdhyb.ora password=oracle entries=5

2.       启动sqlplus,创建spifle,并startup到nomount状态

create spfile from pfile=’ d:oracleadminhybpfileinit.ora’;

startup nomount;

    3.       host1上全备份数据库和归档日志

rman>configure channel device type disk format “e:rman%t%U.bak”;

rman>backup database plus archivelog;

4.       host2上e盘中建立rman目录,把host1上的rman全备份拷贝到host2对应的rman目录上。

5.       由于host2的目录结构与host1不一致,使用SET NEWNAMW改变数据文件的路径,使用logfile子句修改重做日志文件的位置。

6.       启动rman,连接到目标数据库、恢复目录数据库和辅助数据库。

7.       用命令DUPLICATE探测数据文件的位置,使用rman提示符中显示的脚本:

rman>duplicate target database to hyb logfile 'D:ORACLEoradatahyb redo01.log' size 10m, 'D:ORACLEoradatahybredo02.log' size 10m nofilenamecheck;

上述命令会出错:

RMAN-10035: exception raised in RPC: ORA-19624: 操作失败,如果可能请重试

ORA-19504: 无法创建文件"E:ORACLEORADATASIMISSIDB_RBS.ORA"

ORA-27040: skgfrcre: 创建错误,无法创建文件

OSD-04002: 无法打开文件

O/S-Error: (OS 3) 系统找不到指定的路径。

ORA-06512: 在"SYS.X$DBMS_BACKUP_RESTORE", line 1358

RMAN-10031: ORA-19624 occurred during call to DBMS_BACKUP_RESTORE.RESTOREBACKUPPIECE

无需理会,需要的是其中的脚本:

正在打印存储的脚本: Memory Script

{

   set until scn  766952815;

   set newname for datafile  1 to

 "D:ORACLEORADATASIMISSYSTEM01.DBF";

   set newname for datafile  2 to

 "D:ORACLEORADATASIMISUNDOTBS01.DBF";

   set newname for datafile  3 to

 "D:ORACLEORADATASIMISCWMLITE01.DBF";

   set newname for datafile  4 to

 "D:ORACLEORADATASIMISDRSYS01.DBF";

   set newname for datafile  5 to

 "D:ORACLEORADATASIMISEXAMPLE01.DBF";

   set newname for datafile  6 to

 "D:ORACLEORADATASIMISINDX01.DBF";

   set newname for datafile  7 to

 "D:ORACLEORADATASIMISTOOLS01.DBF";

   set newname for datafile  8 to

 "D:ORACLEORADATASIMISUSERS01.DBF";

   set newname for datafile  9 to

 "E:ORACLEORADATASIMISSIDB.ORA";

   set newname for datafile  10 to

 "E:ORACLEORADATASIMISYB.ORA";

   set newname for datafile  11 to

 "E:ORACLEORADATASIMISZS.ORA";

   set newname for datafile  12 to

 "E:ORACLEORADATASIMISFF.ORA";

   set newname for datafile  13 to

 "E:ORACLEORADATASIMISBM.ORA";

   set newname for datafile  14 to

 "E:ORACLEORADATASIMISSIDB_INDEX.ORA";

   set newname for datafile  15 to

 "E:ORACLEORADATASIMISPHOTO.ORA";

   set newname for datafile  16 to

 "E:ORACLEORADATASIMISHIS.ORA";

   set newname for datafile  17 to

 "E:ORACLEORADATASIMISSIDB_RBS.ORA";

   set newname for datafile  18 to

 "F:ORACLEORADATASIMISGRYSZM1994.ORA";

   set newname for datafile  19 to

 "F:ORACLEORADATASIMISGRYSZM1995.ORA";

   set newname for datafile  20 to

 "F:ORACLEORADATASIMISGRYSZM1996.ORA";

   set newname for datafile  21 to

 "F:ORACLEORADATASIMISGRYSZM1997.ORA";

   set newname for datafile  22 to

 "F:ORACLEORADATASIMISGRYSZM1998.ORA";

   set newname for datafile  23 to

 "F:ORACLEORADATASIMISGRYSZM1999.ORA";

   set newname for datafile  24 to

 "F:ORACLEORADATASIMISGRYSZM2000.ORA";

   set newname for datafile  25 to

 "F:ORACLEORADATASIMISGRYSZM2001.ORA";

   set newname for datafile  26 to

 "F:ORACLEORADATASIMISGRYSZM2002.ORA";

   set newname for datafile  27 to

 "F:ORACLEORADATASIMISGRYSZM2003.ORA";

   set newname for datafile  28 to

 "F:ORACLEORADATASIMISGRYSZM2004.ORA";

   set newname for datafile  29 to

 "F:ORACLEORADATASIMISGRYSZM2005.ORA";

   set newname for datafile  30 to

 "F:ORACLEORADATASIMISGRYSZM2006.ORA";

   set newname for datafile  31 to

 "F:ORACLEORADATASIMISGRYSZM2007.ORA";

   set newname for datafile  32 to

 "F:ORACLEORADATASIMISGRYSZM2008.ORA";

   set newname for datafile  33 to

 "F:ORACLEORADATASIMISGRYSZM_LOCAL_INDEX.ORA";

   set newname for datafile  34 to

 "F:ORACLEORADATASIMISGRYSZM_GLOBAL_INDEX.ORA";

   restore

   check readonly

   clone database

   ;

}

 

把该脚本拷贝到自己的run块中,修改必要的部分,本例如下:

run

{

set until scn  766952815;

   set newname for datafile  1 to

 "D:ORACLEORADATAHYBSYSTEM01.DBF";

   set newname for datafile  2 to

 "D:ORACLEORADATAHYBUNDOTBS01.DBF";

   set newname for datafile  3 to

 "D:ORACLEORADATAHYBCWMLITE01.DBF";

   set newname for datafile  4 to

 "D:ORACLEORADATAHYBDRSYS01.DBF";

   set newname for datafile  5 to

 "D:ORACLEORADATAHYBEXAMPLE01.DBF";

   set newname for datafile  6 to

 "D:ORACLEORADATAHYBINDX01.DBF";

   set newname for datafile  7 to

 "D:ORACLEORADATAHYBTOOLS01.DBF";

   set newname for datafile  8 to

 "D:ORACLEORADATAHYBUSERS01.DBF";

   set newname for datafile  9 to

 "D:ORACLEORADATAHYBSIDB.ORA";

   set newname for datafile  10 to

 "D:ORACLEORADATAHYBYB.ORA";

   set newname for datafile  11 to

 "D:ORACLEORADATAHYBZS.ORA";

   set newname for datafile  12 to

 "D:ORACLEORADATAHYBFF.ORA";

   set newname for datafile  13 to

 "D:ORACLEORADATAHYBBM.ORA";

   set newname for datafile  14 to

 "D:ORACLEORADATAHYBSIDB_INDEX.ORA";

   set newname for datafile  15 to

 "D:ORACLEORADATAHYBPHOTO.ORA";

   set newname for datafile  16 to

 "D:ORACLEORADATAHYBHIS.ORA";

   set newname for datafile  17 to

 "D:ORACLEORADATAHYBSIDB_RBS.ORA";

   set newname for datafile  18 to

 "D:ORACLEORADATAHYBGRYSZM1994.ORA";

   set newname for datafile  19 to

 "D:ORACLEORADATAHYBGRYSZM1995.ORA";

   set newname for datafile  20 to

 "D:ORACLEORADATAHYBGRYSZM1996.ORA";

   set newname for datafile  21 to

 "D:ORACLEORADATAHYBGRYSZM1997.ORA";

   set newname for datafile  22 to

 "D:ORACLEORADATAHYBGRYSZM1998.ORA";

   set newname for datafile  23 to

 "D:ORACLEORADATAHYBGRYSZM1999.ORA";

   set newname for datafile  24 to

 "D:ORACLEORADATAHYBGRYSZM2000.ORA";

   set newname for datafile  25 to

 "D:ORACLEORADATAHYBGRYSZM2001.ORA";

   set newname for datafile  26 to

 "D:ORACLEORADATAHYBGRYSZM2002.ORA";

   set newname for datafile  27 to

 "D:ORACLEORADATAHYBGRYSZM2003.ORA";

   set newname for datafile  28 to

 "D:ORACLEORADATAHYBGRYSZM2004.ORA";

   set newname for datafile  29 to

 "D:ORACLEORADATAHYBGRYSZM2005.ORA";

   set newname for datafile  30 to

 "D:ORACLEORADATAHYBGRYSZM2006.ORA";

   set newname for datafile  31 to

 "D:ORACLEORADATAHYBGRYSZM2007.ORA";

   set newname for datafile  32 to

 "D:ORACLEORADATAHYBGRYSZM2008.ORA";

   set newname for datafile  33 to

 "D:ORACLEORADATAHYBGRYSZM_LOCAL_INDEX.ORA";

   set newname for datafile  34 to

 "D:ORACLEORADATAHYBGRYSZM_GLOBAL_INDEX.ORA";

duplicate target database to hyb

logfile 'D:ORACLEoradatahybredo01.log' size 10m,

'D:ORACLEoradatahybredo02.log' size 10m,

'D:ORACLEoradatahybredo03.log' size 10m

nofilenamecheck;

}

注意设置nofilenamecheck选项,不然会出现错误:

RMAN-05001: auxiliary filename F:ORACLEORADATASIMIS GRYSZM_GLOBAL_INDEX.ORA conflicts with a file used by the target database

 

拷贝上述脚本在rman中执行,RMAN输出如下:

 

正在执行命令: SET until clause

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

正在执行命令: SET NEWNAME

 

启动 Duplicate Db 于 27-7月 -04

分配的通道: ORA_AUX_DISK_1

通道 ORA_AUX_DISK_1: sid=11 devtype=DISK

 

正在打印存储的脚本: Memory Script

{

   set until scn  766952815;

   set newname for datafile  1 to

 "D:ORACLEORADATAHYBSYSTEM01.DBF";

   set newname for datafile  2 to

 "D:ORACLEORADATAHYBUNDOTBS01.DBF";

   set newname for datafile  3 to

 "D:ORACLEORADATAHYBCWMLITE01.DBF";

   set newname for datafile  4 to

 "D:ORACLEORADATAHYBDRSYS01.DBF";

   set newname for datafile  5 to

 "D:ORACLEORADATAHYBEXAMPLE01.DBF";

   set newname for datafile  6 to

 "D:ORACLEORADATAHYBINDX01.DBF";

   set newname for datafile  7 to

 "D:ORACLEORADATAHYBTOOLS01.DBF";

   set newname for datafile  8 to

 "D:ORACLEORADATAHYBUSERS01.DBF";

   set newname for datafile  9 to

 "D:ORACLEORADATAHYBSIDB.ORA";

   set newname for datafile  10 to

 "D:ORACLEORADATAHYBYB.ORA";

   set newname for datafile  11 to

 "D:ORACLEORADATAHYBZS.ORA";

   set newname for datafile  12 to

 "D:ORACLEORADATAHYBFF.ORA";

   set newname for datafile  13 to

 "D:ORACLEORADATAHYBBM.ORA";

   set newname for datafile  14 to

 "D:ORACLEORADATAHYBSIDB_INDEX.ORA";

   set newname for datafile  15 to

 "D:ORACLEORADATAHYBPHOTO.ORA";

   set newname for datafile  16 to

 "D:ORACLEORADATAHYBHIS.ORA";

   set newname for datafile  17 to

 "D:ORACLEORADATAHYBSIDB_RBS.ORA";

   set newname for datafile  18 to

 "D:ORACLEORADATAHYBGRYSZM1994.ORA";

   set newname for datafile  19 to

 "D:ORACLEORADATAHYBGRYSZM1995.ORA";

   set newname for datafile  20 to

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

请登录后发表评论 登录
全部评论
ITPUB数据库版块资深版主,对Oracle、PostgreSQL有深入研究。

注册时间:2007-12-28

  • 博文量
    1397
  • 访问量
    3842308