Home > SQL Server Tips > Database Administration > Database mirroring setup in SQL Server 2005
SQL Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DATABASE ADMINISTRATION

Database mirroring setup in SQL Server 2005


Greg Robidoux, Edgewood Solutions LLC
07.13.2006
Rating: -4.31- (out of 5)


Expert advice on database administration
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


One of many new features in SQL Server 2005, database mirroring allows you to automatically mirror database contents from one SQL Server database to another. It also offers failover capabilities, which may be made automatic depending on how you configure mirroring. The mirrored copy is a standby copy that can not be accessed directly. It is used only for failover situations. With SQL Server 2005 Enterprise Edition you can also use database snapshots with the mirror, but we will cover that another time.

The following table of contents will help you navigate this tip.

[TABLE]

[TABLE]

You need a minimum of two different SQL Server instances for database mirroring to work. The primary instance is the "principal." The secondary instance is the "mirror." The principal is your live database and the mirror is your standby copy of the database. As transactions are written to your principal database they are sent to your mirrored database and written there as well.

In addition to the principal and the mirror, another optional component called the "witness" can be introduced. The witness is a third instance of SQL Server 2005 that acts as an intermediary between the principal and the mirror to determine when to failover. This option is only used when you want to run an automatic failover. It creates the ability to have a 2-to-1 vote that says one of my components is not available and therefore I am going to failover. The witness server is only needed when you want to implement automated failover.

Follow this link for a SQL Server 2005 database mirroring primer.

[TABLE]

Database mirroring offers three modes of implementation. The choice you select depends on how you want to handle failover processing.

[TABLE]

Once you have selected instances and the mode to use, a few other requirements must be met. You must have SQL Server 2005 Standard, Enterprise or Developer editions plus SQL Server 2005 Service Pack 1


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
SQL Server Backup and Recovery
The keys to database backup protection for SQL Server
Choosing a SQL Server disaster recovery solution
Licensing a standby server for SQL Server replication
Can I encrypt and restore a database backup in SQL Server 2005?
SQL Server errors, failures and other problems fixed from the trenches
Get SQL Server log shipping functionality without Enterprise Edition
SQL Server 2008 backup compression pros and cons
SQL Server backups using SAN database snapshots
Tips for scheduling and testing SQL Server backups
Code to restore SQL Server databases in VB.NET
SQL Server Backup and Recovery Research

Microsoft SQL Server 2005 (Yukon)
SQL Server Reporting Services Fast Guide
SQL Server Service Broker Tutorial and Reference Guide
Tips for tuning SQL Server 2005 to improve reporting performance
SQL Server consolidation: Why it's an optimization technique
Parent-child dimensions in SQL Server 2005 with Analysis Services MDX
Enforcing data integrity in a SQL Server database
SSIS error message due to installation problem on SQL Server 2005
Should you upgrade to SQL Server 2005 or SQL Server 2008?
Basics for working with DATETIME and SMALLDATETIME in SQL Server 2005
How to configure Database Mail in SQL Server 2005 to send mail
Microsoft SQL Server 2005 (Yukon) Research

Database Administration
Performance implications of transaction log autogrowth in SQL Server
The keys to database backup protection for SQL Server
Understanding transparent data encryption in SQL Server 2008
Working with sparse columns in SQL Server 2008
Determining the source of full transaction logs in SQL Server
Implementing SQL Server 2008 FILESTREAM functionality
Improving SQL Server full-text search performance
Using the OPENROWSET function in SQL Server
New replication features in SQL Server 2008 and what they mean to you
Choosing a SQL Server disaster recovery solution

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
rollback  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


to run the principal and the mirror. Prior to SP1, database mirroring could be set up using a trace flag, but it was not supported by Microsoft. For the witness, other versions of SQL Server 2005 can be used.

Database mirroring setup via SQL Server Management Studio

As with most things in SQL Server, you have the option to use GUI tools and an option to use T-SQL commands. For this tip I will focus on setup using SQL Server Management Studio.

To get started select the database and instances for the principal, mirror and the witness, if you are going to use one. Again these only need to be unique instances, so they can all be on the same physical server. For testing and development this makes sense, but for your production environment the whole idea of mirroring is to use physically different servers; if there is a problem with your primary server you can fail over to a secondary server. Let's begin the setup:

[TABLE]

At this time SQL Server 2005 Database Mirroring should be all configured and ready to go. Create some transactions on your principal database, refresh the mirror status to see if the data is synchronized and then fail over to see if the process actually works.

A couple of things to keep in mind: The only thing mirrored is the database, so any other component -- such as logins, SQL Server Integration Services (SSIS) packages, SQL Agent Jobs, etc -- are not automatically mirrored. These items need to be handled outside the process. But overall you can see it is pretty easy to set up database mirroring. Take the time to configure a test server to see if this new feature is something you can take advantage of in SQL Server 2005.

About the author: Greg Robidoux is the president and founder of Edgewood Solutions LLC, a technology services company delivering professional services and product solutions for Microsoft SQL Server. He has authored numerous articles and has delivered presentations at regional SQL Server users' groups and national SQL Server events. Robidoux, who also serves as the SearchSQLServer.com Backup and Recovery expert, welcomes your questions.

Rate this Tip
To rate tips, you must be a member of SearchSQLServer.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SQL Server Development - .NET, C#, T-SQL, Visual Basic
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts