oracle resetlog与noresetlog的作用(转载)

关于resetlog的作用是将日志序列重置,这样以前的归档就作废。 首先一定要明白oracle工作的基本原理,归档情况下:大家一定要同步,谁也不能滞后或者超前,也就是SCN号,如果…

关于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

*******VICTORY LOVES PREPARATION*******

作者: admin

为您推荐

发表评论

返回顶部