Thursday, April 28, 2016

Database Mirroring in Lync 2013

Back End Server high availability in Skype for Business Server 2015
Database mirroring in Lync is important feature for redundancy in Lync infrastructure.
Lync Server 2013/S4B 2015 SQL mirroring is a process that provides resiliency in the back-end Lync infrastructure in case one of the SQL Server nodes goes offline for any reason.
Skype for Business Server supports mirroring with the following database software:
  • SQL Server 2014, both Enterprise Edition and Standard Edition
  • SQL Server 2012 SP2 and CU2, both Enterprise Edition and Standard Edition
  • SQL Server 2008 R2 SP2, both Enterprise Edition and Standard Edition
It requires two SQL servers, One Is primary and other contains same database as the first one and it acts as a mirror. So in case one of the server or service goes offline, primary database will be failover to mirror server.
The deployment can be with witness server or witness server, however, if you want failover to be automatic without any administration effort, Witness server have to be deployed.

Configuration in Topology builder

For this configuration, you need to configure Topology Builder as follows

Failover in Database Mirroring

In case of maintenance, you need to manually switchover primary to mirror and then perform maintenance on primary server. You can use following command to manually failover database.
Invoke-CsDatabaseFailover -PoolFqdn <poolFQDN> -DatabaseType User -NewPrincipal mirror -Verbose
Use above command when you are failing over to the mirror.
After maintenance, you need to switch over back to primary from mirror state. Use following command you are failing over to the primary.
Invoke-CsDatabaseFailover -PoolFqdn <poolFQDN> -DatabaseType User -NewPrincipal mirror -Verbose
In order to check location of primary and secondary database on SQL server node and its mirroring state of database, use get-csdatabasemirrorstate command in Lync management shell on one of the Front end server.
Before failing over and after failover, you can determine which back-end database is the principal and which is the mirror by typing the following cmdlet:
Get-CsDatabaseMirrorState -PoolFqdn <poolFQDN> -DatabaseType User
In normal scenario, all your databases should have a principle state on a primary server.
As you can see in above screenshot, rtcab database have StateOnPrimary is principle and StateOnMirror is Mirror.When you do failover from primary to mirror, this should change as follows
So in case of rtcab database, now StateonPrimary is Mirror and StateOnMirror is Principle.

User Experience in failover:


For automatic Back End failover with database mirroring, the engineering target for recovery time objective (RTO) is 5 minutes.
Because of the synchronous database mirroring, there is no data loss during Back End Server failures except in rare occasions when both the Front End Servers and the Back End Server go down simultaneously while data is being moved between the servers.
If you use database mirroring and have a witness configured, and the principal fails, Back End Server failover happens automatically and quickly. Active users should not notice much interruption to their ongoing sessions.
If one server is already down, databases are failover to mirror and mirror server is down too, then User will continue their session to maximum of 30 mins.
If primary is still not restored, user will be switched to resiliency mode, in this scenario they will not be able to perform any task that need persistent change on database. (like adding contact, scheduling new meeting).


Conclusion

So overall, SQL mirroring in Lync infra is very critical and helpful feature for Lync infrastructure redundancy with less administrative efforts.