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

[经验分享] Oracle RESETLOGS 和 NORESETLOGS 区别说明

[复制链接]

尚未签到

发表于 2016-7-21 12:51:06 | 显示全部楼层 |阅读模式
  
一.创建控制文件时:ResetlogsNoresetlogs
  当我们将控制文件备份到trace 文件时,可以看到里面包含了2部分的重建语句,一个是使用resetlogs,另一个是使用noresetlogs。
  
  备份控制文件的SQL 如下:
  SQL>alterdatabase backup controlfile to trace
  
  有关控制文件的详细说明,参考:
  Oracle 控制文件
  http://blog.csdn.net/tianlesoftware/article/details/4974440
  
  
Set #1. NORESETLOGS case
  The followingcommands will create a new control file and use it to open the database. Dataused by Recovery Manager will be lost.
  Additional logsmay be required for media recovery of offline.
  Use this only ifthe current versions of all online logs are available.
  --使用noresetlogs仅是当前所有的online logs可用时。
  
Set #2. RESETLOGS case
  The followingcommands will create a new control file and use it to open the database. Dataused by Recovery Manager will be lost.
  The contents ofonline logs will be lost and all backups will be invalidated. Use this only ifonline logs are damaged.
  --使用resetlogs,将导致online logs里的内容丢失,并且所有的备份失效,仅当online logs 随坏的情况下,才使用resetlos模式。
  
  
  CREATE CONTROLFILE REUSE DATABASE"DAVE" RESETLOGS/NORESETLOGSARCHIVELOG
  MAXLOGFILES 16
  MAXLOGMEMBERS 2
  MAXDATAFILES 30
  MAXINSTANCES 1
  MAXLOGHISTORY 292
  LOGFILE
  GROUP 1'/u01/app/oracle/oradata/dave/redo01.log'SIZE 50M,
  GROUP 2'/u01/app/oracle/oradata/dave/redo02.log'SIZE 50M,
  GROUP 3'/u01/app/oracle/oradata/dave/redo03.log'SIZE 50M
  -- STANDBY LOGFILE
  DATAFILE
  '/u01/app/oracle/oradata/dave/system01.dbf',
  '/u01/app/oracle/oradata/dave/undotbs01.dbf',
  '/u01/app/oracle/oradata/dave/sysaux01.dbf',
  '/u01/app/oracle/oradata/dave/users01.dbf'
  CHARACTER SET ZHS16GBK
  ;
  
二.打开数据库时:Resetlogs Noresetlogs
  
2.1 说明
  Use RESETLOGSafter incomplete recovery (when the entire redo stream wasn't applied).RESETLOGS will initialize the logs, reset your log sequence number, and start anew "incarnation" of the database.
--RESETLOGS会初始化logs,重置log sequence号,创建一个新的incarnation
  
  Use NORESETLOGSwhen doing complete recovery (when the entire redo stream was applied). Oraclewill continue using the existing (valid) log files.
  --NORESETLOGS 会继续使用已经存在,且有效的log files
  
  可以使用RMAN命令查看incarnation的信息:
  RMAN>listincarnation;
  
  更多内容参考:
  RMAN 系列(八)---- RMAN List和report命令
  http://blog.csdn.net/tianlesoftware/article/details/5728116
  
  Oracle Rman跨resetlogs版本恢复
  http://blog.csdn.net/tianlesoftware/article/details/4682463
  
  做不完全恢复必须使用resetlogs, resetlogs也可以做完全恢复。而noresetlogs则是必须做完全恢复时使用。resetlogs会重置日志序列号强制清空或重建REDO,而noresetlogs则不会这么做。
  
  
2.2 MOS 上对这个RESETLOGSNORESETLOGS的说明:
  Physical Backup and Recovery: An Insider'sPerspective [ID 16530.1]:
  
  After recoverdatabase operation, open the database with: ALTER DATABASE OPEN [NO]RESETLOGS


  (1) NORESETLOGS
  The NORESETLOGSoption does not clear the redo log files during startup and the online redologs to be used for recovery. Only used in scenario where MANUAL RECOVERY isstarted, CANCEL is used, and then RECOVER DATABASE is started.

2RESETLOGS


  CAUTION: Never use RESETLOGS unlessnecessary.
  
  Once RESETLOGS is used then the redo logfiles cannot be used and any completed transactions in those redo logs arelost!!
  
  Before using the RESETLOGS option take anoffline backup of the database.
  
  The RESETLOGSoption clears all the online redo logs and modifies all the online data filesto indicate no recovery is needed. After resetting the redo logs none of theexisting log files or data file backups can be used.
  
  In the control file, the log sequence number is modified,which is very important for recovery purposes. Therecovery will be applied only to the log files whose sequence number is greaterthan log sequence number in the control file. One has to be very cautious whenusing RESETLOGS option. It is important to remember that all datafiles must beonline otherwise they will become useless once the database is up。
  
  
2.3 几种情况的说明
  
  (1) 第一种情况
  假设仅仅控制文件丢失,而其他文件没有丢失(主要是归档和REDO),那么恢复的时候如果选择从备份中恢复控制文件。恢复后,控制文件会去读数据文件头中与CHECKPOINT SCN对应的RBA信息来确定从那个序列的归档日志开始恢复,一直推进恢复到NEXT SCN是无穷大的那个REDOLOG,此时恢复是完全恢复的,但打开的时候还要以resetlogs方式打开,这样要重置归档日志的sequence,也就是说,如果你恢复时使用了备份控制文件,那么打开数据库时必然是要resetlogs的。
  
  不完全恢复时是必须RESETLOGS,但是完全恢复时如果使用备份控制文件来恢复,那么使用RESETLOGS一样可以完全恢复。但是丢失控制文件也可以不使用RESETLOGS方式打开数据库,这样也就可以避免重置日志序列号带来的不变,详情请见第四种情况。
  
  (2) 第二种情况
  不完全恢复,不管是要什么样的不完全恢复,SCN,TIME,跨越REDO,都必须使用resetlogs。
  

  (3) 第三种情况
  丢失REDOLOG,这就更需要resetlogs了,因为resetlogs能够重建REDOLOG。如果你的REDOLOG、控制文件、数据文件丢失的话,需要先恢复控制文件,然后restore database;recover database;alter database open resetlogs;
  注意,这时候做的是不完全恢复,因为REDO没有了。在recover过程中可能会报错然后自动退出RMAN,无视,alter database open resetlogs即可,
  
  (4) 第四种情况
  没有丢失控制文件及各种日志,仅丢失数据文件,这种问题比较常见,有可能磁盘损坏造成数据文件丢失,等磁盘故障排除后,需要恢复,此时的恢复就很简单了,restore database;recover database;alter database open;就一切OK,也就是说,在不使用备份控制文件恢复的情况下,是可以使用noresetlog方式打开数据库的。
  前提有一,不能丢失日志文件。假若丢失了控制文件和数据文件但还是想以noresetlog打开的话,就必须手动以noresetlogs方式重建控制文件,而且REDOLOG的状态都必须正常,否则是无法使用noresetlogs方式打开。
  
  几种情况的分析转自一下Blog:
  http://space.itpub.net/16628454/viewspace-524593
  
  
  
  
  
  -------------------------------------------------------------------------------------------------------
  版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
  Skype:  tianlesoftware
  QQ: tianlesoftware@gmail.com
  Email:  tianlesoftware@gmail.com
  Blog: http://www.tianlesoftware.com
  Weibo:  http://weibo.com/tianlesoftware
  Twitter: http://twitter.com/tianlesoftware
  Facebook: http://www.facebook.com/tianlesoftware
  Linkedin: http://cn.linkedin.com/in/tianlesoftware
  
  
  -------加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请----
  DBA1 群:62697716(满); DBA2 群:62697977(满)DBA3 群:62697850(满)
  DBA 超级群:63306533(满); DBA4 群:83829929 DBA5群: 142216823
  DBA6 群:158654907 DBA7 群:172855474 DBA总群:104207940

运维网声明 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.yunweiku.com/thread-247449-1-1.html 上篇帖子: Oracle 相关的专业术语 说明 下篇帖子: 探索Oracle pfile和spfile的秘密
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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