<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gossip Corner &#187; SQL Database mirroing</title>
	<atom:link href="http://blog.shakeeluddin.com/tag/sql-database-mirroing/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.shakeeluddin.com</link>
	<description>Media, News, IT, Islam and lots more...</description>
	<lastBuildDate>Wed, 23 Feb 2011 11:43:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>SQL 2005 Database Mirroring with Failover Tutorial</title>
		<link>http://blog.shakeeluddin.com/sql-2005-database-mirroring-with-failover-tutorial/</link>
		<comments>http://blog.shakeeluddin.com/sql-2005-database-mirroring-with-failover-tutorial/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 13:26:01 +0000</pubDate>
		<dc:creator>Shakeel</dc:creator>
				<category><![CDATA[IT Discussion]]></category>
		<category><![CDATA[SQL Database mirroing]]></category>
		<category><![CDATA[SQL Failover]]></category>

		<guid isPermaLink="false">http://shakeelblog.wordpress.com/?p=173</guid>
		<description><![CDATA[Solution Using Certificates Authentication on Production Servers What you need is: 2 Servers and 1 Witness Create a database on Principal Server Backup the database 2 times: 1st time do a &#8220;FULL&#8221; backup, 2nd time do a &#8220;Transaction Log&#8221; backup Restore the database on Mirror Server, MUST use option &#8220;NO RECOVERY&#8221; !!! After restore, the mirror database will not [...]]]></description>
			<content:encoded><![CDATA[<h3>Solution Using Certificates Authentication on Production Servers</h3>
<h2><span style="text-decoration: underline;"></p>
<p></span></h2>
<p><strong>What you need is:</strong></p>
<p>2 Servers and 1 Witness</p>
<p>Create a database on Principal Server</p>
<p>Backup the database 2 times: 1st time do a &#8220;FULL&#8221; backup, 2nd time do a &#8220;Transaction Log&#8221; backup</p>
<p>Restore the database on Mirror Server, MUST use option &#8220;NO RECOVERY&#8221; !!! After restore, the mirror database will not take any request, that is completely normal.</p>
<p>Fully Qualified Domain Name for all 3 servers&#8230;..  you can do this by: 1. Setup a domain, or 2. Change the computer name and modify the &#8220;HOSTS&#8221; file on the 3 servers (<em>C:\WINDOWS\system32\drivers\etc</em>)</p>
<p>OK ! Now we shall start!</p>
<p><span style="color: #993300;"><span id="more-173"></span></span></p>
<p>HOST 1 = Principal Server</p>
<p>HOST 2 = Mirror Server</p>
<p>HOST 3 = Witness Server</p>
<p>You need to copy the certificate between the servers manually.</p>
<p>Here is the SQL code:</p>
<p><strong>HOST 1</strong></p>
<p>create master key encryption by password = &#8216;password&#8217;;<br />
GO</p>
<p>create certificate HOST_1_cert with subject = &#8216;HOST_1 certificate&#8217;, start_date = &#8217;2007/11/01&#8242;, expiry_date = &#8217;2099/11/01&#8242;;<br />
GO</p>
<p>Create endpoint endpoint_mirroring state = started<br />
as tcp(listener_port = 5022, listener_ip = all)<br />
for database_mirroring (authentication = certificate HOST_1_cert, encryption = disabled, role = all);<br />
GO</p>
<p>Backup certificate HOST_1_cert to file = &#8216;c:\HOST_1_cert.cer&#8217;;<br />
GO</p>
<p><strong>HOST 2</strong></p>
<p>create master key encryption by password = &#8216;password&#8217;;<br />
GO</p>
<p>create certificate HOST_2_cert with subject = &#8216;HOST_2 certificate&#8217;, start_date = &#8217;2007/11/01&#8242;, expiry_date = &#8217;2099/11/01&#8242;;<br />
GO</p>
<p>Create endpoint endpoint_mirroring state = started<br />
as tcp(listener_port = 7024, listener_ip = all)<br />
for database_mirroring (authentication = certificate HOST_2_cert, encryption = disabled, role = all);<br />
GO</p>
<p>Backup certificate HOST_2_cert to file = &#8216;c:\HOST_2_cert.cer&#8217;;<br />
GO</p>
<p><strong>HOST 3</strong></p>
<p>create master key encryption by password = &#8216;password&#8217;;<br />
GO</p>
<p>create certificate HOST_3_cert with subject = &#8216;HOST_3 certificate&#8217;, start_date = &#8217;2007/11/01&#8242;, expiry_date = &#8217;2099/11/01&#8242;;<br />
GO</p>
<p>Create endpoint endpoint_mirroring state = started<br />
as tcp(listener_port = 5022, listener_ip = all)<br />
for database_mirroring (authentication = certificate HOST_3_cert, encryption = disabled, role = witness);<br />
GO</p>
<p>Backup certificate HOST_W_cert to file = &#8216;c:\HOST_3_cert.cer&#8217;;<br />
GO</p>
<p><strong>Now Copy 3 Certificates on all Servers</strong>.</p>
<p><strong>HOST 1 again</strong></p>
<p>create login HOST_2_login with PASSWORD = &#8216;password&#8217;;<br />
GO</p>
<p>create user HOST_2_user from login HOST_2_login;<br />
GO</p>
<p>Create certificate HOST_2_cert<br />
Authorization HOST_2_user<br />
From file = &#8216;c:\HOST_2_cert.cer&#8217;;<br />
GO</p>
<p>Grant CONNECT ON Endpoint::endpoint_mirroring to [HOST_2_login];<br />
GO<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>create login HOST_3_login with PASSWORD = &#8216;password&#8217;;<br />
GO</p>
<p>create user HOST_3_user from login HOST_3_login;<br />
GO</p>
<p>Create certificate HOST_3_cert<br />
Authorization HOST_3_user<br />
From file = &#8216;c:\HOST_3_cert.cer&#8217;;<br />
GO</p>
<p>Grant CONNECT ON Endpoint::endpoint_mirroring to [HOST_3_login];<br />
GO</p>
<p><strong>HOST 2 again</strong><strong></strong></p>
<p>create login HOST_1_login with PASSWORD = &#8216;password&#8217;;<br />
GO</p>
<p>create user HOST_1_user from login HOST_1_login;<br />
GO</p>
<p>Create certificate HOST_1_cert<br />
Authorization HOST_1_user<br />
From file = &#8216;c:\HOST_1_cert.cer&#8217;;<br />
GO</p>
<p>Grant CONNECT ON Endpoint::Endpoint_mirroring to [HOST_1_login];<br />
GO</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<p>create login HOST_3_login with PASSWORD = &#8216;password&#8217;;<br />
GO</p>
<p>create user HOST_3_user from login HOST_3_login;<br />
GO</p>
<p>Create certificate HOST_3_cert<br />
Authorization HOST_3_user<br />
From file = &#8216;c:\HOST_3_cert.cer&#8217;;<br />
GO</p>
<p>Grant CONNECT ON Endpoint::Endpoint_mirroring to [HOST_3_login];<br />
GO</p>
<p><strong> </strong><strong>HOST 3 again</strong></p>
<p>create login HOST_1_login with PASSWORD = &#8216;password&#8217;;<br />
GO</p>
<p>create user HOST_1_user from login HOST_A1_login;<br />
GO</p>
<p>Create certificate HOST_1_cert<br />
Authorization HOST_1_user<br />
From file = &#8216;c:\HOST_1_cert.cer&#8217;;<br />
GO</p>
<p>Grant CONNECT ON Endpoint::Endpoint_mirroring to [HOST_1_login];<br />
GO</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>create login HOST_2_login with PASSWORD = &#8216;password&#8217;;<br />
GO</p>
<p>create user HOST_2_user from login HOST_B2_login;<br />
GO</p>
<p>Create certificate HOST_2_cert<br />
Authorization HOST_2_user<br />
From file = &#8216;c:\HOST_2_cert.cer&#8217;;<br />
GO</p>
<p>Grant CONNECT ON Endpoint::endpoint_mirroring to [HOST_2_login];<br />
GO</p>
<p><strong>HOST B again</strong></p>
<p>alter database yourdbname set partner = &#8216;TCP://hostname.ace.local:5022&#8242;;<br />
GO</p>
<p><strong>HOST A again</strong></p>
<p>alter database yourdbname set partner = &#8216;TCP://hostname.ace.local:5022&#8242;;<br />
GO</p>
<p>alter database yourdbname set witness = &#8216;TCP://hostname.ace.local:5022&#8242;;<br />
GO</p>
<p>We implemented it successfully on production servers.</p>
<p><strong>If someone facing any problem write it down !!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.shakeeluddin.com/sql-2005-database-mirroring-with-failover-tutorial/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

