Thursday, July 19, 2012

Database Mirroring Step-by-Step (Lync 2013)

First is: by stand of today, SQL Server Clustering is NOT SUPPORTED.
MSFT makes a clear statement, you can still use SQL Server Clustering for Lync 2013, but with the Preview Version you should test is carefully.

Why not working directly with Database Mirroring?
It is some more the PowerShell you need to configure this feature.
In another blog I describe the setup of the Lync 2013 TestLab, generally I have configured two SQL Server for the Enterprise Pool, SQL01 and SQL02.
In the Topology i have defined SQL01 as the Primary and SQL02 as the Mirror for Database handling.
After the EE is installed, whereby the Database where created, I need to make the Mirroring Feature happen.

First you need to create a DatabaseFileShare for DB Replication. You can to this on a Witness server or like I did, I have chosen a Domain Controller (just for the LAB).

NOTE:
Make sure you have the proper permission for this share set, else you run into some issues.
The proper settings are:
SQL01 Server and SQL01 Server Service Account need: Read and Write Permission
SQL02 Server and SQL02 Server Service Account need: Read Permission

Now you are ready to do Mirroring.

You need the Install-CsMirrorDatabase command.
In our case her:
Install-CsMirrorDatabase -ConfiguredDatabases -FileShare \\dc01-lync15\sqlshare -SqlServerFqdn lync15sql01.lync15.dir


Lync will now show you the summary of Configured Databases, which you need to confirm for mirroring.
The output will like this:
Install Mirror Database
This cmdlet sets up mirroring for databases on primary SQL Server instance on
the mirror SQL Server instance. If a witness is specified, it also sets up a
witness for databases on the primary SQL Server instance.
The following databases will be mirrored and configured with a witness if a
witness is specified:
    Database Name:rtcxds
        Data File:C:\CsData\BackendStore\(default)\DbPath\rtcxds.mdf
        Log File:C:\CsData\BackendStore\(default)\LogPath\rtcxds.ldf
      Primary SQL: LYNC15SQL01.LYNC15.DIR
          Account: LYNC15\sql
       Mirror SQL: LYNC15SQL02.LYNC15.DIR
          Account: LYNC15\sql
    Database Name:rtcshared
        Data File:C:\CsData\BackendStore\(default)\DbPath\rtcshared.mdf
         Log File:C:\CsData\BackendStore\(default)\LogPath\rtcshared.ldf
      Primary SQL: LYNC15SQL01.LYNC15.DIR
          Account: LYNC15\sql
       Mirror SQL: LYNC15SQL02.LYNC15.DIR
          Account: LYNC15\sql
    Database Name:rtcab
        Data File:C:\CsData\ABSStore\(default)\DbPath\rtcab.mdf
         Log File:C:\CsData\ABSStore\(default)\LogPath\rtcab.ldf
      Primary SQL: LYNC15SQL01.LYNC15.DIR
          Account: LYNC15\sql
       Mirror SQL: LYNC15SQL02.LYNC15.DIR
          Account: LYNC15\sql
    Database Name:rgsconfig
        Data File:C:\CsData\ApplicationStore\(default)\DbPath\rgsconfig.mdf
         Log File:C:\CsData\ApplicationStore\(default)\LogPath\rgsconfig.ldf
      Primary SQL: LYNC15SQL01.LYNC15.DIR
          Account: LYNC15\sql
       Mirror SQL: LYNC15SQL02.LYNC15.DIR
          Account: LYNC15\sql
    Database Name:rgsdyn
        Data File:C:\CsData\ApplicationStore\(default)\DbPath\rgsdyn.mdf
         Log File:C:\CsData\ApplicationStore\(default)\LogPath\rgsdyn.ldf
      Primary SQL: LYNC15SQL01.LYNC15.DIR
          Account: LYNC15\sql
       Mirror SQL: LYNC15SQL02.LYNC15.DIR
          Account: LYNC15\sql 
    Database Name:cpsdyn
        Data File:C:\CsData\ApplicationStore\(default)\DbPath\cpsdyn.mdf
         Log File:C:\CsData\ApplicationStore\(default)\LogPath\cpsdyn.ldf
      Primary SQL: LYNC15SQL01.LYNC15.DIR
          Account: LYNC15\sql
       Mirror SQL: LYNC15SQL02.LYNC15.DIR
          Account: LYNC15\sql
    Database Name:xds
        Data File:C:\CsData\CentralMgmtStore\(default)\DbPath\xds.mdf
         Log File:C:\CsData\CentralMgmtStore\(default)\LogPath\xds.ldf
      Primary SQL: LYNC15SQL01.LYNC15.DIR
          Account: LYNC15\sql
       Mirror SQL: LYNC15SQL02.LYNC15.DIR
          Account: LYNC15\sql
    Database Name:lis
        Data File:C:\CsData\CentralMgmtStore\(default)\DbPath\lis.mdf
         Log File:C:\CsData\CentralMgmtStore\(default)\LogPath\lis.ldf
      Primary SQL: LYNC15SQL01.LYNC15.DIR
          Account: LYNC15\sql
       Mirror SQL: LYNC15SQL02.LYNC15.DIR
          Account: LYNC15\sql

 Verify that the following things are taken care of before proceeding:
 Port 5022 is accessible through the firewall if Windows Firewall is enabled
 in the primary SQL Server LYNC15SQL01.LYNC15.DIR.
 Port 5022 is accessible through the firewall if Windows Firewall is enabled
 in the mirror SQL Server LYNC15SQL02.LYNC15.DIR.
 Accounts running the SQL Servers on all primary and mirror SQL servers have
 read/write permissions to the file share \\dc01-lync15\sqlshare
The cmdlet will use WMI provider to find the account information for SQL
Server services running on all primary, mirror and witness servers. Verify that
 WMI provider is running on all these servers.
The cmdlet will try to create folders for data and log files for all the
mirror servers. Verify that the account running this cmdlet has permission to
create these folders.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help
(default is "Y"):A
From here onwards you will see the SQL Server actions,
Lync will first EXPORT the Databases into the FileShare, as you will see in the following screenshot 


than it's time for for Lync to run the SQL Script setting up the Mirrored Relationship between both Server.
We see here that SQL02 will first gain the knowledge about the Database which should be in the Mirror relationship and start than the "Database Copying" process.

SQL01 show's immediately the Primary Database Ownership and it's sync'ed already.

If you verify the settings in for the Database Properties under Mirror, you see the information configured during the Topology Build definition. The SQL Witness can be seen here too. It is important NOT to CHANGE any information here, since Lync need to have the configuration in is Topology Database.

After a while, when you start the Mirroring Monitor Application on the SQL Server, you see it's in-sync and working fine.

TIP:
You should learn much more about SQL Server than you did for Lync 2010 !!!


At the end of our lesson, we check the Sync Status via Lync too.
Thefore we need to run the PowerShell command:
Get-CsDatabaseMirrorState -PoolFqdn poolleft.lync15.dir



Summary:
Remember the commands....

Install-CsMirrorDatabase (here are plenty of parameter)
Uninstall-CsMirrorDatabase
Get-CsDatabaseMirrorState


2 comments:

  1. Is this possible the Lync 2013 Standard or is Enterprise required?

    ReplyDelete
    Replies
    1. Lync Standard Edition cannot utilize any other SQL Server than the integrated SQL Express version. Even if someone would be able changing this, it would not be supported.
      So database mirroring is only supported with Enterprise Edition (Frontend Server, Persistent Chat)

      Delete