更多操作参考:https://www.cnblogs.com/gered/p/9435282.html

【生产问题】-dbcc checkdb报错-数据页故障

数据页故障,索引页故障

use db_tank
dbcc checkdb
--报错如下
由index ID 3可以得知,其为非聚集索引页出了问题
  
Msg 8978, Level 16, State 1, Line 3
Table error: Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data). Page (1:2335514) is missing a reference from previous page (1:3628311). Possible chain linkage problem.
Msg 8978, Level 16, State 1, Line 3
Table error: Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data). Page (1:2839352) is missing a reference from previous page (1:3598023). Possible chain linkage problem.
Msg 8928, Level 16, State 1, Line 3
Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data): Page (1:3598023) could not be processed. See other errors for details.
Msg 8939, Level 16, State 98, Line 3
Table error: Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data), page (1:3598023). Test (IS_OFF (BUF_IOERR, pBUF->bstat)) failed. Values are 46270473 and -4.
Msg 8976, Level 16, State 1, Line 3
Table error: Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data). Page (1:3598023) was not seen in the scan although its parent (1:7723523) and previous (1:7723545) refer to it. Check any previous errors.
Msg 8928, Level 16, State 1, Line 3
Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data): Page (1:3628311) could not be processed. See other errors for details.
Msg 8939, Level 16, State 98, Line 3
Table error: Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data), page (1:3628311). Test (IS_OFF (BUF_IOERR, pBUF->bstat)) failed. Values are 348260361 and -4.
Msg 8976, Level 16, State 1, Line 3
Table error: Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data). Page (1:3628311) was not seen in the scan although its parent (1:13500023) and previous (1:3075648) refer to it. Check any previous errors.

1、初步尝试--无损数据修复  

--切换单用户模式

alter database db_tank
set single_user with rollback IMMEDIATE
dbcc checkdb('db_tank',repair_rebuild) --尝试无损修复
--结果如下
DBCC results for 'Sys_Users_Goods'.
Msg 8978, Level 16, State 1, Line 1
Table error: Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data). Page (1:2335514) is missing a reference from previous page (1:3628311). Possible chain linkage problem.
Repairing this error requires other errors to be corrected first.
Msg 8978, Level 16, State 1, Line 1
Table error: Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data). Page (1:2839352) is missing a reference from previous page (1:3598023). Possible chain linkage problem.
Repairing this error requires other errors to be corrected first.
Msg 8928, Level 16, State 1, Line 1
Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data): Page (1:3598023) could not be processed. See other errors for details.
The repair level on the DBCC statement caused this repair to be bypassed.
Msg 8939, Level 16, State 98, Line 1
Table error: Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data), page (1:3598023). Test (IS_OFF (BUF_IOERR, pBUF->bstat)) failed. Values are 213911561 and -4.
Repairing this error requires other errors to be corrected first.
Msg 8976, Level 16, State 1, Line 1
Table error: Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data). Page (1:3598023) was not seen in the scan although its parent (1:7723523) and previous (1:7723545) refer to it. Check any previous errors.
Repairing this error requires other errors to be corrected first.
Msg 8928, Level 16, State 1, Line 1
Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data): Page (1:3628311) could not be processed. See other errors for details.
Repairing this error requires other errors to be corrected first.
Msg 8939, Level 16, State 98, Line 1
Table error: Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data), page (1:3628311). Test (IS_OFF (BUF_IOERR, pBUF->bstat)) failed. Values are 12584969 and -4.
Repairing this error requires other errors to be corrected first.
Msg 8976, Level 16, State 1, Line 1
Table error: Object ID 477960779, index ID 3, partition ID 72057594074890240, alloc unit ID 72057594081509376 (type In-row data). Page (1:3628311) was not seen in the scan although its parent (1:13500023) and previous (1:3075648) refer to it. Check any previous errors.

2.再次尝试,尝试运行丢失数据修复

select object_name(477960779) --根据object_id来找到故障对象
use db_tank
select count(1) from db_tank..Sys_Users_Goods where isexist=1 --61364953 --备份该库的有效数据,记录下该表的有效数据行
select count(1) from db_tank..Sys_Users_Goods --居然报错,那么肯定是isexist !=1的数据所在页有问题,那么即使丢失数据,也是isexist!=1的,也就是我不在乎的无效数据。那么直接跑
dbcc checktable('Sys_Users_Goods',repair_allow_data_loss)--尝试运行丢失数据修复
  
--出现  error has been repaired;
select count(1) from db_tank..Sys_Users_Goods where isexist=1 --61364953     --再次校验数据是否等于61364953,发现相等,证明只丢失了非有效数据
select count(1) from db_tank..Sys_Users_Goods --再次查看,是否完成修复,一查,不报错了,那么就证明错误已经修复。 --恢复数据库模式为多用户模式
alter database db_tank
set multi_user with rollback IMMEDIATE
 

 DBCC CHECKDB 算是管理员们最常用的命令也是必须要知道的命令了。定期的检查及问题的修复都是比较重要的!!下面介绍一下 DBCC CHECKDB 的一些基本用法。

  

  DBCC CHECKDB 完成两项任务:

  • 检查数据库里有没有损坏发生。
  • 尽力修复数据库损坏,使数据库能够被重新正常访问。

  

  DBCC CHECK 做了些什么:

  • 检查一些关键的系统表
  • 对数据库运行DBCC CHECKALLOC
  • 对数据库运行DBCC CHECKCATALOG
  • 验证数据库中每个索引视图的内容
  • 验证数据库中service broker数据

  DBCC CHECKDB提供的修复方法

  • Repair_allow_data_loss :尝试修复所有错误(可能导致一些数据丢失,一般无发从备份恢复才使用)
  • Repair_fast 未执行任何修复
  • Repair_rebuild :执行次要、快速修复(如:修复非聚集索引中的额外键)及耗时修复(如:重新生成索引),这些修复不会造成数据丢失。

  注意:使用Repair_allow_data_loss参数导致的数据丢失也许是不能接受的,一般从备份还原的数据丢失可以做到心里有数,可以通过查询丢失前数据条数与修复后数据条数进行对比知道丢了多少数据。另外在早期备份中尝试找回。

  如果使用repair_allow_data_loss级别都不能恢复:

  • 按照预先备份恢复
  • 如果损坏发生在默写用户对象(表、视图、存储过程等),可以把它们DROP掉
  • 将数据库设置成紧急只读模式,用select into 将数据导入一个新建的空库。挽救尽可能多的数据,但是损坏严重程度不一样,丢失的数据多少也不一样。这样挽救回来的数据库各个数据表的状态将不一致,一般在逻辑上或有很大的问题。

  虽然sqlserver 对dbcc checkdb 做了一些优化但是对于较大的数据库还是不小的负担所以分时间段进行不同的check检查以分散一次check的影响。还可以通过下面两个参数减轻一些消耗负担

  • With noindex : 不对非聚集索引检查。
  • With physical_only:只做物理结构完整性检查。

  

【生产问题】-dbcc checkdb报错-数据页故障的更多相关文章

  1. 生产环境elasticsearch5.0报错IllegalArgumentException: number of documents in the index cannot exceed 2147483519的处理

    最近几天的push:user:req数据写不到集群,报错如下: [--13T09::,][DEBUG][o.e.a.b.TransportShardBulkAction] [yunva_etl_es8 ...

  2. SAP SOAMANAGER报错原因与故障排除方法

    一些刚刚接触到SAP Webservice的开发者由于对SAP Netweaver组件的不熟悉,往往在使用事物码SOAMANAGER进行webservice配置的时候,发现无法正常启动SOAMANAG ...

  3. quartz 报错:java.lang.classNotFoundException

    最近在做一个调度平台改造的项目,quartz在测试环境跑的是单机环境,生产上两台服务器做集群. 测试环境是ok的,生产上线后报错,一个类java.lang.classNotFoundException ...

  4. MS Sql Server 数据库或表修复(DBCC CHECKDB)

    MS Sql Server 提供了很多数据库修复的命令,当数据库质疑或是有的无法完成读取时可以尝试这些修复命令.  1. DBCC CHECKDB  重启服务器后,在没有进行任何操作的情况下,在SQL ...

  5. SQL Server 存储(1/8):理解数据页结构

    我们都很清楚SQL Server用8KB 的页来存储数据,并且在SQL Server里磁盘 I/O 操作在页级执行.也就是说,SQL Server 读取或写入所有数据页.页有不同的类型,像数据页,GA ...

  6. SQL Server :理解数据页结构

    原文:SQL Server :理解数据页结构 我们都很清楚SQL Server用8KB 的页来存储数据,并且在SQL Server里磁盘 I/O 操作在页级执行.也就是说,SQL Server 读取或 ...

  7. 解决MySQL报错ERROR 2002 (HY000)【转】

    今天在为新的业务线搭架数据库后,在启动的时候报错 root@qsbilldatahis-db01:/usr/local/mysql/bin# ./mysql ERROR 2002 (HY000): C ...

  8. DG duplicate报错:RMAN-05001:auxiliary file name /u01/app/oracle/oradata/fratbs01.dbf conflicts with a file used by the target database

    问题:rman duplicate时报错: RMAN-05001:auxiliary file name /u01/app/oracle/oradata/fratbs01.dbf conflicts ...

  9. 解决MySQL报错ERROR 2002 (HY000)

    今天在为新的业务线搭架数据库后,在启动的时候报错 root@qsbilldatahis-db01:/usr/local/mysql/bin# ./mysql ERROR 2002 (HY000): C ...

随机推荐

  1. QT学习二:工具栏

    QT  的工具栏提供 Dock 功能.文字/图标显示排列的功能. void MainWindow::createToolBar(void) { QToolBar *toolBar = new QToo ...

  2. 复杂可编程逻辑器件CPLD的基本结构

    复杂可编程逻辑器件CPLD的基本结构 文章出处:czhlcai 发布时间: 2008/12/08 | 6911 次阅读 专业薄膜开关打样工厂,12小时加急出货   1.基于乘积项的CPLD结构 CPL ...

  3. sendmail发件人邮箱设定命令

    sendmail发件人邮箱设定命令   以前就碰到过设置发件人后缀的方式,这次迁移服务器居然忘记,从头开始记录下 1:第一种方法,修改/etc/hosts,据说sendmail使用hosts里面的本地 ...

  4. unity free asset

    Unity Test Tools https://www.assetstore.unity3d.com/#/content/13802 Sample Assets (beta) https://www ...

  5. java - day08 - PrimeNumLoop

    质数循环查找 package day07_addition; //范围查找质数 public class PrimeNumLoop { public static void main(String[] ...

  6. Shallow Heap & Retained Heap

    所有包含Heap Profling功能的工具(MAT, Yourkit, JProfiler, TPTP等)都会使用到两个名词,一个是Shallow Size,另一个是 Retained Size. ...

  7. hdu3208 Power of Integer

    /** 题目:H - Power of Integer 链接:https://vjudge.net/contest/152887#problem/H 题意:给出区间[a, b],问你区间[a, b]所 ...

  8. 以css为例谈设计模式

    什么是设计模式? 曾有人调侃,设计模式是工程师用于跟别人显摆的,显得高大上:也曾有人这么说,不是设计模式没用,是你还没有到能懂它,会用它的时候. 先来看一下比较官方的解释:"设计模式(Des ...

  9. jvm(12)-java内存模型与线程

    [0]README 0.1)本文部分文字描述转自“深入理解jvm”,旨在学习“java内存模型与线程” 的基础知识:   [1]概述 1)并发处理的广泛应用是使得 Amdahl 定律代替摩尔定律称为计 ...

  10. day23面向对象第一篇

      python之路——初识面向对象   阅读目录 楔子 面向过程vs面向对象 初识面向对象 类的相关知识 对象的相关知识 对象之间的交互 类命名空间与对象.实例的命名空间 类的组合用法 初识面向对象 ...