打印本文 打印本文 关闭窗口 关闭窗口
一次SQL Server 2000修复实践
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1033  更新时间:2007/11/14 13:14:01  文章录入:mintao  责任编辑:mintao
   我所讲的一个故事的背景是这样的,在某一个POS的项目中使用SQL SERVER 2000做前台数据库,IBM 的DB2做后台数据库。前台数据库的环境是这样的操作系统是WINDOWS 2000 SERVER(10 USERS),数据库是SQL SERVER 2000(E)+SP3,Application是POS的收银系统(是一种实时的交易系统)。硬件的配置是:P4 XRON 2.4G*2,36G HDD*5 做的RAID5 ,1G MEMORY,HP DDS4 磁带机,数据库的容量一般保持在5G左右。

  因为数据比较的重要,并且数据容量也不大,我们要求的备份策略是每天在磁带机做POS_DB的全备份(一个星期7天一个循环),在晚上还在硬盘上做全部备份(MASTER,MSDB,POS_DB).这样保持双重的保险。

  1.故障爆发:

  2003-12-26 13:00

  客户报告所有的POS死机和SERVER运行速度非常的慢。经过重新启动服务器(启动到检查RAID卡时开始报警)我们发现在WINDEOWS 2000 SERVER的“系统日志”中有这样的信息:

Error: 823, Severity: 24, State: 2
I/O error (torn page) detected during read at offset 0x0000001bf96000 in file D :\DATA\POS_DB.mdf'.
SQLSERVER的“错误日志”中有这样的信息:
2003-12-10 03:34:22.23 spid56 Error: 823, Severity: 24, State: 2
2003-12-10 03:34:22.23 spid56 I/O error (torn page) detected during read at offset 0x00000074964000 in file 'D:\DATA\POS_DB.mdf'..

  来自msdn的解释:

I/O logical check failure: If a read Windows API call or a write Windows API call for a database file is successful, but specific logical checks on the data are not successful (a torn page, for example), an 823 error is raised. The following error message is an example of an 823 error for an I/O logical check failure:
2003-09-05 16:51:18.90 spid17 Error: 823, Severity: 24, State: 2
2003-09-05 16:51:18.90 spid17 I/O error (torn page) detected during read at offset 0x00000094004000 in file 'F:\SQLData\mydb.MDF'..
To resolve this problem, first run the DBCC CHECKDB statement on the database that is associated with the file in the error message. If the DBCC CHECKDB statement reports errors, correct those errors before you troubleshoot this problem. If the problem persists even after the DBCC CHECKDB errors have been corrected, or if the DBCC CHECKDB statement does not report any errors, review the Microsoft Windows NT system event log for any system errors or disk-related errors. You can also contact your hardware vendor to run any appropriate diagnostics.

  I/O逻辑检查失败:如果有一个WINDOWS程序在读取和写数据库文件时是成功的,但是在详细的数据逻辑检查时没有成功(比如:不完整的页),SQLSERVER会返回MSG 823的错误。下面就是一个I/O逻辑检查失败MSG 823的实例:

2003-09-05 16:51:18.90 spid17 Error: 823, Severity: 24, State: 2
2003-09-05 16:51:18.90 spid17 I/O error (torn page) detected during read at offset 0x00000094004000 in file 'F:\SQLData\mydb.MDF'..

  要解决这样的问题,首先要在该数据库中执行DBCC CHECKDB(错误信息提示的数据库文件)。如果DBCC CHECKDB报错,在你修复错误之前纠正这些错误。如果这些错误信息一直保留到执行DBCC CHECKDB运行之后,或者DBCC CHECKDB没有报告任何错误,检查WINDOWS NT系统的的事件查看器的和系统错误或磁盘错误相关的信息。你也可以联系硬件厂商运行正确的诊断工具。

  坏了,数据库文件有问题,在检查OS的事件查看器,我们发现在一个星期之前就有错误信息(只是OFFSET的偏移地址不同)。

  赶紧检查HDD,果然发现在RAID5的第一快HDD亮了红灯(灰尘太多,很难于看清)

  执行 DBCC CHECKDB('POS_DB')检查发现:

Server: Msg 8909, Level 16, State 1, Line 1
Table error: Object ID 26342838, index ID 35207, page ID (1:50978). The PageId in the page header =(32230:-2048732002).

Server: Msg 8939, Level 16, State 1, Line 1
Table error: Object ID 859150106, index ID 255, page (1:238770). Test (IS_ON (BUF_IOERR, bp->bstat) && bp->berrcode) failed. Values are 2057 and -1.

Server: Msg 8928, Level 16, State 1, Line 1
Object ID 861246123, index ID 0: Page (1:57291) could not be processed. See other errors for details.

Server: Msg 2511, Level 16, State 1, Line 1
Table error: Object ID 862626116, Index ID 0. Keys out of order on page (1:269310), slots 0 and 1.

  啊哈,果然有很多的表都有错误关联(请记录每一个错误表的OBJECT ID)。

  从MSDN查到:

  错误号Msg 823:表示SQLSERVER在读取数据和写数据时检测到硬件设备有问题或者系统有问题。

  TORN PAGE:的意思是不完整的页

  0x0000001bf96000:这是从数据文件开始处到TORN PAGE 的字节数。

  错误号Msg 8939 :大家可以看看:http://support.microsoft.com/default.aspx?kbid=320434
FIX:在运行 CHECKDB 时,具有 TABLOCK 提示的大容量插入(bulk insert, bcp 等)可能导致错误 8929 和 8965。

  错误号MSG 8928:是和8939相关联的信息,

  错误号MSG 8965:是和8939相关联的信息,

  大家可以到下面的地址找到相关的信息:

http://support.microsoft.com/default.aspx?scid=kb;en-us;826433
PRB: Additional SQL Server Diagnostics Added to Detect Unreported I/O Problems
http://support.microsoft.com/default.aspx?scid=kb;en-us;828339
PRB: Error message 823 may indicate hardware problems or system problems
http://support.microsoft.com/default.aspx?scid=kb;en-us;308795
FIX: CheckDB May Not Fix Error 8909 or Error 8905

  故障确诊:RAID有一块HDD坏,造成数据库文件破坏

  2.更换HDD

  2003-12-28 23:00

  现在就体现了RAID5的好处,坏了一块HDD,系统可以照常运行,不过系统的日志和SQLSERVER的日志还是有MSG823的报错信息。

  按照RAID 卡的REBUILD的步骤将新的HDD绑定到原始的RAID5中,顺利完成。

  用DBCC检查数据库的完整性

DBCC CHECKDB('POS_DB') WITH ALL_ERRORMSGS

  发现还是有和更换HDD之前一样的ERROR信息,看来数据库文件还是有问题。

  --有一个奇怪问题1,既然是5块HDD的RAID5,为何有一块HDD坏会影响数据库文件的损坏,不解?

打印本文 打印本文 关闭窗口 关闭窗口