open resetlogs 做了什么

先摘一段document原文,稍后再对照来检查。

OPEN RESETLOGS Operations
When you open the database with the RESETLOGS option, the database performs the
following actions:
■ Archives the current online redo logs (if they are accessible) and then erases the
contents of the online redo logs and resets the log sequence number to 1.
For example, if the current online redo logs are sequence 1000 and 1001 when you
open RESETLOGS, then the database archives logs 1000 and 1001 and then resets the
online redo logs to sequence 1 and 2.
■ Creates the online redo log files if they do not currently exist.
■ Initializes redo thread records and online redo log records in the control file to the
beginning of the new database incarnation.
More specifically, the database sets the redo thread status to closed, sets the
current thread sequence in the redo thread records to 1, sets the thread checkpoint
of each redo thread to the beginning of log sequence 1, chooses one redo log from
each thread and initialize its sequence to 1, and so on.
■ Updates all current datafiles and online redo logs and all subsequent archived
redo logs with a new RESETLOGS SCN and time stamp.


先看alert日志。

alter database open resetlogs
RESETLOGS after complete recovery through change 104560131
Archived Log entry 93 added for thread 1 sequence 1026 ID 0x357d527c dest 1:   这一行带下面几行,归档了online  log。
Archived Log entry 94 added for thread 1 sequence 1028 ID 0x357d527c dest 1:
Archived Log entry 95 added for thread 1 sequence 1030 ID 0x357d527c dest 1:
Archived Log entry 96 added for thread 1 sequence 1029 ID 0x357d527c dest 1:
Archived Log entry 97 added for thread 1 sequence 1027 ID 0x357d527c dest 1:

Clearing online redo logfile 1 /home/oracle/app/oracle/oradata/orcl2/redo01.log      这一行带下面几行,clear online log sequence ,并设置为0
Clearing online log 1 of thread 1 sequence number 1026
Clearing online redo logfile 1 complete
Clearing online redo logfile 2 /home/oracle/app/oracle/oradata/orcl2/redo02.log
Clearing online log 2 of thread 1 sequence number 1028
Clearing online redo logfile 2 complete
Clearing online redo logfile 3 /home/oracle/app/oracle/oradata/orcl2/redo03.log
Clearing online log 3 of thread 1 sequence number 1030
Clearing online redo logfile 3 complete
Clearing online redo logfile 4 /home/oracle/app/oracle/oradata/orcl2/redo04.log
Clearing online log 4 of thread 1 sequence number 1029
Wed Mar 08 00:26:54 2017
Clearing online redo logfile 4 complete
Clearing online redo logfile 5 /home/oracle/app/oracle/fast_recovery_area1/ORCL2/onlinelog/o1_mf_5_ctsfpl7c_.log
Clearing online log 5 of thread 1 sequence number 1027
Clearing online redo logfile 5 complete

Resetting resetlogs activation ID 897405564 (0x357d527c)     activation ID,这个会出现在控制文件的database  entry条目的Activation ID项。是resetlogs之前的值,会被下面出现的值覆盖。
Online log /home/oracle/app/oracle/oradata/orcl2/redo01.log: Thread 1 Group 1 was previously cleared
Online log /home/oracle/app/oracle/oradata/orcl2/redo02.log: Thread 1 Group 2 was previously cleared
Online log /home/oracle/app/oracle/oradata/orcl2/redo03.log: Thread 1 Group 3 was previously cleared
Online log /home/oracle/app/oracle/oradata/orcl2/redo04.log: Thread 1 Group 4 was previously cleared
Online log /home/oracle/app/oracle/fast_recovery_area1/ORCL2/onlinelog/o1_mf_5_ctsfpl7c_.log: Thread 1 Group 5 was previously cleared
Wed Mar 08 00:26:57 2017
Setting recovery target incarnation to 2  这个涉及到incarnation的概念。incarnation是什么?简单理解,一次open  resetlogs,就产生一个新的incarnation。可以通过rman中

list  incarnation命令查看当前与历史incarnation。例如:这里的1,2就是incarnation了。

RMAN> list incarnation;


using target database control file instead of recovery catalog


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
1       1       ORCL2    1411348214       PARENT  1976932    2016-07-06 22:56:28
2       2       ORCL2    1411348214       CURRENT 104560132  2017-03-08 00:26:38

用一个图会比较形象化:


这里的一个分支就是一个incarnation。


Wed Mar 08 00:26:57 2017
Assigning activation ID 918890248 (0x36c52708)   看到了吧,用这个值覆盖的,最终的控制文件中的activation id就是这个了。
.....后面就没什么重点,直接略过
Completed: alter database open resetlogs


时间晚了,要睡觉。控制文件就不一个个解释。简单说下。

1.控制文件中记录的数据文件,online redo文件scn,和以后产生的archive log,起点scn都是resetlog当时的scn,并且会带上时间戳也是当时的时间戳。这是为了后面应用不同incarnation产生的backup和archive  log准备的。只有scn和时间戳都相同的才被认为是当前incarnation产生的backup或者archive  log。

2.控制文件中的redo  log,当前使用的sequence是1,尚未使用到的为0。redo  thread记录的sequence也从1开始。

3.数据文件,online redo文件scn,和以后产生的archive log自不必说,与上面一点一致。



本来要附上一段trace。这段trace用oradebug追踪了从recover到open  resetlogs的过程,并在最后dump level 8 级的controlfile。结果csdn不能上传文件,罢了。


猜你喜欢

转载自blog.csdn.net/w1346561235/article/details/60813087