Sql-server – SQL Server 2014: Graceful shutdown of an Availability Group node

availability-groupssql server

What I'm trying to do is to gracefully shut down one of two nodes in our SQL Server Availiability Group, effectively draining all the connections.

Previously, we were just stopping the SQL Server instance on the node, but that results in a flurry of "The specified network name is no longer available" errors from client applications.

What is the kosher way of shutting down a node?

I'm no DBA here, so please, ask whatever questions you deem necessary.

Best Answer

You should failover to one of the other nodes first, before shutting down SQL.

This can be done either in SQL Management Studio (under the Always On High Availability node in the Object Explorer tree), or alternatively using the Windows Server Failover Cluster Manager program, which will be available in the Start Menu of all the Windows servers hosting the SQL instances.

Using SSMS is considered the better approach, as the WSFC utility won't know the synchronisation state of the other replicas.

To do a failover via TSQL instead, connect to the node you want to failover to (not from), and execute this, once for each listener group you have:

T-SQL : ALTER AVAILABILITY GROUP My_Group_Name FAILOVER;

In PowerShell you have this option: Switch-SqlAvailabilityGroup

(Source for code samples)