若是DB2數據庫遭受斷電或者異常關閉,數據庫沒有乾淨的關閉,那麼數據庫在啓動的時候將會sql
進行crash recovery. 可是若是數據庫參數AUTORESTART設置爲OFF的話,在啓動數據庫後DB2不會數據庫
進行CRASH RECOVERY。咱們在鏈接到數據庫的時候將會報SQL1015N 錯誤。oracle
[yansp@db2server ~]$ db2 get db cfg for oracle | grep AUTORESTARTrest
Auto restart enabled (AUTORESTART) = OFF日誌
db2 => connect to oracle @orm
SQL1015N The database is in an inconsistent state. SQLSTATE=55025server
這個時候須要咱們手工進行CRASH RECOVERY。進程
db2 => restart database oracle @get
DB20000I The RESTART DATABASE command completed successfully.it
db2 => connect to oracle @
Database Connection Information
Database server = DB2/LINUX 9.7.0
SQL authorization ID = YANSP
Local database alias = ORACLE
經過日誌文件咱們看一下DB2 CRASH RECOVERY的過程。
2013-02-03-06.27.22.704092+480 I1529901G434 LEVEL: Warning
PID : 9899 TID : 2947541904 PROC : db2sysc 0
INSTANCE: yansp NODE : 000 DB : ORACLE
APPHDL : 0-15 APPID: *LOCAL.yansp.130202222719
AUTHID : YANSP
EDUID : 35 EDUNAME: db2agent (ORACLE) 0
FUNCTION: DB2 UDB, base sys utilities, sqledint, probe:30
MESSAGE : Crash Recovery is needed. <-- 須要進行crash recovery
2013-02-03-06.27.31.389376+480 I1530336G497 LEVEL: Warning
PID : 9899 TID : 2947541904 PROC : db2sysc 0
INSTANCE: yansp NODE : 000 DB : ORACLE
APPHDL : 0-15 APPID: *LOCAL.yansp.130202222719
AUTHID : YANSP
EDUID : 35 EDUNAME: db2agent (ORACLE) 0
FUNCTION: DB2 UDB, recovery manager, sqlpresr, probe:410
MESSAGE : Crash recovery started. LowtranLSN 00000000252E0010 MinbuffLSN <--啓動 Crash recovery
00000000252E0010
2013-02-03-06.27.31.463994+480 E1530834G451 LEVEL: Warning
PID : 9899 TID : 2947541904 PROC : db2sysc 0
INSTANCE: yansp NODE : 000 DB : ORACLE
APPHDL : 0-15 APPID: *LOCAL.yansp.130202222719
AUTHID : YANSP
EDUID : 35 EDUNAME: db2agent (ORACLE) 0
FUNCTION: DB2 UDB, recovery manager, sqlpresr, probe:410
MESSAGE : ADM1530E Crash recovery has been initiated. <-初始化 Crash recovery
2013-02-03-06.27.31.643060+480 I1531286G492 LEVEL: Warning
PID : 9899 TID : 2947541904 PROC : db2sysc 0
INSTANCE: yansp NODE : 000 DB : ORACLE
APPHDL : 0-15 APPID: *LOCAL.yansp.130202222719
AUTHID : YANSP
EDUID : 35 EDUNAME: db2agent (ORACLE) 0
FUNCTION: DB2 UDB, recovery manager, sqlprecm, probe:2000
DATA #1 :
Using parallel recovery with 3 agents 8 QSets 24 queues and 16 chunks <- 啓動並行進程來進行Crash recovery
2013-02-03-06.27.31.933175+480 I1531779G351 LEVEL: Warning
PID : 9899 TID : 2945444752 PROC : db2sysc 0
INSTANCE: yansp NODE : 000
EDUID : 40 EDUNAME: db2lfr (ORACLE) 0
FUNCTION: DB2 UDB, data protection services, sqlpgarl, probe:99
MESSAGE : INFO ONLY: Found an old page in the log file <-DB2發現日誌文件中有OLD PAGE
2013-02-03-06.27.32.700437+480 I1532131G507 LEVEL: Warning
PID : 9899 TID : 2947541904 PROC : db2sysc 0
INSTANCE: yansp NODE : 000 DB : ORACLE
APPHDL : 0-15 APPID: *LOCAL.yansp.130202222719
AUTHID : YANSP
EDUID : 35 EDUNAME: db2agent (ORACLE) 0
FUNCTION: DB2 UDB, recovery manager, sqlprecm, probe:4000
MESSAGE : DIA2051W Forward phase of crash recovery has completed. Next LSN is <--前滾恢復完成
"00000000252E7400".
2013-02-03-06.27.33.293191+480 E1532639G460 LEVEL: Warning
PID : 9899 TID : 2947541904 PROC : db2sysc 0
INSTANCE: yansp NODE : 000 DB : ORACLE
APPHDL : 0-15 APPID: *LOCAL.yansp.130202222719
AUTHID : YANSP
EDUID : 35 EDUNAME: db2agent (ORACLE) 0
FUNCTION: DB2 UDB, recovery manager, sqlpresr, probe:3170
MESSAGE : ADM1531E Crash recovery has completed successfully. <--CRASH RECOVERY成功完成
2013-02-03-06.27.33.294698+480 I1533100G462 LEVEL: Warning
PID : 9899 TID : 2947541904 PROC : db2sysc 0
INSTANCE: yansp NODE : 000 DB : ORACLE
APPHDL : 0-15 APPID: *LOCAL.yansp.130202222719
AUTHID : YANSP
EDUID : 35 EDUNAME: db2agent (ORACLE) 0
FUNCTION: DB2 UDB, recovery manager, sqlpresr, probe:3170
MESSAGE : Crash recovery completed. Next LSN is 00000000252E7400
2013-02-03-06.27.34.627484+480 E1533563G464 LEVEL: Event
PID : 9899 TID : 2949639056 PROC : db2sysc 0
INSTANCE: yansp NODE : 000 DB : ORACLE
APPHDL : 0-16 APPID: *LOCAL.DB2.130202222734
AUTHID : YANSP
EDUID : 34 EDUNAME: db2stmm (ORACLE) 0
FUNCTION: DB2 UDB, Self tuning memory manager, stmmLog, probe:1008
DATA #1 :
Starting STMM log from file number 0
整個恢復過程都是有主控進程PID=9899 DB2SYSC進程來完成的。
[yansp@db2server ~]$ ps -ef | grep 9899
yansp 9899 9897 0 06:16 pts/0 00:00:06 db2sysc 0
root 9900 9899 0 06:16 pts/0 00:00:00 db2ckpwd 0
root 9901 9899 0 06:16 pts/0 00:00:00 db2ckpwd 0
root 9902 9899 0 06:16 pts/0 00:00:00 db2ckpwd 0
yansp 12571 11322 1 06:33 pts/2 00:00:00 grep 9899