本篇文章为大家展示了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:rmanbackuporcl_full_%T_%s_%p’ database plus archivelog delete all input;
backup format ‘E:rmanbackuporcl_controlfile_%T_%s_%p’ current controlfile;
sql ‘alter system archive log current’;
backup format ‘E:rmanbackuporcl_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:appAdministratoradminorcladump
md D:appAdministratoradminorcldpdump
md D:appAdministratororadataorcl 启动nomount阶段
点击(此处)折叠或打开 create spfile from pfile=’d:pfile20170721.ora’;
startup nomount
恢复控制文件:
点击(此处)折叠或打开 –恢复控制文件 ,注意修改备份的控制文件名
restore controlfile from ‘D:rmanbackupORCL_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:APPADMINISTRATORORADATAORCLSYSTEM01.DBF’;
set newname for datafile 2 to ‘D:APPADMINISTRATORORADATAORCLSYSAUX01.DBF’;
set newname for datafile 3 to ‘D:APPADMINISTRATORORADATAORCLUNDOTBS01.DBF’;
set newname for datafile 4 to ‘D:APPADMINISTRATORORADATAORCLUSERS01.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:APPADMINISTRATORORADATAORCLREDO002.LOG’ to ‘D:APPADMINISTRATORORADATAORCLREDO002.LOG’;
alter database rename file ‘E:APPADMINISTRATORORADATAORCLREDO003.LOG’ to ‘D:APPADMINISTRATORORADATAORCLREDO003.LOG’;
alter database rename file ‘E:APPADMINISTRATORORADATAORCLREDO001.LOG’ to ‘D:APPADMINISTRATORORADATAORCLREDO001.LOG’;
alter database rename file ‘E:APPADMINISTRATORORADATAORCLREDO004.LOG’ to ‘D:APPADMINISTRATORORADATAORCLREDO004.LOG’;
alter database rename file ‘E:APPADMINISTRATORORADATAORCLREDO005.LOG’ to ‘D:APPADMINISTRATORORADATAORCLREDO005.LOG’;
alter database rename file ‘E:APPADMINISTRATORORADATAORCLREDO006.LOG’ to ‘D:APPADMINISTRATORORADATAORCLREDO006.LOG’;
alter database rename file ‘E:APPADMINISTRATORORADATAORCLREDO007.LOG’ to ‘D:APPADMINISTRATORORADATAORCLREDO007.LOG’;
alter database rename file ‘E:APPADMINISTRATORORADATAORCLREDO008.LOG’ to ‘D:APPADMINISTRATORORADATAORCLREDO008.LOG’;
alter database rename file ‘E:APPADMINISTRATORORADATAORCLREDO009.LOG’ to ‘D:APPADMINISTRATORORADATAORCLREDO009.LOG’;
alter database rename file ‘E:APPADMINISTRATORORADATAORCLREDO010.LOG’ to ‘D:APPADMINISTRATORORADATAORCLREDO010.LOG’
==================================================================================
开始切换数据库:
点击(此处)折叠或打开 –停止原库监听,手动切换几次归档
alter system archive log current;
–确保数据库数据一致,重启数据库实例,再次切换几次归档
alter system archive log current;
–备份归档
backup format ‘E:rmanbackuporcl_arch_%T_%s_%p’ archivelog all
附:使用增量
点击(此处)折叠或打开 –也可以使用增量的方式(主要相关语句,具体参考其他文件 )
select current_scn from v$database;
BACKUP INCREMENTAL FROM SCN 1013684 DATABASE FORMAT ‘E:rmanbackuporcl_incr_%T_%s_%p’;
backup current controlfile format ‘E:rmanbackuporcl_arch_%T_%s_%p’;
recover database noredo
拷贝文件到目标服务器:
开始恢复:
点击(此处)折叠或打开 catalog start with ‘D:rmanbackupORCL_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:APPADMINIS免费主机域名TRATORORADATAORCLTEMP01.DBF’ drop;
ALTER TABLESPACE TEMP ADD TEMPFILE ‘D:APPADMINISTRATORORADATAORCLTEMP01.DBF’ SIZE 10G autoextend on
注意:通过oradim 命令创建实例,开机无法自动启动实例,可修改注册表修改。ORA_CTY1_AUTOSTART 默认为false,修改为true。也可以执行下面命令:
点击(此处)折叠或打开 oradim.exe -NEW -SID orcl -INTPWD oracle -STARTMODE auto -PFILE “D:AgilentOracl免费主机域名eAdmin..initorcl.ora”
恢复后,建议进行数据库、系统相关检查。
上述内容就是windows2008 Oracle如何通过rman进行增量迁移,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注云技术行业资讯频道。
这篇文章给大家分享的是有关SQL语句编写注意点有哪些的内容。小免费主机域名编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。1、使用英文模式下的 “`” 注意此处不是单引号 正确格式免费主机域名: 错误格式: 2、SQL语句书写,在SQL语句的引…