You are on page 1of 6

11/1/21, 12:48 PM MSSQL Database Mirroring Configuration | InfraPCS

InfraPCS
Something about IT Infrastructure and Life

MSSQL Database Mirroring Configuration


There are several ways to perform MSSQL database replication, including log shipping, database mirroring and
AlwaysOn Availability Groups. It is highly recommended to adopt AlwaysOn Availability Groups whenever it is
possible, however, sometime we still need to use database mirroring due to the environment limitation.

This post is to outline the steps to configure the MSSQL database mirroring. The example topology is as below:

Step-1:  On Principle SQL server S1, perform the backup of database “source01” with both full and trans-
action log backup. Copy the backup files to the Mirror SQL server.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here:
Cookie Policy

Close and accept

https://ranchh.wordpress.com/2018/12/20/mssql-database-mirroring-configuration/ 1/6
11/1/21, 12:48 PM MSSQL Database Mirroring Configuration | InfraPCS

Step-2:
 On Mirror SQL server S2, do NOT CREATE source01 database before restoration. Right click
“databases”and select “restore database”,perform the full and transaction log restoration of the database
“source01” with option “RESTORE WITH NORECOVERY”. It is noted that, after the restoration, the database
status should be “restoring…..”

Step-3: On Principle SQL server S1, right click the database “source01” and select “properties” and “mirror-
ing”. Then click “Configure Security”

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here:
Cookie Policy

Close and accept

https://ranchh.wordpress.com/2018/12/20/mssql-database-mirroring-configuration/ 2/6
11/1/21, 12:48 PM MSSQL Database Mirroring Configuration | InfraPCS

Step-4: Follow the Configure Security wizard, choose “NO” in witness configuration. (If witness server is re-
quired, select “YES” and provides witness server details.)

Step-5: Provide the details of the principle server instance details

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here:
Cookie Policy

Close and accept

https://ranchh.wordpress.com/2018/12/20/mssql-database-mirroring-configuration/ 3/6
11/1/21, 12:48 PM MSSQL Database Mirroring Configuration | InfraPCS

Step-6: Provide the details of the mirror server instance details

Step-7: Provide the Domain service account to configure the database mirroring.

Step-8:  After the security configuration is setup, select “Start Mirroring” to establish the database mirror-
ing. The database mirroring should be setup after this step.

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here:
Cookie Policy

Close and accept

https://ranchh.wordpress.com/2018/12/20/mssql-database-mirroring-configuration/ 4/6
11/1/21, 12:48 PM MSSQL Database Mirroring Configuration | InfraPCS

I have found that SQL Server Management Studio version 17 has a known issue to start the database mirroring
session. The error message is similar like below:

“Database xxxx cannot be opened. It is in the middle of a restore.”

In this case, below command lines can be used to setup database mirroring:

Command Step-1: On Mirror SQL Server (S2 in our example), execute below SQL commands:

ALTER DATABASE source01  

    SET PARTNER = 'TCP://S1.XXXXXX.COM:5022' 

GO

Command Step-2: On Principle SQL Server (S1 in our example), execute below SQL commands:

ALTER DATABASE source01  

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
    SET PARTNER = 'TCP://S2.XXXXX.COM:5022' 

To find out more, including how to control cookies, see here:


Cookie Policy
GO

Close and accept

https://ranchh.wordpress.com/2018/12/20/mssql-database-mirroring-configuration/ 5/6
11/1/21, 12:48 PM MSSQL Database Mirroring Configuration | InfraPCS

This entry was posted in Database and tagged Database, mirroring, MSSQL on December 20, 2018
[https://ranchh.wordpress.com/2018/12/20/mssql-database-mirroring-configuration/] .

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here:
Cookie Policy

Close and accept

https://ranchh.wordpress.com/2018/12/20/mssql-database-mirroring-configuration/ 6/6

You might also like