共计 4606 个字符,预计需要花费 12 分钟才能阅读完成。
本篇文章为大家展示了 windows2008 Oracle 如何通过 rman 进行增量迁移,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。
环境介绍:windows2008R2 Oracle11.2.0.1 非归档模式
迁移过程:
修改归档:
点击 (此处) 折叠或打开
alter system set log_archive_dest_1= location=d:\archivelog scope=spfile;
shutdown immediate;
startup mount;
alter database archivelog;
alter database open
通过 rman 进行全备,当然也可以进行 0 级备份,后续增量备份,这里使用归档日志方式进行追加数据。
点击 (此处) 折叠或打开
run {
allocate channel ch2 type disk;
allocate channel ch3 type disk;
allocate channel ch4 type disk;
allocate channel ch5 type disk;
sql alter system archive log current
sql alter system archive log current
backup format E:\rmanbackup\orcl_full_%T_%s_%p database plus archivelog delete all input;
backup format E:\rmanbackup\orcl_controlfile_%T_%s_%p current controlfile;
sql alter system archive log current
backup format E:\rmanbackup\orcl_arch_%Y%M%D_%s_%p archivelog all;
release channel ch2;
release channel ch3;
release channel ch4;
release channel ch5;
}
生成 pfile 文件
点击 (此处) 折叠或打开
create pfile= d:\pfile20170721.ora from spfile
目标端创建实例:
点击 (此处) 折叠或打开
oradim -new -sid orcl
将备份文件、参数文件、密码文件拷贝至目标端
编辑 pfile 文件,创建相关目录,修改相关参数(如 sga、pga 等)
点击 (此处) 折叠或打开
md D:\app\Administrator\admin\orcl\adump
md D:\app\Administrator\admin\orcl\dpdump
md D:\app\Administrator\oradata\orcl
启动 nomount 阶段
点击 (此处) 折叠或打开
create spfile from pfile= d:\pfile20170721.ora
startup nomount
恢复控制文件:
点击 (此处) 折叠或打开
– 恢复控制文件,注意修改备份的控制文件名
restore controlfile from D:\rmanbackup\ORCL_CONTROLFILE_20170731_74_1
– 启动到 mount 阶段
sql alter database mount
恢复数据文件:
点击 (此处) 折叠或打开
catalog start with D:\rmanbackup
– 查看对应数据文件
– 查看对应的表空间、数据文件信息
set lines 150
col tname for a10
col dname for a65
select t.ts#,t.name tname,d.file#,d.name dname,d.status from v$tablespace t,v$datafile d where t.ts#=d.ts#;
– 对数据文件重命名查询语句
select set newname for datafile ||d.file#|| to ||d.name|| from v$datafile d,v$tablespace t where d.ts#=t.ts# and t.INCLUDED_IN_DATABASE_BACKUP= YES
– 更改目标盘符,这里是 d: 原来为 E
——————————
– 恢复数据文件 跟客户通过,数据文件目录 XHLISDB 不变
run{
set newname for datafile 1 to D:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF
set newname for datafile 2 to D:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBF
set newname for datafile 3 to D:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBF
set newname for datafile 4 to D:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBF
…………
restore database;
switch datafile all;
}
– 修改 redo 位置
点击 (此处) 折叠或打开
– 查看 redo 路径
select * from v$logfile;
– 修改 redo 路径, 查看路径后,如路径不对,修改为目标路径
select alter database rename file ||member|| to ||member|| from v$logfile;
alter database rename file E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO002.LOG to D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO002.LOG
alter database rename file E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO003.LOG to D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO003.LOG
alter database rename file E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO001.LOG to D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO001.LOG
alter database rename file E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO004.LOG to D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO004.LOG
alter database rename file E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO005.LOG to D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO005.LOG
alter database rename file E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO006.LOG to D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO006.LOG
alter database rename file E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO007.LOG to D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO007.LOG
alter database rename file E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO008.LOG to D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO008.LOG
alter database rename file E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO009.LOG to D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO009.LOG
alter database rename file E:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO010.LOG to D:\APP\ADMINISTRATOR\ORADATA\ORCL\REDO010.LOG
==================================================================================
开始切换数据库:
点击 (此处) 折叠或打开
– 停止原库监听,手动切换几次归档
alter system archive log current;
– 确保数据库数据一致,重启数据库实例,再次切换几次归档
alter system archive log current;
– 备份归档
backup format E:\rmanbackup\orcl_arch_%T_%s_%p archivelog all
附:使用增量
点击 (此处) 折叠或打开
– 也可以使用增量的方式(主要相关语句, 具体参考其他文件)
select current_scn from v$database;
BACKUP INCREMENTAL FROM SCN 1013684 DATABASE FORMAT E:\rmanbackup\orcl_incr_%T_%s_%p
backup current controlfile format E:\rmanbackup\orcl_arch_%T_%s_%p
recover database noredo
拷贝文件到目标服务器:
开始恢复:
点击 (此处) 折叠或打开
catalog start with D:\rmanbackup\ORCL_ARCH_20170721_61_1
list backup of archivelog all;
– 归档日志备份最早序号开始
restore archivelog from sequence 57;
– 将数据库实例恢复至最后一个归档文件序号
recover database until sequence 63;
–open
alter database open resetlogs;
– 修改临时表空间
alter database tempfile D:\APP\ADMINISTRATOR\ORADATA\ORCL\TEMP01.DBF drop;
ALTER TABLESPACE TEMP ADD TEMPFILE D:\APP\ADMINISTRATOR\ORADATA\ORCL\TEMP01.DBF SIZE 10G autoextend on
注意:通过 oradim 命令创建实例,开机无法自动启动实例,可修改注册表修改。ORA_CTY1_AUTOSTART 默认为 false,修改为 true。也可以执行下面命令:
点击 (此处) 折叠或打开
oradim.exe -NEW -SID orcl -INTPWD oracle -STARTMODE auto -PFILE D:\Agilent\Oracle\Admin\..\initorcl.ora
恢复后,建议进行数据库、系统相关检查。
上述内容就是 windows2008 Oracle 如何通过 rman 进行增量迁移,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注丸趣 TV 行业资讯频道。