oracle resetlog与noresetlog的作用(转载)
关于resetlog的作用是将日志序列重置,这样以前的归档就作废。
首先一定要明白oracle工作的基本原理,归档情况下:大家一定要同步,谁也不能滞后或者超前,也就是SCN号,如果学oracle不懂scn的作用,那oracle就很难学懂了。为什么要resetlog,因为有一些地方不一致了,必须得需要着一个基准点,让大家以这个为起点,一起继续超前走。
alter database open noresetlogs与resetlog的区别:
http://www.oracle.com.cn/viewthread.php?tid=1490
个人理解:
resetlogs,由于不完全恢复导致日志不连续而不能使用恢复点之后的日志进行重做,所以使用resetlogs进行打开数据库。
noresetlogs,由于控制文件的版本是从备份中而来或是手工重建的,并且所有日志是连续的,可以用于重做,所以使用noresetlogs打开数据库,意为使用log进行重做。
目录
1 概述
2 运用场合
3 作用
4 在RMAN中OPEN RESETLOGS与SQLPLUS中OPEN RESETLOGS的区别
5 在重建控制文件的时候使用ResetLog
1、概述
The primary function of resetlogs is to discard the redo that was not applied during incomplete recovery, ensuring that the skipped redo can never be accidentally applied by a subsequent recovery. To accomplish this, resetlogs effectively invalidates all existing redo in all online and archived redo logfiles. This has the side effect of making any existing datafile backups unusable for future recovery operations.Resetlogs also reinitializes the controlfile information about online logs and redo threads, clears the contents of any existing online redo log files, creates the online redo log files if they do not currently exist, and resets the log sequence number in all threads to one.
resetlogs的主要功能是在不完全恢复过程中忽略不可用的重做日志,确保略过的日志不影响接下来的恢复。resetlogs把所有存在于在线或归档的日志文件中的重做信息都置为不可用。这带来一个副作用,使得已存在的数据文件备份对将来的数据恢复不再是安全可用的了。resetlogs同时还会:重新初使化控件文件中的在线日志信息及重做日志线程、清除已存在的重做日志文件、若重做日志不存在则创建日志文件、重置所有线程中的日志序号为1。
2、运用场合
以下条件需要使用resetlog
1)在不完全恢复(介质恢复)
2)使用备份控制文件(backup的控制文件一般从日志文件和数据库的信息以及SCN的信息,相比目前的状态都已经过期了)
3、ResetLog的作用
(1)将重做日志的序列号设为1
(2)一般以该子句打开数据库后,要立即备份数据库,因为这个子句会使数据库以前的备份不能用.
(3)在重做日志当前日志组出现错误时,要以该子句打开数据库.该子句会重新设置重做日志文件的状态.
(4)让数据库系统归档初始化,重新生成归档文件.
4、在RMAN中OPEN RESETLOGS与SQLPLUS中OPEN RESETLOGS的区别
1) If you run the RMAN command (not the SQL statement) ALTER DATABASE OPEN RESETLOGS, then RMAN automatically creates a new database incarnation record in the recovery catalog. RMAN implicitly and automatically issues a RESET DATABASE command, which specifies that this new incarnation of the database is the current incarnation. RMAN associates all subsequent backups and log archiving done by the target database with the new database incarnation.
2) If you issue the SQL statement (not the RMAN command) ALTER DATABASE OPEN RESETLOGS, then RMAN does not automatically run a RESET DATABASE command. Hence, RMAN cannot access the recovery catalog because it cannot distinguish between a RESETLOGS command and an accidental restore of an old control file. To solve this problem, you must manually run the RESET DATABASE command in RMAN after executing the SQL statement ALTER DATABASE OPEN RESETLOGS.
The RESET DATABASE command updates the repository to indicate that the target database has been opened with the RESETLOGS option. In the rare situation in which you wish to restore backups of a prior incarnation of the database, use the RESET DATABASE TO INCARNATION key command to change the current incarnation to an older incarnation. For example, if you accidentally drop a table immediately after the most recent RESETLOGS, then you may want to
recover the database to just before the time of the most recent RESETLOGS and then open it with the RESETLOGS option, thereby creating a new incarnation.
5、在重建控制文件的时候使用ResetLogs
1.create controlfile resetlogs/noresetlogs
1)用noresetlogs重建控制文件时,控制文件中datafile Checkpoint SCN来自online logs中的Current log头
2)用resetlogs重建控制文件时,控制文件中datafile Checkpoint SCN来自各数据文件头(Start SCN)。
2.数据文件检查点scn
当一个检查点动作完成后,Oracle就把每个数据文件的scn单独存放在控制文件中。
select name,checkpoint_change# from v$datafile;
3、启动scn
Oracle把这个检查点的scn存储在每个数据文件的文件头中,这个值称为启动scn,因为它用于在数据库实例启动时,
检查是否需要执行数据库恢复。
select name,checkpoint_change# from v$datafile_header
4、终止scn
每个数据文件的终止scn都存储在控制文件中。
select name,last_change# from v$datafile
以下条件需要使用using backup controlfile
1)、使用备份控制文件
2)、重建resetlogs控制文件,如果重建立noresetlogs不必要使用using backup controlfile
2、alter database open resetlog
指定RESETLOGS将重设当前LOG sequence number为1,抛弃所有日志信息。
以下条件需要使用resetlog
1)在不完全恢复(介质恢复)
2)使用备份控制文件
使用resetlogs打开数据库后无必完整地备份一次数据库。
3、create controlfile resetlogs/noresetlogs
1)用Noresetlogs重建控制文件时,控制文件中 datafile Checkpoint来自Online logs中的Current log头
2)用Resetlogs重建控制文件时,控制文件中datafile Checkpoint来自各数据文件头。
当system scn,datafile scn,start scn 不全相等,需要介质恢复,如果stopscn null需要实例恢复,resetlogs抛弃所有在上一次恢复没有用到的日志信息,确保不被重新用与恢复。
1、系统正常关闭:
system scn=datafile scn=start scn=stop scn
1)system scn=datafile scn=start scn,不需要介质恢复
2)stopscn not null,不需要实例恢复
2、系统异常关闭:
system scn=datafile scn=start scn,stop scn null
1)system scn=datafile scn=start scn,不需要介质恢复
2)stopscn null,需要实例恢复
3、旧数据文件
system scn=datafile scn>start scn,stop scn null/notnull
1)system scn=datafile scn>start scn,需要介质恢复成system scn=datafile scn=start scn
2)stopscn null,需要实例恢复,not null 不需要实例恢复
4、备份控制文件
system scn=datafile scn<=start scn(当数据文件为旧的相等),stop scn notnull/null
1)system scn=datafile scn<=start scn,需要使用using backup controlfile介质恢复成system scn=datafile scn=start scn=current log scn(当前日志最大SCN)
2)为保证上一次恢复没有用到log日志不被使用,必须resetlogs
5、重建noresetlogs控制文件
控制文件中 datafile Checkpoint来自Online logs中的Current log头
current log scn=system scn=datafile scn>=start scn,stop scn not null/null
1)current log scn=system scn=datafile scn>=start scn,需要介质恢复成system scn=datafile scn=start scn=redolog scn(当前日志最大SCN),stop scn not null
2)stopscn not null 不需要实例恢复
6、重建resetlogs控制文件
控制文件中datafile Checkpoint来自各数据文件头。
system scn>=datafile scn=start scn,stop scn not null/null
1)system scn>=datafile scn=start scn,需要使用using backup controlfile介质恢复成system scn=datafile scn=start scn(当前日志最大SCN),stop scn not null
2)stop notnull,因为SCN已经为redolog scn,log已经不能使用,必须resetlogs
《FROM:http://blog.csdn.net/zhjxixi/article/details/7739199》
oracle resetlog与noresetlog的作用(转载)的更多相关文章
- 安装Oracle后修改IP总结(转载)
转载自:http://blog.csdn.net/bleibo/article/details/5447198 安装Oracle后修改IP总结(转载) 针对ORACLE 10G 在安装完后,修改IP ...
- Oracle中的索引详解(转载)
一. ROWID的概念 存储了row在数据文件中的具体位置:64位 编码的数据,A-Z, a-z, 0-9, +, 和 /, row在数据块中的存储方式 SELECT ROWID, last_name ...
- Oracle函数over(),rank()over()作用及用法--分区(分组)求和& 不连续/连续排名
(1) 函数: over()的作用及用法: -- 分区(分组)求和. RANK ( ) OVER ( [query_partition_clause] order_by_clause )D ...
- Oracle取TOP N条记录(转载)
在SQL Server里面有top关键字可以很方便的取出前N条记录,但是Oracle里面却没有top的使用,类似实现取出前N条记录的简单方法如下: 方法1:利用ROW_NUMBER函数 取出前5条记录 ...
- Oracle Redo Log 机制 小结(转载)
Oracle 的Redo 机制DB的一个重要机制,理解这个机制对DBA来说也是非常重要,之前的Blog里也林林散散的写了一些,前些日子看老白日记里也有说明,所以结合老白日记里的内容,对oracle 的 ...
- Oracle降低高水位先(转载)
Oracle 降低高水位线的方法 高水位(HIGH WARTER MARK,HWM)好比水库中储水的水位,用于描述数据库中段的扩展方式.高水位对全表扫描方式有着至关重要的影响.当使用DELETE删除 ...
- Oracle 字符集的查看和修改 --转载
原文地址:Oracle 字符集的查看和修改 作者:piaoliuxiong 一.什么是Oracle字符集 Oracle字符集是一个字节数据的解释的符号集合,有大小之分,有相互的包容关系.ORACLE ...
- java中关键字volatile的作用(转载)
转载:http://blog.csdn.net/orzorz/article/details/4319055 用在多线程,同步变量. 线程为了提高效率,将某成员变量(如A)拷贝了一份(如B),线程中对 ...
- Oracle临时表空间语句、作用
在Oracle数据库中:一个表空间只属于一个数据库使用:而一个数据库可以拥有多个表空间.属于"一对多"的关系 我们对照着mysql来理解. 1.Oracle有表空间,mysql没有 ...
随机推荐
- VS2012+SQL2008+ODBC编程,第一篇博客,写的不好忘各位大神指点一二~
近期写一个数据库的课程设计,用的是C++ MFC .最開始用的是ADO技术,可是苦于网上大部分的教程都是VC6.0的,对着教程敲了4,5遍还是执行不成功.我用的IDE是VS2012,毕竟VC6.0和V ...
- C语言头文件组织
一.全局变量单独编写(很值得借鉴). 一般习惯将不同功能模块放到一个头文件和一个C文件中. 例如是写一些数学计算函数: //mymath.h #ifndef _mymath_H #define _my ...
- 四、Mp3文件类型及其判断
根据前两篇文章的分析,帧分为标签帧和数据帧,MP3文件类型是根据数据帧的类型来分的,文件类型如下表: 位率相等(Constant BitRate) CBR Mp3文件 位率不等(Variable B ...
- git使用经验
一直想写一点关于git的文章,但是平时太懒了,没有写,现在写些经验这里,方便以后自己忘记了.
- 第二章实例:SimpleAdapter结合listview实现列表视图
package test.simpleAdapter; import java.util.ArrayList; import java.util.HashMap; import java.util.L ...
- [Effective Modern C++] Item 3. Understand decltype - 了解decltype
条款三 了解decltype 基础知识 提供一个变量或者表达式,decltype会返回其类型,但是返回的内容会使人感到奇怪. 以下是一些简单的推断类型: ; // decltype(i) -> ...
- [转]标准C++字符串string以及MFC6.0字符串CString的tokenize和split函数
标准字符串的方法: /******************************************** the tokenize function for std::string ****** ...
- sqlplus 链接数据库
实验目的:在虚拟机中用sqlplus工具访问真实机的数据库: 实验环境: 真实机(windows系统,数据库服务名 orcl): SQL> select * from v$version; BA ...
- 我用爬虫一天时间“偷了”知乎一百万用户,只为证明PHP是世界上最好的语言
我用爬虫一天时间“偷了”知乎一百万用户,只为证明PHP是世界上最好的语言 2015-08-06 猿圈 我用爬虫一天时间“偷了”知乎一百万用户 只为证明PHP是世界上最好的语言 看了不少朋友圈里推荐的P ...
- java学习一目了然——异常必知
java学习一目了然--异常必知 我们只要学java,异常肯定非常熟悉,该抛的时候抛一下就行.但是这其中还有点小细节需要注意.就用这个小短篇来说一下异常处理中的小细节吧. 异常处理 RuntimeEx ...