configuring sql2005 db mirroring on localmachine

Upload: akash-raj81

Post on 05-Apr-2018

234 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    1/41

    How To Configure Database Mirrioring In Local System

    Without Domain

    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 controlleron 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

  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    2/41

    Now I am going to implement Database Mirroring on Adventure-works database.

    SQL_2005_ONE As Principal Server

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot117.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot1161.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot117.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot1161.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    3/41

    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.

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot075.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot074.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot075.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot074.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    4/41

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot077.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot076.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot077.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot076.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    5/41

    Perform Immediate Log backup ..

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot079.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot078.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot079.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot078.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    6/41

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot0801.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    7/41

    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

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot082.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot081.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot082.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot081.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    8/41

  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    9/41

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot119.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    10/41

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot120.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    11/41

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot121.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    12/41

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot084.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot122.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot084.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot122.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    13/41

    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

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot086.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot085.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot086.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot085.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    14/41

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot123.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    15/41

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot124.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    16/41

    After restoring log backup file ,database would be restoring mode

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot1251.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    17/41

    We are ready to start configuring database mirroring

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot0861.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    18/41

    Click on Configure Security

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot089.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot088.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot089.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot088.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    19/41

    Database Mirroring Configuration wizard will open

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot091.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot090.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot091.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot090.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    20/41

    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

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot092.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    21/41

    Here we are going to configure Principal server

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot093.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    22/41

    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

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot094.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    23/41

    Next step is configuring Witness Instance

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot095.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    24/41

    We are going to configure service accounts in mirroring

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot096.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    25/41

    We are using all local system accounts in same machine ,so we can ignore this window

    We have reached final window for configuring Mirroring

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot097.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    26/41

    Final window showing that configuring endpoints with default values

    All should be success

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot098.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    27/41

    After successful configuration ,You will get Start mirroring

    window

    I have selected Start Mirroring.But as usual got error message

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot100.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot099.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot100.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot099.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    28/41

    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

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot126.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot101.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot126.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot101.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    29/41

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot1281.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot1271.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot1281.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot1271.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    30/41

    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

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot130.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot129.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot130.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot129.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    31/41

    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 didnt 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 !!

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot131.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    32/41

    You can observe that server names having Mydomain.com and SQL Server treating that as FullyQualified 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

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot1321.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    33/41

    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

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot103.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    34/41

    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

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot105.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot104.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot105.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot104.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    35/41

    Second Method

    Database Properties >>Mirroring>>Failover

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot133.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot107.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot133.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot107.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    36/41

    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

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot1341.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    37/41

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot108.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    38/41

    After registration we can see Principal,Mirror server Synchronization Status

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot1091.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    39/41

    History Tab will show more details

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot110.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    40/41

    If require we can configure Warning Thresholds

    http://sqlphilomath.files.wordpress.com/2011/07/screenshot112.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot111.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot112.jpghttp://sqlphilomath.files.wordpress.com/2011/07/screenshot111.jpg
  • 7/31/2019 Configuring SQL2005 DB Mirroring on Localmachine

    41/41

    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)