Dela via


Database Mirroring Setup Overview

This section describes the general steps for setting up database mirroring. For an introduction to database mirroring, see Database Mirroring Overview.

Important

We recommend that you configure database mirroring during off-peak hours, because configuration can affect performance.

Setup Steps

To set up database mirroring, follow these steps:

  1. Make sure that logins exist on the mirror server for all the database users. For more information, see Setting Up Login Accounts for Database Mirroring.

  2. Before making a database available on another server instance, on the other server instance, you must set up the environment that is required to use the database on the new server instance. For more information, see Managing Metadata When Making a Database Available on Another Server Instance.

  3. Create the mirror database by restoring with NORECOVERY a recent full database backup of the principal database. Make sure that the principal database was already using the full recovery model when the backup was taken. The mirror database must have the same name as the principal database, and they cannot be renamed during a database mirroring session.

    Important

    You must restore all the log backups done since the full database backup. Before you can start mirroring on the partners, you should create a current log backup on the original database and restore it to the future mirror database.

    For more information, see How to: Prepare a Mirror Database for Mirroring (Transact-SQL). For information about how to create and restore log backups, see Working with Transaction Log Backups.

    Note

    Complete the remaining setup steps as soon as you can after taking the backup of the principal database.

  4. Set up security and start the database mirroring session.

    You can set up mirroring by using either Transact-SQL or the Database Mirroring Wizard. For more information, see one of the following:

    Note

    Database mirroring supports full-text catalogs. For more information, see Database Mirroring and Full-Text Catalogs.

  5. Optionally, add a witness to the session.

    You can add the witness by using either Transact-SQL or the Database Mirroring Wizard. For more information, see one of the following:

    Note

    The database owner can turn off the witness for a database at any time. Turning off the witness is equivalent to having no witness, and automatic failover cannot occur.

For a comprehensive example of using Transact-SQL to set up database mirroring using Microsoft Windows Authentication, see Example: Setting Up Database Mirroring Using Windows Authentication (Transact-SQL).

For a comprehensive example of using Transact-SQL to set up database mirroring using certificate-based security, see Example: Setting Up Database Mirroring Using Certificates (Transact-SQL).