Today we are going to learn few Tips which are not documented in BOL.The reason i am writing this post is , Most of the learners may not have enough knowledge to build domain controller on virtual machines and failing to become familiar with High availability techniques like Database Mirroring.
As per BOL Mirroring require Fallowing prerequisites
1.Servers should be in same domain
2.SQL service accounts should be same domain accounts
All above points remain same ,treat as a best practice but there are situations, demands us to configure Mirroring in non-domain environment.
Here we start..
Pre implementation
1.We need Three SQL Server instances.
I have installed three SQL Server 2005 (ENT Evolution Edition) instances and applied sp3.
Tip: Mirroring introduced in SQL 2005, Only Enterprise and Developer Edition will support Database Mirroring
Mirroring functionality enabled from sp1 ,if you are using SQL 2005 RTM then you have to enable trace flag 1400.
2.All Instances are running on local machine ,using localsystem service account for SQL services.
3.All required protocols enabled for each instance.
Please have a look After completing above steps
Now I am going to implement Database Mirroring on Adventure-works database.
SQL_2005_ONE As Principal Server
SQL_2005_TWO As Mirror server
SQL_2005_THREE As Witness Server
First Make sure that Adventureworks database is in Full recovery Model (It is must).
Now we need to take full backup of this database.
Perform Immediate Log backup ..
We have completed database full and log backup successfully.These backup files has to be restored on SQL_TWO_2005 Instance
Tip :We have to restore as same database name that is AdventureWorks.
Below are steps
Tip :Make sure to change restore location of files And Restore with NORECOVERY option
After above step we can able to see Adventureworks Database in Restoring mode
I am going to restore log backup file
After restoring log backup file ,database would be restoring mode
We are ready to start configuring database mirroring
Click on Configure Security
Database Mirroring Configuration wizard will open
I am going to configure Automatic fail-over (High availability mode),we need witness server for this
I am choosing “Yes” here in above step
Below Step is self explanatory
Here we are going to configure Principal server
Here Listener Port is 5022 (you can change it)
Endpoint, i am leaving it for wizard to configure with default values
Next step is configuring Mirror Instance
Next step is configuring Witness Instance
We are going to configure service accounts in mirroring
We are using all local system accounts in same machine ,so we can ignore this window
We have reached final window for configuring Mirroring
Final window showing that configuring endpoints with default values
All should be success
After successful configuration ,You will get Start mirroring
window
I have selected Start Mirroring.But as usual got error message
SQL Server identified that we are not in Domain and giving error to start Mirroring secession
Now we have to troubleshoot this failure ,No wonder we are not in domain
Is that mean we cannot configure mirroring ? No
Here is the workaround to resolve this
I had verified Mycomputer properties
As we aware we are not in domain and Mycomputer is a member of WORKGROUP
Click on More Tab,You will get below window
I have empty box for Primary DNS suffix
I had enter Mydomain.com (you can choose your desired domain name fallowed by .com)
Click ok for all opened windows ,System will ask for Reboot.
After Rebooting the system ,verify your system name using cmd
Hmm !,My System name is remain same ,so no need to bother about SQL instances registration.
No need to bother about sp_dropserver and sp_addserver.
(You can ignore above step if you didn’t understand )
Let us start Mirror setup again
We have to do form the first step to start mirror window step
This time Mirrioring Started successfully !!
You can observe that server names having Mydomain.com and SQL Server treating that as Fully Qualified Domain Name.
We have configured Mirroring successfully in local machine with out domain
Now let me show you Some Interesting Things that are part of Mirroring
Our Principal and Mirror Databases showing their respective Role names in Managemenstudio
Now let me show you Automatic fail-over feature of mirroring
I had stopped Principal server service in configuration manager to simulate the failure of principle server
Now let us verify Mirrored Database status
Please observe SQL_TWO_2005 was a Mirror Database, Now Became Principal automatically. This is a great feature of Mirroring (and latency also very less) as per Microsoft.
We can do this Fail over in different ways
First method using below command
Second Method
Database Properties >>Mirroring>>Failover
Now We will learn how to Monitor Mirroring Performance
The name implies the answer,Yes i am going to use Mirroring monitor
You will get mirroring monitor with empty records .Here we have to register principal or mirror server name
After registration we can see Principal,Mirror server Synchronization Status
History Tab will show more details
If require we can configure Warning Thresholds
As of now we have done Mirror configuration and monitoring.
This will be helpful to practice and getting familiar with New feature of SQL server 2005 (Same steps applicable for SQL 2008 also)
There are multiple ways to configure mirroring in local machine or different domain environment (using certificates is the one method)
But i am sure this is the simplest method among those.
Looking for your feedback to improve this blog
I will post more tips in future to simplify your SQL administration Learning
All The Best Friends.