设为首页 收藏本站
查看: 854|回复: 0

[经验分享] oracle备份恢复之rman恢复到异机(二)

[复制链接]

尚未签到

发表于 2018-9-11 11:28:15 | 显示全部楼层 |阅读模式
  转摘:http://jiujian.blog.51cto.com/444665/1085478
  注意事项:
  1 此处实验环境为同平台,同字节序,同版本,源机器和目标机器相同的目录结构。
  2 目标机器只需要安装oracle数据库软件即可。
  3 第一次利用备份恢复测试环境,之后从源机器拷贝备份到目标机器并在控制文件中注册,再见行恢复测试。
  一 拷贝参数文件备份、控制文件备份、数据文件备份、以及归档备份到新主机上
  1 rman 连接到源数据库
  [oracle@oracle dbs]$ rman target /

  Recovery Manager:>  Copyright (c) 1982, 2005, Oracle.  All rights reserved.
  connected to target database: CRM (DBID=3601019238)
  RMAN>
  2  分别列出参数文件备份,控制文件备份,数据文件备份,以及归档备份的名字
  参数文件备份如下:
  RMAN> list backup of spfile;

  BS Key  Type LV>  ------- ---- -- ---------- ----------- ------------ ---------------
  13      Full    7.11M      DISK        00:00:04     09-DEC-12
  BP Key: 13   Status: AVAILABLE  Compressed: NO  Tag: TAG20121209T040058
  Piece Name: /oracle/app/db1/dbs/0dnsd96i_1_1
  SPFILE Included: Modification time: 09-DEC-12
  控制文件备份如下:
  RMAN> list backup of controlfile;

  BS Key  Type LV>  ------- ---- -- ---------- ----------- ------------ ---------------
  13      Full    7.11M      DISK        00:00:04     09-DEC-12
  BP Key: 13   Status: AVAILABLE  Compressed: NO  Tag: TAG20121209T040058
  Piece Name: /oracle/app/db1/dbs/0dnsd96i_1_1
  Control File Included: Ckp SCN: 2779528241   Ckp time: 09-DEC-12
  数据文件备份如下:
  RMAN> list backup of database;

  BS Key  Type LV>  ------- ---- -- ---------- ----------- ------------ ---------------
  12      Full    599.38M    DISK        00:03:33     09-DEC-12
  BP Key: 12   Status: AVAILABLE  Compressed: NO  Tag: TAG20121209T040058
  Piece Name: /oracle/app/db1/dbs/0cnsd8vq_1_1
  List of Datafiles in backup set 12
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 2779528081 09-DEC-12 /oracle/test/system1.dbf
  2       Full 2779528081 09-DEC-12 /oracle/test/zxb.dbf
  3       Full 2779528081 09-DEC-12 /oracle/test/sysaux01.dbf
  4       Full 2779528081 09-DEC-12 /oracle/test/users01.dbf
  5       Full 2779528081 09-DEC-12 /oracle/test/zxa.dbf
  6       Full 2779528081 09-DEC-12 /oracle/test/test1.dbf
  7       Full 2779528081 09-DEC-12 /oracle/test/zxc.dbf
  8       Full 2779528081 09-DEC-12 /oracle/test/undotbs1.dbf
  9       Full 2779528081 09-DEC-12 /oracle/test/zxbig.dbf
  列出归档备份如下:
  RMAN> list backup of archivelog all;
  注意:归档的备份应该包括当前联机日志文件。
  3 copy 这些备份到新的主机
  二 恢复参数文件及控制文件
  1 配置新主机上的ORACLE_SID
  export   ORACLE_SID=CRM
  2 在新主机上发起rman连接
  [oracle@oracle dbs]$ rman target /

  Recovery Manager:>  Copyright (c) 1982, 2005, Oracle. All rights reserved.
  connected to target database (not started)
  3  设置dbid 并启动实例到nomount状态
  RMAN> set dbid 3601019238
  executing command: SET DBID
  RMAN> startup nomount
  startup failed: ORA-01078: failure in processing system parameters
  LRM-00109: could not open parameter file '/oracle/app/db1/dbs/initCRM.ora'
  starting Oracle instance without parameter file for retrival of spfile
  Oracle instance started
  Total System Global Area     159383552 bytes

  Fixed>
  Variable>  Database Buffers              83886080 bytes
  Redo Buffers                   6369280 bytes
  注意:在rman下即使没有参数文件,默认也会启动一个DUMMY实例,以便能够恢复参数文件。
  4  恢复spfile文件
  RMAN> restore spfile to '/oracle/app/db1/dbs/spfileCRM.ora' from '/oracle/app/db1/dbs/0dnsd96i_1_1';
  Starting restore at 10-DEC-12
  using target database control file instead of recovery catalog
  allocated channel: ORA_DISK_1
  channel ORA_DISK_1: sid=34 devtype=DISK
  channel ORA_DISK_1: autobackup found: /oracle/app/db1/dbs/0dnsd96i_1_1
  channel ORA_DISK_1: SPFILE restore from autobackup complete
  Finished restore at 10-DEC-12
  5 startup force nomount
  RMAN> startup force nomount;
  Oracle instance started
  Total System Global Area     322961408 bytes

  Fixed>
  Variable>  Database Buffers             218103808 bytes
  Redo Buffers                   6365184 bytes
  6 恢复控制文件
  RMAN> restore controlfile to '/oracle/CRM2/CRM/control01.ctl' from '/oracle/app/db1/dbs/0dnsd96i_1_1';
  Starting restore at 10-DEC-12
  allocated channel: ORA_DISK_1
  channel ORA_DISK_1: sid=210 devtype=DISK
  channel ORA_DISK_1: restoring control file
  channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
  Finished restore at 10-DEC-12
  cp /oracle/CRM2/CRM/control01.ctl /oracle/CRM2/CRM/control02.ctl
  7 启动数据库到加载状态

  RMAN>>  database mounted
  released channel: ORA_DISK_1
  三  在新控制文件中注册数据文件备份和归档备份
  RMAN> catalog start with '/backup/';
  searching for all files that match the pattern /backup/
  List of Files Unknown to the Database
  =====================================
  File Name: /backup/0ensd96n_1_1
  File Name: /backup/0bnsd8vn_1_1
  File Name: /backup/0cnsd8vq_1_1
  Do you really want to catalog the above files (enter YES or NO)? yes
  cataloging files...
  cataloging done
  List of Cataloged Files
  =======================
  File Name: /backup/0ensd96n_1_1
  File Name: /backup/0bnsd8vn_1_1
  File Name: /backup/0cnsd8vq_1_1
  四  恢复整个库
  1 RMAN> restore database;
  Starting restore at 10-DEC-12
  allocated channel: ORA_DISK_1
  channel ORA_DISK_1: sid=209 devtype=DISK
  channel ORA_DISK_1: starting datafile backupset restore
  channel ORA_DISK_1: specifying datafile(s) to restore from backup set
  restoring datafile 00001 to /oracle/test/system1.dbf
  restoring datafile 00002 to /oracle/test/zxb.dbf
  restoring datafile 00003 to /oracle/test/sysaux01.dbf
  restoring datafile 00004 to /oracle/test/users01.dbf
  restoring datafile 00005 to /oracle/test/zxa.dbf
  restoring datafile 00006 to /oracle/test/test1.dbf
  restoring datafile 00007 to /oracle/test/zxc.dbf
  restoring datafile 00008 to /oracle/test/undotbs1.dbf
  restoring datafile 00009 to /oracle/test/zxbig.dbf
  channel ORA_DISK_1: reading from backup piece /oracle/app/db1/dbs/0cnsd8vq_1_1
  channel ORA_DISK_1: restored backup piece 1
  piece handle=/oracle/app/db1/dbs/0cnsd8vq_1_1 tag=TAG20121209T040058
  channel ORA_DISK_1: restore complete, elapsed time: 00:02:56
  Finished restore at 10-DEC-12
  2 RMAN> recover database;
  Starting recover at 10-DEC-12
  using channel ORA_DISK_1
  starting media recovery
  archive log thread 1 sequence 16 is already on disk as file /oracle/CRM2/CRM/redo04b.log
  archive log thread 1 sequence 17 is already on disk as file /oracle/CRM2/CRM/redo05.log
  archive log filename=/oracle/CRM2/CRM/redo04b.log thread=1 sequence=16
  archive log filename=/oracle/CRM2/CRM/redo05.log thread=1 sequence=17
  media recovery complete, elapsed time: 00:00:05
  Finished recover at 10-DEC-12
  3>

  SQL>>
  Database>  总结:到此,库已经恢复完成,以后只需要把源机器数据备份、归档备份,或者归档文件,拷贝到目标机器上,并在控制文件中注册该备份(catalog start with ‘/backup/’)然后执行恢复即可。


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-571959-1-1.html 上篇帖子: Oracle Study之--Oracle等待事件(2) 下篇帖子: oracle进阶笔记-常用工具的使用-oracle sql developer
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表