Oracle 11g 数据库启动时实例恢复的背后

当系统、数据文件以及数据文件头这三个checkpoint_change#一致(只读、脱机表空间除外)时,数据库才能正常打开。

正常关库时,会生成新的检查点,写入上述三个checkpoint_change#,同时数据文件中的last_change#也会记录下该检查点,也就是说三个checkpoint_change#与last_change#记录着同一个值。

数据库打开前,先确定是否介质恢复,再确定是否实例恢复。介质恢复主要是更新旧的文件,而实例恢复主要是更新内存。如果last_change#值为空,则说明需要进行实例恢复,恢复后的数据库才能打开。

正常关闭的数据库是干净的,一致的

SQL> shutdown normal;   
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 1068937216 bytes
Fixed Size                  2220200 bytes
Variable Size             629149528 bytes
Database Buffers          432013312 bytes
Redo Buffers                5554176 bytes
Database mounted.

SQL> select file#,status,name,checkpoint_change#,last_change# from v$datafile

     FILE# STATUS  NAME                      CHECKPOINT_CHANGE# LAST_CHANGE#
---------- ------- ------------------------- ------------------ ------------
         1 SYSTEM  +DATA/susu/datafile/syste           33003415     33003415
                   m.256.1029148521

         2 ONLINE  +DATA/susu/datafile/sysau           33003415     33003415
                   x.257.1029148523

         3 ONLINE  +DATA/susu/datafile/undot           33003415     33003415
                   bs1.258.1029148523

         4 ONLINE  +DATA/susu/datafile/users           33003415     33003415
                   .259.1029148523

         5 ONLINE  +DATA/susu/datafile/examp           33003415     33003415
                   le.269.1029149011
SQL> select checkpoint_change# from v$database;

CHECKPOINT_CHANGE#
------------------
          33003415

SQL> select file#,checkpoint_change# from v$datafile_header;

     FILE# CHECKPOINT_CHANGE#
---------- ------------------
         1           33003415
         2           33003415
         3           33003415
         4           33003415
         5           33003415

SQL> alter database open;

Database altered.

SQL> select status from v$instance;

STATUS
------------
OPEN


非正常关闭

SQL> shutdown abort;
ORACLE instance shut down.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 1068937216 bytes
Fixed Size                  2220200 bytes
Variable Size             629149528 bytes
Database Buffers          432013312 bytes
Redo Buffers                5554176 bytes
SQL> alter database mount;

Database altered.

SQL> select file#,status,name,checkpoint_change#,last_change# from v$datafile;

     FILE# STATUS  NAME                      CHECKPOINT_CHANGE# LAST_CHANGE#
---------- ------- ------------------------- ------------------ ------------
         1 SYSTEM  +DATA/susu/datafile/syste           33006255
                   m.256.1029148521

         2 ONLINE  +DATA/susu/datafile/sysau           33006255
                   x.257.1029148523

         3 ONLINE  +DATA/susu/datafile/undot           33006255
                   bs1.258.1029148523

         4 ONLINE  +DATA/susu/datafile/users           33006255
                   .259.1029148523

         5 ONLINE  +DATA/susu/datafile/examp           33006255
                   le.269.1029149011


SQL> select checkpoint_change# from v$database;

CHECKPOINT_CHANGE#
------------------
          33003418

SQL> 
SQL> select file#,checkpoint_change# from v$datafile_header;

     FILE# CHECKPOINT_CHANGE#
---------- ------------------
         1           33006255
         2           33006255
         3           33006255
         4           33006255
         5           33006255

SQL> recover database;
Media recovery complete.
SQL> alter database open;

Database altered.

SQL> select checkpoint_change# from v$database;

CHECKPOINT_CHANGE#
------------------
          33026259

SQL> 
SQL> 
SQL> 
SQL> 
SQL> select file#,checkpoint_change# from v$datafile_header;

     FILE# CHECKPOINT_CHANGE#
---------- ------------------
         1           33026259
         2           33026259
         3           33026259
         4           33026259
         5           33026259

reference

上一篇:【Dell服务器】R430服务器启动异常进入initramfs问题解决记录


下一篇:网页*问Ubuntu服务器,端口配置