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

DATABASE ADMINISTRATOR

Database mirroring witness in SQL Server 2005


Greg Robidoux, Edgewood Solutions
02.07.2007
Rating: -3.00- (out of 5)


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


SQL Server 2005's database mirroring feature offers new functionality that allows you to configure database failover much easier than in the past. In a previous tip, Database mirroring setup in SQL Server 2005, I walked you through the steps to set up database mirroring as well as explained how it works.

When configuring database mirroring, one option is to use the High Availability mode. This option allows for synchronizing of transaction writes on both servers, as well as offers the ability of automated failover. When using the High Availability mode, you need to have three instances of SQL Server: the principal, mirror and the witness. Here is a summary of what each component does.

  • Principal – this is the instance that stores the active database.
  • Mirror – this is the instance that receives transactions to keep the mirrored database in sync.
  • Witness – this is the instance that communicates with the principal and mirror to determine if failover should occur.

What is the role of the witness server?
The witness is a third instance of SQL Server 2005 that acts as an intermediary between the principal and the mirror in order to determine when to fail over. By having a third instance, it creates the ability to have a 2–1 vote that says one of my components is not available and therefore I am going to fail over. Because of the need to determine if the components are online or offline before an automatic failover, the witness server is only needed when you implement the High Availability mode and you want, or need, automatic failover. This instance doesn't do much more than communicate with the principal and the mirror to make sure they are still alive. No database activity is occurring on this instance, just communication between the three components.

Where should the witness be?
This really depends on your network configuration and the reliability of your components. If you implement this over a WAN and have periodic network glitches by having the witness near the principal, then you can eliminate some unnecessary failovers. In addition, if your primary data center has some issues and you want to ensure your database stays online, it may make sense to keep this with the mirror. Therefore, if there are any issues in your primary data center, your mirror and witness can communicate and take over the job.

Physical location is not the only point of concern when placing your witness. It would also make sense to install the witness on a different physical server. It is possible to create three instances on one server and set up database mirroring. But, if you are trying to eliminate hardware failure as a possible cause of downtime, the witness should be installed on a different piece of hardware.

If you are trying to eliminate data center outages, it makes sense to have your mirror in a different physical location. Based on this assumption, you should keep the witness and the principal in the same data center and your mirror in a different location.

What version of SQL Server 2005 for the witness?
The witness server can run on any version of SQL Server 2005, including the Express edition. The principal and mirror can only run on the Standard, Enterprise and Developer editions of SQL Server 2005.

What kind of server does the witness run on?
You can install the witness on any hardware and operating system that supports the version of SQL Server 2005 you are using for the witness. Because of the nature and role of the witness, I suggest using hardware that you feel is reliable and will not cause further complications when implementing and utilizing database mirroring.

What happens if the witness fails?
Because the witness is just one of the three components, if it fails, it does not necessarily mean that a failover will occur. As long as the principal and mirror can still communicate with each other, there is no need for a failover. Therefore the failure of just the witness will not trigger an automated failover.

How does failover work?
Since three components make up the High Availability mode, two of these components need to determine that a problem has occurred and then initiate a failover. If the principal server fails and the witness and mirror can still communicate, the failover process will kick in. The mirror will become the principal and the witness will continue to perform its duties as the witness server.

Summary
Implementing the High Availability mode of database mirroring is pretty straightforward by just implementing another instance of SQL Server to act as the witness. Although from that perspective it is fairly easy, you should implement database mirroring in different phases until you get the hang of how it works and when it will kick in. Using the High Protection mode as the first implementation probably makes more sense than jumping right into the High Availability mode. Either way, though, take the time to test this new component of SQL Server 2005 before you take the leap into using it as part of your production failover strategy.


More on SearchSQLServer.com

  • Tip: SQL Server bulk-logged recovery
  • Learning Guide: SQL Server Backup and Recovery Learning Guide
  • Best of: Top 10 SQL Server backup and recovery tips

  • 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.
    Copyright 2007 TechTarget

    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.




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


    RELATED CONTENT
    SQL Server backup and recovery
    SQL Server backups using SAN database snapshots
    Tips for scheduling and testing SQL Server backups
    Code to restore SQL Server databases in VB.NET
    Tricking SQL Server into making full database backups
    SAN considerations for your SQL Server environment
    Top 7 SQL Server backup and restore tips of 2007
    Retrieve deleted tables in SQL Server
    SQL Server backup and restore commands to limit downtime
    Mirrored backup and restore commands in SQL Server 2005
    Set up a SQL Server disaster recovery site
    SQL Server backup and recovery Research

    SQL Server availability
    Monitor database mirroring and replication after a SQL Server upgrade
    Upgrade live applications to SQL Server 2005 for high availability
    SQL Server high availability when upgrading to SQL Server 2005
    Tutorial: Migrating to SANs from local SQL Server disk storage
    How to restore SQL Server database to transition server during upgrade
    SQL Server memory configurations for procedure cache and buffer cache
    Upgrade Active/Active cluster to SQL Server 2005 and Windows 2003
    SQL Server backups using SAN database snapshots
    Tips for moving from SQL Server local disk storage to SANs
    How to process SQL Server 2005 Analysis Services for data availability
    SQL Server availability Research

    SQL Server 2005 (Yukon)
    SQL Server data conversions from date/time values to character types
    Basics for working with DATETIME and SMALLDATETIME in SQL Server 2005
    How to configure Database Mail in SQL Server 2005 to send mail
    How to use rank function in SQL Server 2005
    Manage traces in SQL Server 2005 Analysis Services with XMLA commands
    Tutorial: SQL Server 2005 Analysis Services
    Create a computed column in SQL Server using XML data
    Open SSIS packages without validation using these SQL properties
    Using the OUTPUT clause for practical SQL Server applications
    Create DDL table in SQL Server 2005 to audit DDL trigger activity
    SQL Server 2005 (Yukon) Research

    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

    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.

    HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    SEARCH 
    TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




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