`

数据库文件出现坏块修复过程

阅读更多
<meta content="MSHTML 6.00.2900.3199" name="GENERATOR"> <style></style>2004年08月09日 14:28:00

前几天,数据库文件出问题,现象就是,一些的查询操作会报以下错误:

Microsoft OLE DB Provider for SQL Server 错误 '80004005'
Warning: Fatal error 644 occurred at Aug 5 2004 8:45AM

或者:

Microsoft OLE DB Provider for SQL Server 错误 '80004005'
Warning: Fatal error 823 occurred at Aug 4 2004 10:39PM

823 错误是指:
SQL Server 在对某设备进行读或写请求时遇到 I/O 错误。该错误通常表明磁盘

问题。

644 错误是指:
当索引 ID 表示的非聚集索引出错时发生该错误。当进程试图删除不存在的行时检测到该损坏。

那个数据库服务器的硬盘是做了Raid 5 的,查询具体的硬盘,没有看到那块硬盘坏了。把数据备份,然后恢复到另外一台机子。仍然存在这个问题。显然数据库文件有坏块了。

试图通过下面语句修复数据库,但是只能修复部分数据,但是不能完全修复。

dbcc checktable('数据表')
dbcc checktable('数据表') WITH ALL_ERRORMSGS
DBCC CHECKTABLE (数据表,repair_allow_data_loss)

DBCC DBREINDEX('数据表')

sp_dboption '数据库名', 'SINGLE USER', TRUE
DBCC CHECKDB('数据库名', REPAIR_ALLOW_DATA_LOSS)
sp_dboption '数据库名', 'SINGLE USER', FALSE


用SQL Server 的导入导出功能无法完全导出数据。会报 823 错误。对所有数据的Select ,也会报 823 错误。

下面是用这些修复语句修复后,返回的一些有代表性的错误信息:

Server: Msg 8929, Level 16, State 1, Line 1
对象 ID 797245895: 在文本 ID 4582550994944 中发现错误,该文本的所有者是由 RID = (1:65204:25) ReplyID = 22853478 标识的数据记录。

Server: Msg 8909, Level 16, State 1, Line 1
表错误: 对象 ID 0,索引 ID 13824,页 ID (1:430153)。页首结构中的 PageId = (31744:9744137)。

Server: Msg 2533, Level 16, State 1, Line 1
表错误: 未发现页 (1:307388),该页分配给了对象 ID 397244470,索引 ID 0。可能页无效或页首结构中的对象 ID 信息不正确。

Server: Msg 8978, Level 16, State 1, Line 1
表错误: 对象 ID 397244470,索引 ID 1。页 (1:307360) 缺少上一页 (1:307391) 对它的引用。可能是因为链的链接有问题。

Server: Msg 8976, Level 16, State 1, Line 1
表错误: 对象 ID 397244470,索引 ID 1。在扫描操作中未发现页 (1:307388),而其父代 (1:308098) 和上一页 (1:307387) 指向了该页。请检查先前的错误。

Server: Msg 8980, Level 16, State 1, Line 1
表错误: 对象 ID 397244470,索引 ID 1。索引节点页 (1:308098),槽 155 指向子页 (1:307389) 和上一子页 (1:307388),但未遇到这些页。

Server: Msg 8939, Level 16, State 1, Line 1
表错误: 对象 ID 825360384,索引 ID 62467,页 (1:430152)。测试(m_slotCnt > MaxSlot)失败。值为 5409 和 4048。

Server: Msg 8986, Level 16, State 1, Line 1
发现的错误数目(201)太多(属于对象 ID 797245895)。若要查看所有的错误信息,请用 'WITH ALL_ERRORMSGS' 重新运行该语句。

Server: Msg 8964, Level 16, State 1, Line 1
Table error: Object ID 797245895. The text, ntext, or image node at page (1:90548), slot 53, text ID 4297096364032 is not referenced.

Server: Msg 8974, Level 16, State 1, Line 1
Text node referenced by more than one node. Object ID 797245895, text, ntext, or image node page (1:100941), slot 15, text ID 4367996551168 is pointed to by page (1:407572), slot 25 and by page (1:430169), slot 25.

Server: Msg 8961, Level 16, State 1, Line 1
Table error: Object ID 797245895. The text, ntext, or image node at page (1:100944), slot 29, text ID 4582550732800 does not match its reference from page (1:430166), slot 55.

Server: Msg 8965, Level 16, State 1, Line 1
Table error: Object ID 797245895. The text, ntext, or image node at page (1:307381), slot 4, text ID 4584554954752 is referenced by page (1:3786), slot 75, but was not seen in the scan.


Error: 823, Severity: 24, State: 2
I/O error (torn page) detected during read at offset 0x000000d2086000 in file 'E:\database\DbName.mdf'.


17310 :
SqlDumpExceptionHandler: Process 3224 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.

17065 :
SQL Server Assertion: File: >"xact"
18052 :
Error: 3624, Severity: 20, State: 1.

17066 :
SQL Server Assertion: File: >proc.c
17066 :
SQL Server Assertion: File: >recbase.cpp m_SizeRec'.

这些修复都无效后,最后只有采用了最原始的方式,写程序逐行用SELECT语句将数据提取出来。好在每天都有备份,这次只有几十条数据丢失。

至于为啥产生这个错误,目前仍然不知道。



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=69303


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics