windows2008 Oracle如何通过rman进行增量迁移

本篇文章为大家展示了windows2008 Oracle如何通过rman进行增量迁移,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。

环境介绍: windows2008R2 Oracle11.2.0.1  非归档模式

迁移过程:

修改归档:

点击(此处)折叠或打开

  1. alter system set log_archive_dest_1='location=d:/archivelog' scope=spfile;

  2. shutdown immediate;

  3. startup mount;

  4. alter database archivelog;

  5. alter database open

通过rman进行全备,当然也可以进行0级备份,后续增量备份,这里使用归档日志方式进行追加数据。

点击(此处)折叠或打开

  1. run {

  2.     allocate channel ch2 type disk;

  3.     allocate channel ch3 type disk;

  4.     allocate channel ch4 type disk;

  5.     allocate channel ch5 type disk;

  6.     sql 'alter system archive log current';

  7.     sql 'alter system archive log current';

  8.     backup format 'E:/rmanbackup/orcl_full_%T_%s_%p' database plus archivelog delete all input;

  9.     backup format 'E:/rmanbackup/orcl_controlfile_%T_%s_%p' current controlfile;

  10.     sql 'alter system archive log current';

  11.     backup format 'E:/rmanbackup/orcl_arch_%Y%M%D_%s_%p' archivelog all;

  12.     release channel ch2;

  13.     release channel ch3;

  14.     release channel ch4;

  15.     release channel ch5;

  16. }

生成pfile文件

点击(此处)折叠或打开

  1. create pfile='d:/pfile20170721.ora' from spfile

目标端创建实例:

点击(此处)折叠或打开

  1. oradim -new -sid orcl

将备份文件、参数文件、密码文件拷贝至目标端

编辑pfile文件,创建相关目录,修改相关参数(如sga、pga等)

点击(此处)折叠或打开

  1. md D:/app/Administrator/admin/orcl/adump

  2. md D:/app/Administrator/admin/orcl/dpdump

  3. md D:/app/Administrator/oradata/orcl

启动nomount阶段

点击(此处)折叠或打开

  1. create spfile from pfile='d:/pfile20170721.ora';

  2. startup nomount

恢复控制文件:

点击(此处)折叠或打开

  1. –恢复控制文件 ,注意修改备份的控制文件名

  2. restore controlfile from 'D:/rmanbackup/ORCL_CONTROLFILE_20170731_74_1';

  3. –启动到mount阶段

  4. sql 'alter database mount'

恢复数据文件:

点击(此处)折叠或打开

  1. catalog start with 'D:/rmanbackup';

  2. –查看对应数据文件

  3. –查看对应的表空间、数据文件信息

  4. set lines 150

  5. col tname for a10

  6. col dname for a65

  7. 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#;

  8. –对数据文件重命名查询语句

  9. 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';

  10. –更改目标盘符,这里是d: 原来为E

  11. ——————————

  12. –恢复数据文件  跟客户通过,数据文件目录XHLISDB不变

  13. run{

  14. set newname for datafile 1 to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/SYSTEM01.DBF';

  15. set newname for datafile 2 to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/SYSAUX01.DBF';

  16. set newname for datafile 3 to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/UNDOTBS01.DBF';

  17. set newname for datafile 4 to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/USERS01.DBF';

  18. …………

  19. restore database;

  20. switch datafile all;

  21. }

–修改redo 位置

点击(此处)折叠或打开

  1. –查看redo路径

  2. select * from v$logfile;

  3. –修改redo路径,查看路径后,如路径不对,修改为目标路径

  4. select 'alter database rename file '''||member||''' to '''||member||''';' from v$logfile;

  5. alter database rename file 'E:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO002.LOG' to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO002.LOG';

  6. alter database rename file 'E:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO003.LOG' to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO003.LOG';

  7. alter database rename file 'E:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO001.LOG' to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO001.LOG';

  8. alter database rename file 'E:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO004.LOG' to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO004.LOG';

  9. alter database rename file 'E:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO005.LOG' to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO005.LOG';

  10. alter database rename file 'E:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO006.LOG' to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO006.LOG';

  11. alter database rename file 'E:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO007.LOG' to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO007.LOG';

  12. alter database rename file 'E:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO008.LOG' to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO008.LOG';

  13. alter database rename file 'E:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO009.LOG' to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO009.LOG';

  14. alter database rename file 'E:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO010.LOG' to 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/REDO010.LOG'

==================================================================================
开始切换数据库:

点击(此处)折叠或打开

  1. –停止原库监听,手动切换几次归档

  2. alter system archive log current;

  3. –确保数据库数据一致,重启数据库实例,再次切换几次归档

  4. alter system archive log current;

  5. –备份归档

  6. backup format 'E:/rmanbackup/orcl_arch_%T_%s_%p' archivelog all

附:使用增量

点击(此处)折叠或打开

  1. –也可以使用增量的方式(主要相关语句,具体参考其他文件 )

  2. select current_scn from v$database;

  3. BACKUP INCREMENTAL FROM SCN 1013684 DATABASE FORMAT 'E:/rmanbackup/orcl_incr_%T_%s_%p';

  4. backup current controlfile format 'E:/rmanbackup/orcl_arch_%T_%s_%p';

  5. recover database noredo

拷贝文件到目标服务器
开始恢复:

点击(此处)折叠或打开

  1. catalog start with 'D:/rmanbackup/ORCL_ARCH_20170721_61_1';

  2. list backup of archivelog all;

  3. –归档日志备份最早序号开始

  4. restore archivelog from sequence 57;

  5.  

  6. –将数据库实例恢复至最后一个归档文件序号

  7. recover database until sequence 63;

  8. –open

  9. alter database open resetlogs;

  10. –修改临时表空间

  11. alter database tempfile 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/TEMP01.DBF' drop;

  12. ALTER TABLESPACE TEMP ADD TEMPFILE 'D:/APP/ADMINISTRATOR/ORADATA/ORCL/TEMP01.DBF' SIZE 10G autoextend on

注意:通过oradim 命令创建实例,开机无法自动启动实例,可修改注册表修改。ORA_CTY1_AUTOSTART  默认为false,修改为true。也可以执行下面命令:

点击(此处)折叠或打开

  1. oradim.exe -NEW -SID orcl -INTPWD oracle -STARTMODE auto -PFILE "D:/Agilent/Oracle/Admin/../initorcl.ora"

恢复后,建议进行数据库、系统相关检查。

上述内容就是windows2008 Oracle如何通过rman进行增量迁移,你们学到知识或技能了吗?如果还想学到更多技能或者丰富自己的知识储备,欢迎关注亿速云行业资讯频道。

原创文章,作者:kirin,如若转载,请注明出处:https://blog.ytso.com/203759.html

(0)
上一篇 2021年11月28日
下一篇 2021年11月28日

相关推荐

发表回复

登录后才能评论