Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1424039
  • 博文数量: 314
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 3473
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-07 08:51
个人简介

偶尔有空上来看看

文章分类

全部博文(314)

文章存档

2021年(46)

2020年(115)

2019年(11)

2018年(9)

2017年(9)

2016年(17)

2015年(7)

2014年(4)

2013年(1)

2012年(11)

2011年(27)

2010年(35)

2009年(11)

2008年(11)

分类: Oracle

2011-01-11 17:15:30

windows环境
oracle 10.2.0.1
源库:192.168.1.81
目标库:192.168.1.2
 
主要流程:
停止源库->备份->恢复->改数据文件位置->resetlogs打开
 
迁移数据库81 到192.168.1.2上
停81库,设置归档路径,将其启动到归档模式,
以administrator身份启动数据库服务oracleserviceorcl
备份测试
C:\>set oracle_sid=orcl
C:\>rman target /
RMAN> backup current controlfile format '\\192.168.1.2\oradata\81\cf_%U';
 
全备
run {
backup as compressed backupset database
 format '\\192.168.1.2\oradata\81\dbfull_%d_%T_%s';
sql 'alter system archive log current';
}

搜集信息
sqlplus "/as sysdba"
set linesize 130 pagesize 2000
set trimspool on
set echo off
set verify off
set timing off
set feedback off
set head off
set echo off
spool renfile.sql

select 'set newname for datafile '''||name||''' to ''d:\oradata\81\'||  substr(name, instr(name, '\', -1) + 1)||'''; ' cmd  from v$datafile
union all
select 'set newname for tempfile '''||name||''' to ''d:\oradata\81\'||  substr(name, instr(name, '\', -1) + 1)||'''; ' cmd  from v$tempfile;
spool off

创建pfile文件,拷贝到目标位置
create pfile from spfile;
 
修改pfile文件中的路径,注意dump目录、控制文件目录、归档位置目录(最好将需要恢复的归档日志拷贝到此目录 以便恢复)

启动实例到nomount状态,恢复控制文件
set oracle_sid=orcl
rman target /
startup nomount
restore controlfile from 'd:\oradata\81\DBFULL_ORCL_20110111_21';  #控制文件得提前知道放哪了
也就是段句柄=\\192.168.1.2\ORADATA\81\DBFULL_ORCL_20110111_21
 
alter database mount;
catalog start with 'e:\oradata\bak' noprompt;  #备份集的位置指定一下
 
run{
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF' to 'd:\oradata\81\SYSTEM01.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\UNDOTBS01.DBF' to 'd:\oradata\81\UNDOTBS01.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSAUX01.DBF' to 'd:\oradata\81\SYSAUX01.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\USERS01.DBF' to 'd:\oradata\81\USERS01.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\EXAMPLE01.DBF' to 'd:\oradata\81\EXAMPLE01.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\test_01.DBF' to 'd:\oradata\81\test_01.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\test_02.DBF' to 'd:\oradata\81\test_02.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\test_0423_01.DBF' to 'd:\oradata\81\test_0423_01.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\test_0423_02.DBF' to 'd:\oradata\81\test_0423_02.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\test_0423_03.DBF' to 'd:\oradata\81\test_0423_03.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\test_0423_04.DBF' to 'd:\oradata\81\test_0423_04.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\test_03.DBF' to 'd:\oradata\81\test_03.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\test_04.DBF' to 'd:\oradata\81\test_04.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\test_05.DBF' to 'd:\oradata\81\test_05.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\test_06.DBF' to 'd:\oradata\81\test_06.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\test_07.DBF' to 'd:\oradata\81\test_07.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\AAA.DBF' to 'd:\oradata\81\AAA.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TS_EV_01.DBF' to 'd:\oradata\81\TS_EV_01.DBF';
set newname for datafile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TS_EV_02.DBF' to 'd:\oradata\81\TS_EV_02.DBF';
set newname for tempfile 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\TEMP01.DBF' to 'd:\oradata\81\TEMP01.DBF';
restore database;
switch datafile all;
switch tempfile all;
recover database;
#alter database open resetlogs;
}
 
如果缺少归档日志
run {
set ARCHIVELOG DESTINATION to 'd:\oradata\81\arch';
recover database;
}
 
sqlplus "/as sysdba"
alter database rename file 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO01.LOG' to 'd:\oradata\81\redo01.dbf';
alter database rename file 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG' to 'd:\oradata\81\redo02.dbf';
alter database rename file 'D:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO03.LOG' to 'd:\oradata\81\redo03.dbf';
 
检查控制文件、数据文件、日志文件、临时文件位置是否正确。

参考:
run {
 ALLOCATE CHANNEL dev1 DEVICE TYPE DISK;
 ALLOCATE CHANNEL dev2 DEVICE TYPE DISK;
 backup full tag 'dbfullbak' database  maxsetsize 30g
 include current controlfile format '\\192.168.1.2\oradata\81\dbfull_%U'
 plus archivelog format '\\192.168.1.2\oradata\81\arch_%U' delete all input;
}

 
阅读(1728) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2011-03-08 13:43:25

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com

chinaunix网友2011-01-11 17:33:07

tnsnames.ora lsnrctl stat