Home > Database > Mysql Tutorial > body text

数据库修复Part2: 页面还原

WBOY
Release: 2016-06-07 15:44:11
Original
1362 people have browsed it

上文我们已经新建了Corrupt的数据库,今天我们就用页面还原修复损坏的页面。 首先我们允许DBCC CHECKDB查看损坏的页面ID: DBCC CHECKDB with NO_INFOMSGS Msg 8928, Level 16,State 1, Line 1 Object ID2105058535, index ID 0, partition ID 7205759403877

上文我们已经新建了Corrupt的数据库,今天我们就用页面还原修复损坏的页面。

 

首先我们允许DBCC CHECKDB查看损坏的页面ID:

 

DBCC CHECKDB withNO_INFOMSGS 

 

Msg 8928, Level 16,State 1, Line 1

Object ID2105058535, index ID 0, partition ID 72057594038779904, alloc unit ID72057594039828480 (type In-row data): Page (1:78) could not be processed. See other errors for details.

Msg 8939, Level 16,State 98, Line 1

Table error: ObjectID 2105058535, index ID 0, partition ID 72057594038779904, alloc unit ID72057594039828480 (type In-row data), page (1:78). Test (IS_OFF (BUF_IOERR,pBUF->bstat)) failed. Values are 12716041 and -4.

repair_allow_data_loss is the minimumrepair level for the errors found by DBCC CHECKDB (corrupt).

 

建议的修复 是repair_allow_data_loss,但是如果用repair_allow_data_loss修复的话就会有数据损失,而且可能会造成数据一致性问题。SQL Server 2005之后提供了Page Restore,使用Page Restore我们可以直接修复这个损坏的页面。

 

命令:---Corrupt.bak是在数据库损坏之前的备份

 

restore database corrupt page='1:78'fromdisk ='d:\mssql\corrupt.bak'withnorecovery

 

backup log corrupttodisk='d:\mssql\corrupt.trn'

 

restore log corruptfromdisk='d:\mssql\corrupt.trn'withrecovery

 

页面还原用于修复隔离出来的损坏页。 还原和恢复少量页面的速度可能比还原一个文件更快,因此减少了还原操作中处于脱机状态的数据量。

 

还原页步骤:

1.       获取要还原的损坏页的页 ID。

2.       从包含页的完整数据库备份、文件备份或文件组备份开始进行页面还原。 RESTORE DATABASE 语句中,使用 PAGE 子句列出所有要还原的页的页 ID。

3.       应用最近的差异。

4.       应用后续日志备份。

5.       创建新的数据库日志备份,使其包含已还原页的最终 LSN,即最后还原的页脱机的时间点。 设置为顺序中首先还原的最终 LSN 是重做目标 LSN。包含该页的文件的联机前滚可以在重做目标 LSN 处停止。

6.       还原新的日志备份。 应用这个新的日志备份后,就完成了页面还原,可以开始使用页了。

 

更多页面还原信息请参考:http://msdn.microsoft.com/zh-cn/library/ms175168.aspx

 

 

 

 

 

 

 

 

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!