博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
崩溃恢复(crash recovery)与 AUTORESTART参数
阅读量:5912 次
发布时间:2019-06-19

本文共 4088 字,大约阅读时间需要 13 分钟。

       关于这个参数设置的影响,在生产系统中经历过两次:
       第一次是有套不太重要的系统安装在虚拟机,这套系统所有应用(DB2 WAS IHS)都配置到/etc/rc.local中,每次启动机器会自动拉起应用,然后有次虚拟机宕机,重启后检查了各个应用进程都正常启动,但是前台页面访问异常无法访问,然后到后台手动连接数据库报:
SQL1015N  The database is in an inconsistent state.  SQLSTATE=55025
根据SQL1015N提示:需要执行RESTART DATABASE DBNAME命令,执行后然后数据库可以正常连接

第二次是一套HA服务器的主机电源故障发生系统切换,切换到备机后,检查应用都正常被拉起,但是前台无法访问,和第一次是相同的问题,AUTORESTART参数被设置了OFF

这个参数解释如下:
       如果DB2数据库遭受断电或者异常关闭,数据库没有干净的关闭,那么数据库在启动的时候将会进行crash recovery. 但是如果数据库参数AUTORESTART设置为OFF的话,在启动数据库后DB2不会进行CRASH RECOVERY。关于crash recovery,在db2diag.log日志会有相关体现

下面重现这一场景:

/* 1   设置AUTORESTART为OFF   */[db2inst1@limt ~]$ db2 UPDATE DATABASE CONFIGURATION for limtdb USING AUTORESTART OFF IMMEDIATEDB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.[db2inst1@limt ~]$ db2 get db cfg for limtdb|grep -i AUTORESTART Auto restart enabled                      (AUTORESTART) = OFF [db2inst1@limt yunwei]$ db2 connect to limtdb   Database Connection Information Database server        = DB2/LINUXX8664 10.1.0 SQL authorization ID   = DB2INST1 Local database alias   = LIMTDB/* 2   插入一条数据但不提交,为了数据库处于不一致性   */[db2inst1@limt yunwei]$ db2  +c "insert into A values(15485,'asdas','asdas')"DB20000I  The SQL command completed successfully.[db2inst1@limt yunwei]$ /* 3  kill数据库,模拟异常宕机情况   */[db2inst1@limt yunwei]$ ps -ef|grep db2sysdb2inst1  5287  5285  1 08:07 pts/1    00:00:04 db2sysc 0                                      db2inst1  5827  3612  0 08:12 pts/1    00:00:00 grep db2sys[db2inst1@limt yunwei]$ kill -9 5287/* 4  启动数据库,此时数据库没有进行崩溃恢复,因为AUTORESTART为OFF  */[db2inst1@limt yunwei]$ [db2inst1@limt yunwei]$ db2start12/19/2014 08:13:04     0   0   SQL1063N  DB2START processing was successful.SQL1063N  DB2START processing was successful.[db2inst1@limt yunwei]$ [db2inst1@limt yunwei]$ /* 5  此处报错是因为刚才的db2bp进程没有terminate  */[db2inst1@limt yunwei]$ db2 connect to limtdbSQL0752N  Connecting to a database is not permitted within a logical unit of work when the CONNECT type 1 setting is in use.  SQLSTATE=0A001[db2inst1@limt yunwei]$ db2 terminateDB20000I  The TERMINATE command completed successfully./* 6  再次启动时候报数据库不一致 */[db2inst1@limt yunwei]$ db2 connect to limtdbSQL1015N  The database is in an inconsistent state.  SQLSTATE=55025/* 7  db2 ? SQL1015N 有一条建议: using the RESTART DATABASE command*/[db2inst1@limt yunwei]$ db2 restart database limtdbDB20000I  The RESTART DATABASE command completed successfully. /* 8  数据库可以正常连接*/[db2inst1@limt yunwei]$ db2 connect to limtdb   Database Connection Information Database server        = DB2/LINUXX8664 10.1.0 SQL authorization ID   = DB2INST1 Local database alias   = LIMTDB/* 9   以下是设置AUTORESTART为ON情况下,数据库宕机重启(不需要执行RESTART DATABASE) */[db2inst1@limt yunwei]$ [db2inst1@limt yunwei]$ db2 UPDATE DATABASE CONFIGURATION for limtdb USING AUTORESTART ON IMMEDIATEDB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.[db2inst1@limt yunwei]$ [db2inst1@limt yunwei]$ db2 get db cfg for limtdb|grep -i AUTORESTART Auto restart enabled                      (AUTORESTART) = ON[db2inst1@limt yunwei]$ [db2inst1@limt yunwei]$ [db2inst1@limt yunwei]$ db2  +c "insert into A values(15485,'asdas','asdas')"DB20000I  The SQL command completed successfully.[db2inst1@limt yunwei]$ ps -ef|grep db2sysdb2inst1  5870  5868  1 08:13 pts/1    00:00:03 db2sysc 0                                      db2inst1  6122  3612  0 08:16 pts/1    00:00:00 grep db2sys[db2inst1@limt yunwei]$ kill -9 5870[db2inst1@limt yunwei]$ db2start12/19/2014 08:16:35     0   0   SQL1063N  DB2START processing was successful.SQL1063N  DB2START processing was successful.[db2inst1@limt yunwei]$ db2 connect to limtdbSQL0752N  Connecting to a database is not permitted within a logical unit of work when the CONNECT type 1 setting is in use.[db2inst1@limt yunwei]$ db2 terminateDB20000I  The TERMINATE command completed successfully.[db2inst1@limt yunwei]$ db2 connect to limtdb   Database Connection Information Database server        = DB2/LINUXX8664 10.1.0 SQL authorization ID   = DB2INST1 Local database alias   = LIMTDB

转载于:https://www.cnblogs.com/limt/p/4199235.html

你可能感兴趣的文章
PowerManager Android 电源管理
查看>>
自定义PlantUML和C4Model的样式
查看>>
springboot报编译失败 Compilation failure
查看>>
Ubuntu下su模式认证失败的问题解决
查看>>
mysqld error(一)
查看>>
Javascript延时函数
查看>>
UML类图关系大全
查看>>
Ant编译Hadoop 1.0.3的eclipse-plugin插件包
查看>>
tensorflow开发环境搭建
查看>>
springMVC启动时,加载数据至内存中配置详解;
查看>>
JDBCRealm Http Digest
查看>>
CentOS 7 网络配置
查看>>
matplotlib 交互式导航
查看>>
eclipse的插件未安装成功
查看>>
由装箱引发的——Integer比较的来龙去脉
查看>>
java 深拷贝
查看>>
UnicodeEncodeError: 'ascii' codec can't encode
查看>>
jvm在什么时候进行进行垃圾回收,在什么时候进行扩大内存
查看>>
【转载】强大的命令行工具wmic
查看>>
JavaScript里的数组转化新方法Array.From
查看>>