zoukankan      html  css  js  c++  java
  • How to recreate the msdb database in SQL Server 2005

    How to recreate the msdb database in SQL Server 2005?

    I've just spent a bunch time researching an answer to this question on the new disaster recovery forum because I couldn't find any definitive info on how to do this in SQL Server 2005. I pieced together a method to do this on previous releases of SQL Server and tried it on one of the SQL Server 2005 instances on my laptop to make sure it works. I'd like to share it with everyone to save someone having to do the same.

    If your msdb goes suspect then you have two choices, restore it from a backup or recreate it (and then recreate any scheduled jobs). Obviously everyone has a comprehensive and valid set of backups, right? If only...

    Of course, the very first thing you do is work out why it went suspect in the first place and take any necessary steps to stop it happening again.

    Now you'd hope that if you don't have a valid msdb backup then you can at least run repair on it and so you don't lose everything in there. Well, that works as long as the transaction log isn't damaged. Ok, but then surely we can stick the database into the now-documented emergency mode (alter database dbname set emergency) and run emergency mode repair? (dbcc checkdb (dbname, repair_allow_data_loss) in emergency mode). Nope, msdb can't be put into emergency mode.

    So, you're out of options and you're going to have to recreate msdb. Here's what to do (change the directory paths to suit your installation):

    1. Detach the damaged msdb. You can't just detach msdb because you're not allowed to detach system databases. However, you can if you start the server with trace flag 3608. I did this by shutting down the server, navigating to the directory 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn' and doing the following: start sqlservr.exe -c -T3608
    2. Move or rename the damaged msdb files (msdbdata.mdf and msdblog.ldf in the 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data' directory)
    3. Run the instmsdb.sql script in the 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Install' directory
    4. Shutdown and restart the server without the 3608 trace flag

    This works on SQL Server 2000 as well.

    Hopefully you'll never have to do this but if you ever do, let me know how it goes for you.

    Published Tuesday, June 06, 2006 7:01 PM by Paul Randal - MSFT Filed under: Disaster Recovery

    只能从在服务器实例当前运行的 SQL Server 版本上创建的备份中还原系统数据库。例如,若要还原在 SQL Server 2005 SP1 上运行的服务器实例上的系统数据库,则必须使用在服务器实例升级到 SQL Server 2005 SP1 之后所创建的数据库备份。

    http://msdn.microsoft.com/zh-cn/library/ms190749.aspx


    作者:nzperfect
    出处:http://www.cnblogs.com/nzperfect/
    引用或者转载本BLOG的文章请注明原作者和出处,并保留原文章中的版权信息。

  • 相关阅读:
    CF598E Chocolate Bar 题解 动态规划
    CF864E Fire 题解 背包DP
    用 程序 解决 windows防火墙 的 弹窗 问题
    windbg 使用与技巧
    bat 下 字符串拆分 类似 split 可以使用 for /f delims
    vs2013 在按F5调试时,总是提示 “项目已经过期”的解决方案
    代理与反向代理
    关于维护用户状态的一致性
    视频的裁剪后缩放功能。
    通信协议的设计
  • 原文地址:https://www.cnblogs.com/nzperfect/p/1694031.html
Copyright © 2011-2022 走看看