0% found this document useful (0 votes)
374 views

Tutorial Mirroring

This 3-sentence summary provides the essential information about setting up database mirroring between 2 SQL servers using certificates: The tutorial explains how to create certificates on the principal, mirror, and witness servers; backup and import the certificates between the servers; set up endpoints and grant access; and restore the database on the mirror server with NO RECOVERY to complete the mirroring configuration using certificates for authentication instead of Windows authentication. Common errors encountered during mirroring setup are also discussed, along with their solutions.

Uploaded by

bima
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
374 views

Tutorial Mirroring

This 3-sentence summary provides the essential information about setting up database mirroring between 2 SQL servers using certificates: The tutorial explains how to create certificates on the principal, mirror, and witness servers; backup and import the certificates between the servers; set up endpoints and grant access; and restore the database on the mirror server with NO RECOVERY to complete the mirroring configuration using certificates for authentication instead of Windows authentication. Common errors encountered during mirroring setup are also discussed, along with their solutions.

Uploaded by

bima
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL 2005 Database Mirroring Tutorial Page 1 of 3

Type to search the Web

Home

Lotus Show SQL 2005 Database Mirroring Tutorial


EF 100 Macro
Introduction
Talk about success
This tutorial is for people who are really really frustrated.
How to test camera
One of my project need to use mirroring to replicate data between 2 database servers. I look for help online
Good Words and found some useful websites. However, when I follow the instructions, some error messages stop me.....
Photos
Most likely, you would get this error message:
My Ferrari Error: 1418 - Microsoft SQL Server - The server network address can not be reached or does not exist.
Check the network address name and reissue the command. The server network endpoint did not
Flash Exploded respond because the specified server network address cannot be reached or does not exist.
Dirt Colin McRae
That error message dosen't tell you the truth.... there is nothing to do with "can not be reached or does not
SQL 2005 Database Mirroring Tutorial exist".
There are 2 possible causes:
Glory Road [movie] - You forgot to use "NO RECOVERY" when restoring database on the MIRROR server
- NT Authentication fail.... some unknow reason... a lot of people reported this problem
Electric Car
When you view the SQL Server Log, you would see some error message like :
Error: 1474, Severity: 16, State: 1

Database mirroring connection error 4 'An error occurred while receiving data: '10054(An existing
connection was forcibly closed by the remote host.)'.' for 'TCP://mymirror.mydomain:5022'

or

Error: 1443, Severity: 16, State: 2

or

Database Mirroring login attempt by user 'NT AUTHORITY\ANONYMOUS LOGON.' failed with error:
'Connection handshake failed. The login 'NT AUTHORITY\ANONYMOUS LOGON' does not have
CONNECT permission on the endpoint. State 84.

Well, if you are having the above error messages, I hope this tutorial could help you.

Solution: Using Certificates


Forget about Windows Authentication or Domain Account..... just use Certificates is good enough.

What you need is:


- 2 Servers and 1 Witness
- Create a database on Principal Server
- Backup the database 2 times: 1st time do a "FULL" backup, 2nd time do a "Transaction Log" backup
- Restore the database on Mirror Server, MUST use option "NO RECOVERY" !!! After restore, the mirror
database will not take any request, that is completely normal.
- Fully Qualified Domain Name for all 3 servers..... you can do this by: 1. Setup a domain, or 2. Change the
computer name and modify the "HOSTS" and "NETWORKS" files on the 3 servers (C:\WINDOWS\system32
\drivers\etc) [if you use the 2nd way, when you change the computer name, press "More..." to input the DNS
suffix]

OK ! Now we shall start!

HOST A = Principal Server


HOST B = Mirror Server
HOST W = Witness Server

You need to copy the certificate between the servers manually.

Here is the SQL code:

-- HOST A
create master key encryption by password = 'abc123!!';
GO

create certificate HOST_A_cert with subject = 'HOST_A certificate', start_date = '2007/11/01', expiry_date =
'2020/11/01';

http://alan328.com/SQL2005_Database_Mirroring_Tutorial.aspx 25/02/2008
SQL 2005 Database Mirroring Tutorial Page 2 of 3

GO

Create endpoint endpoint_mirroring state = started


as tcp(listener_port = 7024, listener_ip = all)
for database_mirroring (authentication = certificate HOST_A_cert, encryption = disabled, role = all);
GO

Backup certificate HOST_A_cert to file = 'd:\HOST_A_cert.cer';


GO

-- HOST B
create master key encryption by password = 'abc123!!';
GO

create certificate HOST_B_cert with subject = 'HOST_B certificate', start_date = '2007/11/01', expiry_date =
'2020/11/01';
GO

Create endpoint endpoint_mirroring state = started


as tcp(listener_port = 7024, listener_ip = all)
for database_mirroring (authentication = certificate HOST_B_cert, encryption = disabled, role = all);
GO

Backup certificate HOST_B_cert to file = 'd:\HOST_B_cert.cer';


GO

-- HOST W
create master key encryption by password = 'abc123!!';
GO

create certificate HOST_W_cert with subject = 'HOST_W certificate', start_date = '2007/11/01', expiry_date
= '2020/11/01';
GO

Create endpoint endpoint_mirroring state = started


as tcp(listener_port = 7024, listener_ip = all)
for database_mirroring (authentication = certificate HOST_W_cert, encryption = disabled, role = witness);
GO

Backup certificate HOST_W_cert to file = 'd:\HOST_W_cert.cer';


GO

-- HOST A again
create login HOST_B_login with PASSWORD = 'abc123!!';
GO

create user HOST_B_user from login HOST_B_login;


GO

Create certificate HOST_B_cert


Authorization HOST_B_user
From file = 'D:\HOST_B_cert.cer';
GO

Grant CONNECT ON Endpoint::endpoint_mirroring to [HOST_B_login];


GO
------
create login HOST_W_login with PASSWORD = 'abc123!!';
GO

create user HOST_W_user from login HOST_W_login;


GO

Create certificate HOST_W_cert


Authorization HOST_W_user
From file = 'D:\HOST_W_cert.cer';
GO

Grant CONNECT ON Endpoint::endpoint_mirroring to [HOST_W_login];


GO

-- HOST B again
create login HOST_A_login with PASSWORD = 'abc123!!';
GO

create user HOST_A_user from login HOST_A_login;


GO

Create certificate HOST_A_cert


Authorization HOST_A_user

http://alan328.com/SQL2005_Database_Mirroring_Tutorial.aspx 25/02/2008
SQL 2005 Database Mirroring Tutorial Page 3 of 3

From file = 'D:\HOST_A_cert.cer';


GO

Grant CONNECT ON Endpoint::Endpoint_mirroring to [HOST_A_login];


GO

-------
create login HOST_W_login with PASSWORD = 'abc123!!';
GO

create user HOST_W_user from login HOST_W_login;


GO

Create certificate HOST_W_cert


Authorization HOST_W_user
From file = 'D:\HOST_W_cert.cer';
GO

Grant CONNECT ON Endpoint::Endpoint_mirroring to [HOST_W_login];


GO

-- HOST W again
create login HOST_A_login with PASSWORD = 'abc123!!';
GO

create user HOST_A_user from login HOST_A_login;


GO

Create certificate HOST_A_cert


Authorization HOST_A_user
From file = 'D:\HOST_A_cert.cer';
GO

Grant CONNECT ON Endpoint::Endpoint_mirroring to [HOST_A_login];


GO

-------
create login HOST_B_login with PASSWORD = 'abc123!!';
GO

create user HOST_B_user from login HOST_B_login;


GO

Create certificate HOST_B_cert


Authorization HOST_B_user
From file = 'D:\HOST_B_cert.cer';
GO

Grant CONNECT ON Endpoint::endpoint_mirroring to [HOST_B_login];


GO

-- HOST B again
alter database good set partner = 'TCP://server1.ace.local:7024';
GO

-- HOST A again
alter database good set partner = 'TCP://server2.ace.local:7024';
GO

alter database good set witness = 'TCP://mc.ace.local:7024';


GO

Now, everything is fine!

Hope you enjoy it!

Alan - [email protected]

Home|Contact Us|About Us|Site Map

http://alan328.com/SQL2005_Database_Mirroring_Tutorial.aspx 25/02/2008

You might also like