标签:
今天修改了Service Account的密码,然后我restart Service,发现有db处于Recovery Pending状态,查看 Paul Randal 的blog,看到如下定义:
RECOVERY PENDING
如果是Recovery 还没有开始,那么这将是一个非常好的状态。如果是出现damage,那么,惨了,可能出现数据丢失。
血泪的教训:在Service Restart 之前,一定确保DB没有在运行更新操作,并使用checkpoint保存脏数据。
对于Recovery Pending状态,应该如何修复,引用《How to resolve the issue of a database that was in Recovery Pending mode》
This error is closely correlated to that Forcibly deletion process of File stream file which I do think no other solution except waiting to finish recovery mode and either wise it will end with :
Stop SQL Server and remove transaction log file of this DB then restart again where DB should go with suspect mode ….If so you can run the below query
ALTER DATABASE [DB_Name] SET SINGLE_USER WITH NO_WAIT ALTER DATABASE [DB_Name] SET EMERGENCY; DBCC checkdb ([DB_Name], REPAIR_ALLOW_DATA_LOSS ) ALTER DATABASE [DB_Name] SET online; ALTER DATABASE [DB_Name] SET Multi_USER WITH NO_WAIT
在使用CheckDB命令Repair之前,查看DB的大小
select DB_NAME(mf.database_id) as DatabaseName, mf.type_desc as FileType, mf.name as FileLogicName, mf.physical_name as FilePhysicalName, mf.size as PagesCount, mf.size*8/1024 as Size_MB, mf.size*8/1024/1024.0 as Size_GB from sys.master_files mf where mf.database_id= db_id(N‘dbname‘)
在执行时,出现各种问题:
1,User does not have permission to alter database ‘Office365‘, the database does not exist, or the database is not in a state that allows access checks.
2,Database ‘Office365‘ cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
最后,我到File Physical path下,找不到相应的MDF文件,但是Log文件是存在的,并且log文件最后修改的时间离现在有2年,可能是被遗弃的DB。而重启 Service Account ,不至于将一个18GB的MDF文件删除吧,这种情况,是什么原因?
从《Database Status》找到如下解释:
Recovery Pending state: SQL Server has encountered a resource-related error during recovery. The database is not damaged, but files may be missing or system resource limitations may be preventing it from starting. The database is unavailable. Additional action by the user is required to resolve the error and let the recovery process be completed.
附上Database Status及其 Definition
State | Definition |
---|---|
ONLINE | Database is available for access. The primary filegroup is online, although the undo phase of recovery may not have been completed. |
OFFLINE | Database is unavailable. A database becomes offline by explicit user action and remains offline until additional user action is taken. For example, the database may be taken offline in order to move a file to a new disk. The database is then brought back online after the move has been completed. |
RESTORING | One or more files of the primary filegroup are being restored, or one or more secondary files are being restored offline. The database is unavailable. |
RECOVERING | Database is being recovered. The recovering process is a transient state; the database will automatically become online if the recovery succeeds. If the recovery fails, the database will become suspect. The database is unavailable. |
RECOVERY PENDING | SQL Server has encountered a resource-related error during recovery. The database is not damaged, but files may be missing or system resource limitations may be preventing it from starting. The database is unavailable. Additional action by the user is required to resolve the error and let the recovery process be completed. |
SUSPECT | At least the primary filegroup is suspect and may be damaged. The database cannot be recovered during startup of SQL Server. The database is unavailable. Additional action by the user is required to resolve the problem. |
EMERGENCY | User has changed the database and set the status to EMERGENCY. The database is in single-user mode and may be repaired or restored. The database is marked READ_ONLY, logging is disabled, and access is limited to members of the sysadmin fixed server role. EMERGENCY is primarily used for troubleshooting purposes. For example, a database marked as suspect can be set to the EMERGENCY state. This could permit the system administrator read-only access to the database. Only members of the sysadmin fixed server role can set a database to the EMERGENCY state. |
推荐阅读:
《Troubleshooting: SCOM DW Database is in a Suspect State》
《Search Engine Q&A #4: Using EMERGENCY mode to access a RECOVERY PENDING or SUSPECT database》
《Corruption: Last resorts that people try first…》
标签:
原文地址:http://www.cnblogs.com/ljhdo/p/5532293.html