暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

DB2 数据库活动日志故障 - SQLOGCTL.LFH

原创 盖国强 2019-05-08
2205

问题描述

最近某用户的DB2数据库遇到故障,活动日志受损,数据库无法启动,这对于DB2来说,是最为严重的情况。
在DB2 V9中,DB2通过SQLOGCTL.LFH文件来实现日志和控制文件功能,从9.5开始,缺省的维护两个拷贝SQLOGCTL.LFH.1 和 SQLOGCTL.LFH.2 。

专家解答

以下是DB2的官方介绍:

In Version 9.1, the database manager maintained one log control file: SQLOGCTL.LFH. In Version 9.5, the database manager maintains two copies of the log control file: SQLOGCTL.LFH.1 and SQLOGCTL.LFH.2.

Details

When a database restarts after a failure, the database manager applies transaction information stored in log files to return the database to a consistent state. The database manager uses a log control file to determine which entries in the log files need to be applied.

If the log control file is damaged, it might not be possible for the database manager to return the database to a consistent state. However, having two copies of the log control file can make database recovery more resilient because if one copy of the log control file is damaged, the database manager can use the other copy during a restart.

As a result of the usage of the mirrored log control files, the -file option of the db2flsn command is deprecated and might be removed in a future release.

Resolution

If you run applications or scripts that refer to the log control file, update those applications and scripts to refer to one of the duplicate log control files now. For tools like db2flsn, use the -path parameter to specify the path to both log control files. This enables the database manager to handle the case where one of the log control files is missing, damaged, or stale. 

以下是牛新庄关于这段的记录:

DB2数据库启动的环节中有一个步骤是检查SQLOGCTL.LFH.1文件,这个文件中记录了数据库的活动日志情况。很多人由于没有深刻理解活动日志的作用,而有可能误删除活动日志。如果误删除了活动日志,那么数据库将无法连接。这也属于数据库损坏的一种情况,因为数据库的完整一致性受到了破坏。出现这种情况后,首先考虑是否有可以恢复的备份,如果有,可以从备份恢复,然后前滚到日志的末尾,以完全恢复该数据库。如果没有可用的备份来恢复,可以通过IBM的技术支持中心来协助解决(IBM内部通过一条命令db2lfh去修改SQLOGCTL.LFH.1文件)。如果想自己解决那就只有使用db2dart工具了。
如何避免数据库的活动日志被删除?可以有以下措施:

启用数据库的镜像日志功能,但是会带来性能的额外开销。

启用数据库的日志出口程序,这样可以避免手工来删除活动日志目录中的日志。

当一定要手工删除活动日志目录中的归档日志时,使用命令PRUNE LOGFILE PRIOR TO log-file-name,可以避免将活动日志误删除。注意维护活动日志所在目录的权限。
简而言之,当在线的日志和控制文件出现问题时,常规手段已经不能处理,通过db2dart抽取数据的工作量太大,通过db2lfh只能通过IBM的技术支持实现。

实际上,还是那句话:备份重于一切。


「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论