实例恢复的深入解析
实例恢复的深入解析什么时候会产生实例恢复呢?当你数据库服务器异常断电,重启数据库就会发生实例恢复。实例恢复是由数据库自动完成的,无须DBA的干涉。当然这里有个前提条件:数据文件、在线日志文件、控制文件不得有损坏。我们用实验来分析一下实例恢复的整个过程吧!1、在关闭数据库前,我们先看一下几个检查点的SCNSQL> select checkpoint_change# from v$database;CHECKPOINT_CHANGE#------------------1455180--控制文件中保存的数据库检查点SCN号实际上在所有数据文件头部中最小的检查点SCNSQL> select file#,checkpoint_change# from v$datafile;FILE# CHECKPOINT_CHANGE#---------- ------------------1 14551802 14551803 14551804 14551805 14551806 1455180--控制文件中保存的数据文件检查点SCN:当一个检查点动作完成之后,Oracle就把每个数据文件的scn单独存放在控制文件中SQL> select file#,checkpoint_change# from v$datafile_header;FILE# CHECKPOINT_CHANGE#---------- ------------------1 14551802 14551803 14551804 14551805 14551806 1455180--每个数据文件的文件头中的检查点SCN这三个检查点的SCN一致,接下来模拟异常断电,重启机器2、此命令可以模拟异常断电SQL> shutdown abort;ORACLE instance shut down.3、监控告警日志[oracle@guoyj trace]$ tail -f alert_bxocp.logStarting background process VKRMTue Dec 11 22:54:41 2012VKRM started with pid=24, OS id=12500Tue Dec 11 22:58:11 2012Shutting down instance (abort)License high water mark = 3USER (ospid: 12479): terminating the instanceInstance terminated by USER, pid = 12479Tue Dec 11 22:58:12 2012Instance shutdown complete4、数据库启动到MOUNT状SQL> shutdown abort;ORACLE instance shut down.SQL> startup mount;ORACLE instance started.Total System Global Area 839282688 bytesFixed Size 2233000 bytesVariable Size 524291416 bytesDatabase Buffers 310378496 bytesRedo Buffers 2379776 bytesDatabase mounted.5、再确定一下这个时间的检查点SCNSQL> select checkpoint_change# from v$database;CHECKPOINT_CHANGE#------------------1455180SQL> SQL> select file#,checkpoint_change# from v$datafile;FILE# CHECKPOINT_CHANGE#---------- ------------------1 14551802 14551803 14551804 14551805 14551806 14551806 rows selected.SQL> select file#,checkpoint_change# from v$datafile_header;FILE# CHECKPOINT_CHANGE#---------- ------------------1 14551802 14551803 14551804 14551805 14551806 1455180发现与异常断电前的检查点的SCN一致,这里一致无须介质恢复。先不着急open数据库,我们做一些dump6、dump的控制文件alter session set events 'immediate trace name CONTROLF level 12';取部分内容:***************************************************************************DATABASE ENTRY***************************************************************************(size = 316, compat size = 316, section max = 1, section in-use = 1,last-recid= 0, old-recno = 0, last-recno = 0)(extent = 1, blkno = 1, numrecs = 1)12/07/2012 10:36:14DB Name "BXOCP"Database flags = 0x00404000 0x00001000Controlfile Creation Timestamp 12/07/2012 10:36:15Incmplt recovery scn: 0x0000.00000000Resetlogs scn: 0x0000.000f30dc Resetlogs Timestamp 12/07/2012 10:36:16Prior resetlogs scn: 0x0000.00000001 Prior resetlogs Timestamp 09/17/2011 09:46:04Redo Version: compatible=0xb200000#Data files = 6, #Online files = 6Database checkpoint: Thread=1 scn: 0x0000.0016344c --数据库检查点SCN=16344c转成10进制为1455180Threads: #Enabled=1, #Open=1, Head=1, Tail=1***************************************************************************CHECKPOINT PROGRESS RECORDS***************************************************************************(size = 8180, compat size = 8180, section max = 11, section in-use = 0,last-recid= 0, old-recno = 0, last-recno = 0)(extent = 1, blkno = 2, numrecs = 11)THREAD #1 - status:0x2 flags:0x0 dirty:55low cache rba:(0x13.3.0) on disk rba:(0x13.a6.0)-- low cache rba:(0x13.3.0)实例恢复的起点:19号日志,第3个块,第0个字节--on disk rba:(0x13.a6.0):实例恢复的终点:19号日志,第166个块,第0个字节on disk scn: 0x0000.0016359c 12/11/2012 22:57:42resetlogs scn: 0x0000.000f30dc 12/07/2012 10:36:16heartbeat: 801789080 mount id: 848836772THREAD #2 - status:0x0 flags:0x0 dirty:0low cache rba:(0x0.0.0) on disk rba:(0x0.0.0)on disk scn: 0x0000.00000000 01/01/1988 00:00:00rese上一个:oracle redo损坏的处理
下一个:从ORACLE移植到DB2