合 MSSQL数据库一直显示“正在恢复”或“可疑”的解决办法
Tags: 故障处理MSSQLSQL Server可疑正在恢复
现象
正在恢复
由于磁盘空间满了,数据库处于“恢复挂起”状态,清理磁盘后,重启SQL Server服务器后,数据库一直显示“正在恢复”,用sp_who2查询显示该库处于“DB STARTUP”状态。
查询数据库阻塞,发现有个系统进程9在阻塞,然后使用kill 9
报错:只能终止用户进程
1 2 | 消息 6107,级别 14,状态 1,第 3 行 只能终止用户进程。 |
数据库可疑
若一直“正在恢复”,或显示“可疑”(Suspect),在 SQL Server 中,如果某个数据库被标记为“可疑”(Suspect),这通常意味着该数据库的事务日志文件(.ldf)可能损坏或丢失。当一个数据库的日志文件不可用时,SQL Server 无法保证数据库的一致性,因此会将数据库状态设置为“可疑”。
可以查询告警日志是否有如下输出:
1 2 3 4 | An error occurred during recovery, preventing the database 'AB_STORE' (database ID 5) 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. During redoing of a logged operation in database 'AB_STORE', an error occurred at log record ID (1886659:12025:60). Typically, the specific failure is previously logged as an error in the Windows Event Log service. Restore the database from a full backup, or repair the database. |
若有,则说明恢复出现问题,可以使用本文的方法2进行恢复。
分析
1 | SELECT name, state_desc FROM sys.databases; |