zoukankan      html  css  js  c++  java
  • 如何解决Database处于Recovery Pending状态

    上篇文章里, 我们通过脚本修改了数据库MDF和LDF文件的位置, 恢复了之后, 发现数据库处于Recovery Pending状态.

    image

    如何解决呢?

    尝试一

    =======================

    运行下面的命令, 失败.

    RESTORE DATABASE SharePoint_Config WITH RECOVERY
    

    报错:

    Msg 3148, Level 16, State 3, Line 1
    This RESTORE statement is invalid in the current context. The 'Recover Data Only' option is only defined for secondary filegroups when the database is in an online state. When the database is in an offline state filegroups cannot be specified.
    Msg 3013, Level 16, State 1, Line 1
    RESTORE DATABASE is terminating abnormally.

    尝试二

    ======================

    运行下面的命令, 失败.

    DBCC checkdb ('SharePoint_Config')
    

    报错:

    Msg 945, Level 14, State 2, Line 1
    Database 'SharePoint_Config' cannot be opened due to inaccessible files or insufficient memory or disk space.  See the SQL Server errorlog for details.

    这里注意到"inaccessible files"字样, 于是想起应该检查一下存放MDF和LDF的路径的权限设置是否与默认的文件夹相同.

    经过比较, 发现少了用户"MSSQLSERVER"的full control.

    image

    添加NT Service\MSSQLSERVER用户后, 赋予full control权限, 问题依旧. 看起来不是权限的问题.

    笔者还尝试了下面的命令, 均告失败.

    EXEC sp_resetstatus 'SharePoint_Config';
    ALTER DATABASE "SharePoint_Config" SET EMERGENCY
    DBCC checkdb('SharePoint_Config')
    ALTER DATABASE "SharePoint_Config" SET SINGLE_USER WITH ROLLBACK IMMEDIATE
    DBCC CheckDB ('SharePoint_Config', REPAIR_FAST)
    DBCC CheckDB ('SharePoint_Config', REPAIR_ALLOW_DATA_LOSS)
    

    笔者最后将两个数据库删掉, 重新Attach MDF和LDF文件, 才将数据库状态恢复.

    笔者不会放过这个问题, 明天找数据库专家咨询一下.

    参考资料

    =======================

    Database States

    http://msdn.microsoft.com/en-us/library/ms190442.aspx

    DBCC CHECKDB

    http://msdn.microsoft.com/en-us/library/aa258278%28v=sql.80%29.aspx

    Suspect Database Recovery (SQL Server 2005)

    http://social.msdn.microsoft.com/Forums/en-US/sqldatabaseengine/thread/ea8b251f-fbce-4f8b-8a87-1b570688ce88/

  • 相关阅读:
    shell 冒泡算法 解决数组排序问题
    react(二)
    react(一)
    mybatis-plus:3
    lambda
    配置中心(nacos)-控制台使用
    nacos作为配置中心的简单项目配置
    nacos作为注册中心的简单项目配置
    Vue初步学习
    nacos单例模式简单搭建
  • 原文地址:https://www.cnblogs.com/awpatp/p/2937875.html
Copyright © 2011-2022 走看看