【生产问题】-dbcc checkdb报错-数据页故障
更多操作参考: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报错-数据页故障的更多相关文章
- 生产环境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 ...
- SAP SOAMANAGER报错原因与故障排除方法
一些刚刚接触到SAP Webservice的开发者由于对SAP Netweaver组件的不熟悉,往往在使用事物码SOAMANAGER进行webservice配置的时候,发现无法正常启动SOAMANAG ...
- quartz 报错:java.lang.classNotFoundException
最近在做一个调度平台改造的项目,quartz在测试环境跑的是单机环境,生产上两台服务器做集群. 测试环境是ok的,生产上线后报错,一个类java.lang.classNotFoundException ...
- MS Sql Server 数据库或表修复(DBCC CHECKDB)
MS Sql Server 提供了很多数据库修复的命令,当数据库质疑或是有的无法完成读取时可以尝试这些修复命令. 1. DBCC CHECKDB 重启服务器后,在没有进行任何操作的情况下,在SQL ...
- SQL Server 存储(1/8):理解数据页结构
我们都很清楚SQL Server用8KB 的页来存储数据,并且在SQL Server里磁盘 I/O 操作在页级执行.也就是说,SQL Server 读取或写入所有数据页.页有不同的类型,像数据页,GA ...
- SQL Server :理解数据页结构
原文:SQL Server :理解数据页结构 我们都很清楚SQL Server用8KB 的页来存储数据,并且在SQL Server里磁盘 I/O 操作在页级执行.也就是说,SQL Server 读取或 ...
- 解决MySQL报错ERROR 2002 (HY000)【转】
今天在为新的业务线搭架数据库后,在启动的时候报错 root@qsbilldatahis-db01:/usr/local/mysql/bin# ./mysql ERROR 2002 (HY000): C ...
- 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 ...
- 解决MySQL报错ERROR 2002 (HY000)
今天在为新的业务线搭架数据库后,在启动的时候报错 root@qsbilldatahis-db01:/usr/local/mysql/bin# ./mysql ERROR 2002 (HY000): C ...
随机推荐
- ASP.NET MVC4空MVC项目添加脚本压缩和合并
本文介绍的是 建立的空MVC项目如何添加该功能 1.选中MVC项目,右键>"管理解决反感的NuGet程序包" 2.在"联机"中在线搜索搜索"Op ...
- JAVA代码之RocketMQ生产和消费数据
一.启动RocketMQ [root@master ~]# cat /etc/hosts # Do not remove the following line, or various programs ...
- APACHE KYLIN™ 概览
APACHE KYLIN™ 概览 Apache Kylin™是一个开源的分布式分析引擎,提供Hadoop之上的SQL查询接口及多维分析(OLAP)能力以支持超大规模数据,最初由eBay Inc. 开发 ...
- 【问题记录】MySQL中时间戳转日期格式和Java中时间戳转日期格式偶尔不一致
背景: MySQL的某个字段存放着一些时间戳格式的时间. 问题描述: Java程序将MySQL中的时间戳字段取出来,在Java程序中转成yyyy-MM-dd HH:mm:ss格式的时候,偶尔会出现转化 ...
- iOS- 详解文本属性Attributes(转)
iOS- 详解文本属性Attributes 1.NSKernAttributeName: @10 调整字句 kerning 字句调整 2.NSFontAttributeName : [UIFont s ...
- Yarn源码分析之参数mapreduce.job.reduce.slowstart.completedmaps介绍
mapreduce.job.reduce.slowstart.completedmaps是MapReduce编程模型中的一个参数,这个参数的含义是,当Map Task完成的比例达到该值后才会为Redu ...
- ubuntu 12.10 apt-get 源
更改apt-get源配置文件/etc/apt/sources.list 用一下内容替换掉 deb http://mirrors.163.com/ubuntu/ precise main restric ...
- 为什么Servlet修改之后,Tomcat都得重启,servlet才会生效!
最近做东西经常需要重新加载项目,今天深深的问了自己为什么? Servlet的生命周期中,只会初始化一次,如果每次要是发送请求或响应,Servlet引擎都会调用service.从这里就会看出,servl ...
- python django -1
VT Django是一款python的web开发框架 与MVC有所不同,属于MVT框架 m表示model,负责与数据库交互 v表示view,是核心,负责接收请求.获取数据.返回结果 t表示templa ...
- 目标跟踪之klt---光流跟踪法
近来在研究跟踪,跟踪的方法其实有很多,如粒子滤波(pf).meanshift跟踪,以及KLT跟踪或叫Lucas光流法,这些方法各自有各自的有点,对于粒子滤波而言,它能够比较好的在全局搜索到最优解,但其 ...