不正常关机引起的数据库置疑

昨晚因为家里有事需要马上回家,在下班的时候马上就关机(手提电脑),生怕赶不上公交回去,

但是Windows7关机关了很久(感觉Windows7关机比WindowsXP关机速度相差太远了)

还没有关机完毕,于是本人就拔掉电源,收拾好笔记本电脑就赶公交去了

结果回到家,打开SSMS一看,杯具的事情发生了,有3个数据库置疑

马上打开SQL ERRORLOG看一下,只有一条与置疑有关的信息

1 2013-09-11 17:38:27.97 服务器         SQL Server is terminating because of a system shutdown. This is an informational message only. No user action is required.

上面是关机之前的信息

下面是回到家开机的时候的信息

 1 2013-09-11 18:29:06.15 spid31s     错误: 9003,严重性: 20,状态: 1。
 2 2013-09-11 18:29:06.15 spid31s     The log scan number (37:324:1) passed to log scan in database 'RemoteViewTest2012' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.
 3 2013-09-11 18:29:06.27 spid32s     CHECKDB for database 'DBLOGTEST' finished without errors on 2013-06-10 00:00:46.493 (local time). This is an informational message only; no user action is required.
 4 2013-09-11 18:29:06.61 spid24s     CHECKDB for database 'hengshan' finished without errors on 2013-06-10 00:00:42.547 (local time). This is an informational message only; no user action is required.
 5 2013-09-11 18:29:07.20 spid29s     CHECKDB for database 'TransactionTestDb' finished without errors on 2013-06-10 00:01:01.113 (local time). This is an informational message only; no user action is required.
 6 2013-09-11 18:29:07.45 spid26s     CHECKDB for database 'Northwind' finished without errors on 2013-06-10 00:00:51.853 (local time). This is an informational message only; no user action is required.
 7 2013-09-11 18:29:08.23 spid27s     CHECKDB for database 'partionTest' finished without errors on 2013-09-10 22:52:17.883 (local time). This is an informational message only; no user action is required.
 8 2013-09-11 18:29:08.36 spid4s      Recovery is writing a checkpoint in database 'AdventureWorks' (6). This is an informational message only. No user action is required.
 9 2013-09-11 18:29:06.60 spid31s     错误: 3414,严重性: 21,状态: 1。
10 2013-09-11 18:29:06.60 spid31s     An error occurred during recovery, preventing the database 'RemoteViewTest2012' (database ID 17) from restarting. Diagnose the recovery errors and fix them, or restore from a known good backup. If errors are not corrected or expected, contact Technical Support.
11 2013-09-11 18:29:08.66 spid31s     CHECKDB for database 'RemoteViewTest2012' finished without errors on 2013-06-10 00:00:46.493 (local time). This is an informational message only; no user action is required.
12 2013-09-11 18:29:08.83 spid20s     CHECKDB for database 'AdventureWorks' finished without errors on 2013-06-10 00:00:08.693 (local time). This is an informational message only; no user action is required.
13 2013-09-11 18:29:09.01 spid30s     CHECKDB for database 'YourSQLDba' finished without errors on 2013-06-10 00:00:46.493 (local time). This is an informational message only; no user action is required.
14 2013-09-11 18:29:10.39 spid23s     1 transactions rolled forward in database 'DLGPOS' (9). This is an informational message only. No user action is required.
15 2013-09-11 18:29:10.66 spid21s     CHECKDB for database 'AdventureWorksDW' finished without errors on 2013-06-10 00:00:35.087 (local time). This is an informational message only; no user action is required.
16 2013-09-11 18:29:10.68 spid21s     0 transactions rolled back in database 'DLGPOS' (9). This is an informational message only. No user action is required.
17 2013-09-11 18:29:10.68 spid21s     Recovery is writing a checkpoint in database 'DLGPOS' (9). This is an informational message only. No user action is required.
18 2013-09-11 18:29:10.82 spid23s     CHECKDB for database 'DLGPOS' finished without errors on 2013-06-13 23:14:53.543 (local time). This is an informational message only; no user action is required.
19 2013-09-11 18:29:13.47 spid22s     CHECKDB for database 'dbdreamlink' finished without errors on 2013-06-10 00:00:37.570 (local time). This is an informational message only; no user action is required.
20 2013-09-11 18:29:13.69 spid28s     错误: 9003,严重性: 20,状态: 1。
21 2013-09-11 18:29:13.69 spid28s     The log scan number (276:83:1) passed to log scan in database 'GPOSDB' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.
22 2013-09-11 18:29:13.69 spid28s     错误: 3414,严重性: 21,状态: 1。
23 2013-09-11 18:29:13.69 spid28s     An error occurred during recovery, preventing the database 'GPOSDB' (database ID 14) from restarting. Diagnose the recovery errors and fix them, or restore from a known good backup. If errors are not corrected or expected, contact Technical Support.
24 2013-09-11 18:29:13.69 spid28s     CHECKDB for database 'GPOSDB' finished without errors on 2013-02-04 10:00:33.557 (local time). This is an informational message only; no user action is required.
25 2013-09-11 18:29:13.88 spid18s     24 transactions rolled forward in database 'msdb' (4). This is an informational message only. No user action is required.
26 2013-09-11 18:29:13.97 spid4s      0 transactions rolled back in database 'msdb' (4). This is an informational message only. No user action is required.
27 2013-09-11 18:29:13.97 spid4s      Recovery is writing a checkpoint in database 'msdb' (4). This is an informational message only. No user action is required.
28 2013-09-11 18:29:15.02 spid18s     CHECKDB for database 'msdb' finished without errors on 2013-06-10 00:00:49.520 (local time). This is an informational message only; no user action is required.
29 2013-09-11 18:29:16.79 spid25s     错误: 9003,严重性: 20,状态: 1。
30 2013-09-11 18:29:16.79 spid25s     The log scan number (193:5320:1) passed to log scan in database 'Monitoring' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.
31 2013-09-11 18:29:16.80 spid25s     错误: 3414,严重性: 21,状态: 1。
32 2013-09-11 18:29:16.80 spid25s     An error occurred during recovery, preventing the database 'Monitoring' (database ID 11) from restarting. Diagnose the recovery errors and fix them, or restore from a known good backup. If errors are not corrected or expected, contact Technical Support.
33 2013-09-11 18:29:16.80 spid25s     CHECKDB for database 'Monitoring' finished without errors on 2013-06-10 00:00:47.140 (local time). This is an informational message only; no user action is required.
34 2013-09-11 18:29:38.33 spid4s      Recovery is writing a checkpoint in database 'pratice' (5). This is an informational message only. No user action is required.
35 2013-09-11 18:29:38.75 spid19s     CHECKDB for database 'pratice' finished without errors on 2013-06-10 00:00:56.963 (local time). This is an informational message only; no user action is required.
36 2013-09-11 18:29:40.27 spid4s      Recovery is complete. This is an informational message only. No user action is required.
37 2013-09-11 18:29:48.07 spid52      Using 'xpsqlbot.dll' version '2005.90.5000' to execute extended stored procedure 'xp_qv'. This is an informational message only; no user action is required.
38 2013-09-11 18:29:52.60 spid52      Using 'xpstar90.dll' version '2005.90.5000' to execute extended stored procedure 'xp_instance_regread'. This is an informational message only; no user action is required.
39 2013-09-11 18:29:53.21 spid52      Using 'xplog70.dll' version '2005.90.5000' to execute extended stored procedure 'xp_msver'. This is an informational message only; no user action is required.
40 2013-09-11 19:03:59.16 spid57      Common language runtime (CLR) functionality initialized using CLR version v2.0.50727 from C:\Windows\Microsoft.NET\Framework\v2.0.50727\.
41 2013-09-11 19:03:59.82 spid57      AppDomain 2 (pratice.dbo[runtime].1) created.
42 2013-09-11 19:10:02.86 spid59      DBCC TRACEON 3604, server process ID (SPID) 59. This is an informational message only; no user action is required.
43 2013-09-11 19:10:02.92 spid59      DBCC TRACEOFF 3604, server process ID (SPID) 59. This is an informational message only; no user action is required.

由于我没有做数据库备份,只能使用下面的SQL脚本来逐个数据库逐个数据库紧修复

 1 --恢复数据库置疑状态sp_resetstatus 2013-5-9           已放博客园
 2 EXEC [sys]. [sp_resetstatus] @DBName = 'GPOSDB'
 3   --重置置疑数据库的状态
 4
 5 --sp_resetstatus 关闭数据库上的置疑标记。此过程更新 sysdatabases 中的命名数据库的模式和状态列。
 6 --在运行此过程之前,应参考 SQL Server 错误日志并解决所有问题。执行 sp_resetstatus 后停止并重新启动SQL Server。
 7 --由于某些原因,数据库可能成为置疑状态。
 8 --可能的原因包括操作系统拒绝对数据库资源的访问,以及一个或多个数据库文件不可用性或已损坏。
 9
10 ALTER DATABASE [GPOSDB] SET EMERGENCY
11 GO
12 DBCC CHECKDB ( 'GPOSDB') WITH NO_INFOMSGS ,ALL_ERRORMSGS
13
14
15 ALTER DATABASE [GPOSDB] SET SINGLE_USER  WITH ROLLBACK IMMEDIATE
16
17 EXEC sys.SP_CONFIGURE 'ALLOW UPDATES' , 1
18 RECONFIGURE WITH OVERRIDE
19 GO
20 RECONFIGURE WITH OVERRIDE
21 GO
22
23 DBCC checkdb( 'GPOSDB',REPAIR_ALLOW_DATA_LOSS )
24 GO
25
26 ALTER DATABASE [GPOSDB] SET MULTI_USER
27 GO
28
29
30 ALTER DATABASE [GPOSDB] SET ONLINE
31 GO

View Code

输出的信息

  1 数据库 "RemoteViewTest2012" 上的可疑标志已经重置。
  2 配置选项 'allow updates' 已从 1 更改为 1。请运行 RECONFIGURE 语句进行安装。
  3 警告: 数据库 'RemoteViewTest2012' 的日志已重新生成。已失去事务的一致性。RESTORE 链已断开,服务器不再有以前的日志文件的上下文,因此您需要了解它们的内容。应运行 DBCC CHECKDB 验证物理一致性。数据库已置于 dbo-only 模式。在准备使数据库可用时,需要重置数据库选项,并删除所有多余的日志文件。
  4 RemoteViewTest2012的 DBCC 结果。
  5 Service Broker 消息 9675,状态 1: 已分析的消息类型: 14。
  6 Service Broker 消息 9676,状态 1: 已分析的服务约定: 6。
  7 Service Broker 消息 9667,状态 1: 已分析的服务: 3。
  8 Service Broker 消息 9668,状态 1: 已分析的服务队列: 3。
  9 Service Broker 消息 9669,状态 1: 已分析的会话端点: 0。
 10 Service Broker 消息 9674,状态 1: 已分析的会话组: 0。
 11 Service Broker 消息 9670,状态 1: 已分析的远程服务绑定: 0。
 12 sys.sysrowsetcolumns的 DBCC 结果。
 13 对象 'sys.sysrowsetcolumns' 的 5 页中有 541 行。
 14 sys.sysrowsets的 DBCC 结果。
 15 对象 'sys.sysrowsets' 的 1 页中有 79 行。
 16 sysallocunits的 DBCC 结果。
 17 对象 'sysallocunits' 的 1 页中有 90 行。
 18 sys.sysfiles1的 DBCC 结果。
 19 对象 'sys.sysfiles1' 的 1 页中有 2 行。
 20 sys.syshobtcolumns的 DBCC 结果。
 21 对象 'sys.syshobtcolumns' 的 5 页中有 541 行。
 22 sys.syshobts的 DBCC 结果。
 23 对象 'sys.syshobts' 的 1 页中有 79 行。
 24 sys.sysftinds的 DBCC 结果。
 25 对象 'sys.sysftinds' 的 0 页中有 0 行。
 26 sys.sysserefs的 DBCC 结果。
 27 对象 'sys.sysserefs' 的 1 页中有 90 行。
 28 sys.sysowners的 DBCC 结果。
 29 对象 'sys.sysowners' 的 1 页中有 14 行。
 30 sys.sysprivs的 DBCC 结果。
 31 对象 'sys.sysprivs' 的 1 页中有 120 行。
 32 sys.sysschobjs的 DBCC 结果。
 33 对象 'sys.sysschobjs' 的 1 页中有 51 行。
 34 sys.syscolpars的 DBCC 结果。
 35 对象 'sys.syscolpars' 的 7 页中有 425 行。
 36 sys.sysnsobjs的 DBCC 结果。
 37 对象 'sys.sysnsobjs' 的 1 页中有 1 行。
 38 sys.syscerts的 DBCC 结果。
 39 对象 'sys.syscerts' 的 0 页中有 0 行。
 40 sys.sysxprops的 DBCC 结果。
 41 对象 'sys.sysxprops' 的 0 页中有 0 行。
 42 sys.sysscalartypes的 DBCC 结果。
 43 对象 'sys.sysscalartypes' 的 1 页中有 27 行。
 44 sys.systypedsubobjs的 DBCC 结果。
 45 对象 'sys.systypedsubobjs' 的 0 页中有 0 行。
 46 sys.sysidxstats的 DBCC 结果。
 47 对象 'sys.sysidxstats' 的 2 页中有 142 行。
 48 sys.sysiscols的 DBCC 结果。
 49 对象 'sys.sysiscols' 的 1 页中有 257 行。
 50 sys.sysbinobjs的 DBCC 结果。
 51 对象 'sys.sysbinobjs' 的 1 页中有 23 行。
 52 sys.sysobjvalues的 DBCC 结果。
 53 对象 'sys.sysobjvalues' 的 23 页中有 144 行。
 54 sys.sysclsobjs的 DBCC 结果。
 55 对象 'sys.sysclsobjs' 的 1 页中有 14 行。
 56 sys.sysrowsetrefs的 DBCC 结果。
 57 对象 'sys.sysrowsetrefs' 的 0 页中有 0 行。
 58 sys.sysremsvcbinds的 DBCC 结果。
 59 对象 'sys.sysremsvcbinds' 的 0 页中有 0 行。
 60 sys.sysxmitqueue的 DBCC 结果。
 61 对象 'sys.sysxmitqueue' 的 0 页中有 0 行。
 62 sys.sysrts的 DBCC 结果。
 63 对象 'sys.sysrts' 的 1 页中有 1 行。
 64 sys.sysconvgroup的 DBCC 结果。
 65 对象 'sys.sysconvgroup' 的 0 页中有 0 行。
 66 sys.sysdesend的 DBCC 结果。
 67 对象 'sys.sysdesend' 的 0 页中有 0 行。
 68 sys.sysdercv的 DBCC 结果。
 69 对象 'sys.sysdercv' 的 0 页中有 0 行。
 70 sys.syssingleobjrefs的 DBCC 结果。
 71 对象 'sys.syssingleobjrefs' 的 1 页中有 133 行。
 72 sys.sysmultiobjrefs的 DBCC 结果。
 73 对象 'sys.sysmultiobjrefs' 的 1 页中有 106 行。
 74 sys.sysdbfiles的 DBCC 结果。
 75 对象 'sys.sysdbfiles' 的 1 页中有 2 行。
 76 sys.sysguidrefs的 DBCC 结果。
 77 对象 'sys.sysguidrefs' 的 0 页中有 0 行。
 78 sys.sysqnames的 DBCC 结果。
 79 对象 'sys.sysqnames' 的 1 页中有 91 行。
 80 sys.sysxmlcomponent的 DBCC 结果。
 81 对象 'sys.sysxmlcomponent' 的 1 页中有 93 行。
 82 sys.sysxmlfacet的 DBCC 结果。
 83 对象 'sys.sysxmlfacet' 的 1 页中有 97 行。
 84 sys.sysxmlplacement的 DBCC 结果。
 85 对象 'sys.sysxmlplacement' 的 1 页中有 17 行。
 86 sys.sysobjkeycrypts的 DBCC 结果。
 87 对象 'sys.sysobjkeycrypts' 的 0 页中有 0 行。
 88 sys.sysasymkeys的 DBCC 结果。
 89 对象 'sys.sysasymkeys' 的 0 页中有 0 行。
 90 sys.syssqlguides的 DBCC 结果。
 91 对象 'sys.syssqlguides' 的 0 页中有 0 行。
 92 sys.sysbinsubobjs的 DBCC 结果。
 93 对象 'sys.sysbinsubobjs' 的 0 页中有 0 行。
 94 sys.queue_messages_1977058079的 DBCC 结果。
 95 对象 'sys.queue_messages_1977058079' 的 0 页中有 0 行。
 96 sys.queue_messages_2009058193的 DBCC 结果。
 97 对象 'sys.queue_messages_2009058193' 的 0 页中有 0 行。
 98 sys.queue_messages_2041058307的 DBCC 结果。
 99 对象 'sys.queue_messages_2041058307' 的 0 页中有 0 行。
100 WebHits_ShangHai的 DBCC 结果。
101 对象 'WebHits_ShangHai' 的 1 页中有 1 行。
102 CHECKDB 在数据库 'RemoteViewTest2012' 中发现 0 个分配错误和 0 个一致性错误。
103 DBCC 执行完毕。如果 DBCC 输出了错误信息,请与系统管理员联系。

View Code

修复完毕之后,查询了那些置疑数据库,发现数据都没有丢失,这个事情算解决完了

小结:

在这里要提醒大家注意的是

(1)平时要正确断开数据库链接,并正常关机

(2)定期做好数据库备份

(3)最好使用UPS保证断电的时候不会发生杯具的事情

我们曾经遇到过有两三个客户就是因为突然断电,刚好UPS也坏了,造成数据库置疑,幸好有数据库备份,不然就惨了

当然,这个是我私人笔记本电脑,即使数据丢失损失也不大,但是大家在客户那里一定要做好数据保护工作,定期做好备份

不然的话,等杯具来临的时候损失就不是你个人可以承担的了

转载于:https://www.cnblogs.com/lyhabc/p/3316655.html

不正常关机引起的数据库置疑相关推荐

  1. MSDB数据库置疑状态的解决方法

    转自:百度文库 问题:我的SQL Server 2000的MSDB数据库,因为不正常关机,造成了置疑状态,请问采用什么方法能够弥补? 解决方法一:你可以采用以下的代码进行修复: USE MASTER ...

  2. sql2000数据库置疑

    sqlserver附加数据库错误823的解决方案 一.SQL-Server附加数据库时失败. 1.异常情况:服务器在正常运行的情况下突然断电,导致数据库文件损坏,具体表现是:数据库名后面有" ...

  3. sqlserver日志文件在哪_用友SQL SERVER数据库置疑修复实例

    数据库置疑修复实例 方法1: 企业管理器能够正常分离附加时: 第一步:先把数据库服务停止客户数据SQL SERVER服务停止把软件安装所在目录的账套数据复制一份,以避免操作不当造成的数据丢失. 小提示 ...

  4. sql2000数据库置疑造成的原因以及如何解决置疑

    sql2000数据库置疑造成的原因以及如何解决置疑 参考文章: (1)sql2000数据库置疑造成的原因以及如何解决置疑 (2)https://www.cnblogs.com/www123----/p ...

  5. SQL SERVER数据库置疑后恢复步骤

    --SQL SERVER数据库置疑后恢复步骤    --1. 恢复步骤:    --a.将smlog_log.ldf文件备份到其它目录下:    --b.将源目录下的smlog_log.ldf文件改名 ...

  6. SQL 2000数据库置疑及修复方案

    数据库置疑及修复 数据库置疑处理 提要:在数据库置疑或者修复的处理过程中,须先将文中的数据库更改为真实的数据库名称. 数据库置疑修复处理完成后,需执行第二步骤,使用DBCC语句对数据库进行检测并修复错 ...

  7. SQL server 2000及SQL server 2005 数据库置疑解决办法

    以数据库mpcyerp为例,做对数据库置疑的处理方法说明: 一.将mpcyerp_Data.MDF文件拷贝出来并备份 在企业管理器中建立一个同名的新数据库mpcyerp 二.停止SQL Server服 ...

  8. 数据库置疑的处理步骤(以数据库'shop07'为例)

    –数据库置疑的处理步骤(以数据库'shop07'为例) select * from sysdatabases –1.停掉SQL Server服务(在运行中执行以下命令): NET STOP MSSQL ...

  9. Sql server 2005与2008 数据库置疑修复

    SQL2005和SQL2008数据库可疑状态处理,类似于SQL2000的置疑处理 USE MASTER GO//将数据库设成紧急模式 SP_CONFIGURE 'ALLOW UPDATES',1 RE ...

最新文章

  1. 使用 LocalReport 对象进行打印
  2. 高并发编程-线程通信_使用wait和notify进行线程间的通信2_多生产者多消费者导致程序假死原因分析
  3. 看好电影,学标准英语
  4. angularjs html编辑器,AngularJS集成wangeditor富文本编辑器
  5. 送一些豆瓣 8.9 分优质书,啃完拿下 BAT 高薪 offer 不是梦!
  6. obs可以推到中转服务器吗,能否使用OBS(Open Broadcaster Software)、FMLE(Flash Media Live Encoder)等第三方软件进行推流?...
  7. 计算机c盘哪些东西可以清理,细说电脑c盘哪些文件可以删除
  8. c++ cdi+示例_C ++“和”关键字示例
  9. idea+springboot+mongodb的实战使用分享
  10. TensorFlow第十二步 自编码器去噪降维
  11. JSP Servlet Mysql学生宿舍管理系统
  12. mysql部署window设置分片_window配置 mysql 详细步骤
  13. 了解 Nginx 主要应用场景
  14. 合肥科学岛安光所计算机应用,国家大气污染防治攻关联合中心成立 合肥科学岛安光所承担重任...
  15. 短视频网站源码干货分享:如何实现背景音乐和美颜功能
  16. 高等数学微积分公式大全
  17. n9100 分区 Linux,​史上最全的三星N9100官方固件
  18. springboot 配置programe arguments 不生效
  19. qt样式表设置边框_Qt样式表之 QSS 语法介绍
  20. linux支持vmfs文件系统吗,调整vmfs文件系统块大小

热门文章

  1. 打不开<dirent.h>和<<unistd.h>>
  2. Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven...
  3. DirectShow学习笔记总结
  4. Android5.0以上去除状态栏半透明遮罩
  5. 31岁失业四个月,做测试好迷茫,怎么规划呢?
  6. js 将json字符串转换为json对象的方法解析
  7. Hutool 自定义excel导出
  8. Windows环境搭建C语言开发环境
  9. SPSS(Statistical Product and Service Solutions)安装
  10. Python 内置函数—判断素数