Have you ever has an issues with a SQL server (2000, 2005, 2008 and so on) that you needed to rebuilt the master database? I've had that problem not too long ago and had to spend some time researching how this can be done. Here is a good site with the information you will need to rebuild the master database (http://blogs.msdn.com/b/psssql/archive/2008/08/29/how-to-rebuild-system-databases-in-sql-server-2008.aspx). But with a little work you can rebuild the master and the other system databases in less than 5 minutes. Let's see how this can be done.
If I had to rebuild the master database or worse uninstall SQL server and reinstall SQL server completely the restore time for the whole environment would have taken a lot longer.
This process will not cure everything, but it is a faster way to rebuild your master database.
Hope you find this helpful,
Rudy
It's All Proactive
To quickly rebuild the master and system database you need to have done some proactive work before you need to do a rebuild. Here is a quick and easy list of task to do proactively.- Stop all SQL server services
- Copy the master.mdf and master.ldf files from the SQL server's data folder to another folder
- Restart all SQL server services
Time to Rebuild
So now what? Now when a master database has to be rebuilt due to corruption of some kind you can quick get back to a good state by performing the following.- Stop all SQL server services
- Rename the master.mdf to master.mdf.old and master.ldf to master.ldf.old
- Copy the master.mdf and master.ldf files from your folder to the SQL server's data folder
- Restart all SQL server services
- Log into SQL server to ensure you can connect
- Perform a restore of the master database from your backups
Real World Example
Here is my real world example. At a disaster recovery test I had to build a SQL server 2008 environment and restore all of the SQL server's databases. This included all user and system databases. After the initial installation of SQL server 2008 I copied the master database files to a new folder I called 'D:\OrgFileBackup'. Then I performed the restore of the master database from our tape backups. During the restore an error occurred and the master database became corrupted. I could no longer log into SQL server nor restore any database. My only choice was to rebuild the master database. I performed the steps above and was able to connect to SQL server and perform my restores.If I had to rebuild the master database or worse uninstall SQL server and reinstall SQL server completely the restore time for the whole environment would have taken a lot longer.
Rebuild Completed
This process is not intended to replace your backups but to enhance it. Now that you can log into SQL server you can perform a restore of the master database. You must restore from backups to get all the latest information back into the master database.This process will not cure everything, but it is a faster way to rebuild your master database.
Hope you find this helpful,
Rudy
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.