You are on page 1of 7

Mirroring Configuration Steps

1. Download the Mirroring on SQL SERVER 2008.rar from the Installation


and Patch directory.
2. Start the mirroring process only after all branches completed their
dayends.
3. Take Both Primary and backup machine on teamviewer.
4. Go to C:\Windows\System32\drivers\etc and edit host file. Add IP
address and Machine name of both primary and backup machine in the
host file of both the computer. Change IPs to LAN of live location when
servers goes to live location.

5. Check if protocol for names pipes for sqlserver network configuration.


It should be enabled.
6. Check the sql services Sql Server Browser should be started and set
to auto started.
7. Run Surface configuration script on both the server. Script is given

below.
8. First create SQLCert folder in D drive.
9. Run the script1 on Principal server
10.Run the script1 on Mirror server.
11.Copy the HOST_PRIN_cert.cer file from d:\SQLCert\ folder from
Principal server and paste into D:\SQLCert \ folder in Mirror server.
12.Copy the HOST_MIRR_cert.cer file from d:\SQLCert\ folder from Mirror
server and paste into D:\SQLCert \ folder in Principal server.
13. Run the script2 on Principal server.
14.Run the script2 on Mirror server.
15.Change the database recovery model properties to Full
16.Change database name in script 3 of principal server script and Run
the script3 on Principal server.
17.Copy the database bak and trn file from D:\SQLCert\ folder and paste
into D:\SQLCert\ folder in Mirror server.
18.Change database name in script 3 of mirror server script and Run the
script3 on Mirror server.
19.Change IP address to Primary server machine name and Now first run
the script4 on Mirror server.
20.Change IP address to backup server machine name and Run the script4
on Principal server.
21.If everything is completed successfully then on Principal Server
Database will show (Principal, Synchronized) and on mirror server
database will show (Mirror, Synchronized/Restoring)
22.Change

Steps for restoring the Database again on the


Principal Server after mirroring is started
1. On Principal server run the following query: ALTER DATABASE [uprampur ]SET PARTNER of
2. On Principal server right click on principal machine live database go to

properties options Restricted Users change it to single user from


multi user
3. Now restore the database with overwrite option
4. After restoring the database change the restricted user back to multi
user in the option
5. Change the database recovery model properties to Full
6. Change database name in script 3 of principal server script and Run
the script3 on Principal server.
7. Copy the database bak and trn file from D:\SQLCert\ folder and paste
into D:\SQLCert\ folder in Mirror server.
8. Run the following query on the Backup machine where mirroring is
happening.
a. ALTER DATABASE [up-rampur] SET PARTNER of
b. --restore database rampur with recovery
9. Delete the database
10.Change database name in script 3 of mirror server script and Run the
script3 on Mirror server.
11.Change IP address to Primary server machine name and Now first run
the script4 on Mirror server.
12.Change IP address to backup server machine name and Run the script4
on Principal server.
13.If everything is completed successfully then on Principal Server
Database will show (Principal, Synchronized) and on mirror server
database will show (Mirror, Synchronized/Restoring)

IN FAILOVER CASE
When your principal server is not available or not working the run the below
script on Mirror server after this process your mirror is working as Principal
server.

--ALTER DATABASE BIRGANJ SET PARTNER


FORCE_SERVICE_ALLOW_DATA_LOSS
--GO

Run the below script on Principal server, then your failure server work as
Mirror server.

--ALTER DATABASE rampur SET PARTNER RESUME


--GO

How to Test Synchronization


1. On Principal Synchronized server go to database which is mirrored and
open the table called ac_head_m. Go to first row and go to oldglcode
column and change the name to test. Press enter to save the data.
2. Now on principal server and right click on mirror database and click on
properties. Now click on mirroring . Now click on failover to make the
principal server to mirror server and mirror server to principal server.
3. Now go to mirror server which will now be showing that database as
Principal/Synchronized. Now open the table called ac_head_m. Go to
first row and go to oldglcode column and check if test is there. If test
is there then synchronized is working on mirror server. Now change the
oldglcode value back to earlier one NULL (if null)
4. Now on mirror server, which is now showing the as
Principal/Synchronized and right click on mirror database and click on
properties. Now click on mirroring . Now click on failover to make the
principal server to mirror server and mirror server to principal server.
5. Now go to principal server which will now be showing that database as
Principal/Synchronized. Now open the table called ac_head_m. Go to
first row and go to oldglcode column and check if Null is there. If null
is there then synchronized is working on mirror server.

If you want to Start over again then these script first


then starts from the beginning (Step 1):
drop ENDPOINT Mirroring
GO
drop CERTIFICATE HOST_PRIN_cert
go
drop CERTIFICATE HOST_MIRR_cert

go
drop LOGIN HOST_prin_login
GO
drop USER HOST_PRIN_user
GO
drop LOGIN HOST_mirr_login
GO
drop USER HOST_mirr_user
GO
drop MASTER KEY
GO

How to delete the in recovery mirror database


--ALTER DATABASE rampur SET PARTNER of
--restore database rampur with recovery

Surface Configuration Query


-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO
EXECUTE SP_CONFIGURE 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
EXECUTE SP_CONFIGURE 'xp_cmdshell', '1'
RECONFIGURE WITH OVERRIDE

GO
EXECUTE SP_CONFIGURE 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
GO

If you have to change the instance name to default


sql server name
sp_helpserver
select @@servername
So in order to get the network name and the SQL Server instance name back
in sync I had do these steps:
Run this in Microsoft SQL Server Management Studio:
sp_dropserver 'old_name'
go
sp_addserver 'new_name','local'
go
Restart SQL Server service. I prefer the command prompt for this, but you
can just as easily do it in Services under the Control Panel
net stop mssqlserver
net start mssqlserver
Then after that is done run this again, to make sure everything is changed:
sp_helpserver
select @@servername
If it gives error: Msg 1418, Level 16, State 1, Line 1
The server network address "TCP://<<your mirror server name here>>:5023"
can not be reached or does not exist. Check the network address name and
that the ports for the local and remote endpoints are operational.
Solution:
I hope you have replace the <<your mirror server name here>> by the
actual Mirror Server Name.
If you have, please check the following:
1. Both server names are added to host file
2. Name pipe is enabled
3. Make sure that the TCP EndPoint is Started on the Mirror Server.
(SELECT * FROM sys.tcp_endpoints)
4. It is possible that host certificate got expired. Try dropping everything
and do everything from step 1.
4. Make sure that SQL Server is listening on the EndPoints. You might
want to look at the SQL Server Errorlog to ensure that SQL Server is
actually listening on this EndPoint.

5. The SQL Server Browser Service is running on the Mirror Server.


6. The UDP Port 1434 and TCP Port 5023 is opened on the Firewall.

You might also like