Skip to content

Latest commit

 

History

History
147 lines (90 loc) · 9.98 KB

change-the-hadr-cluster-context-of-server-instance-sql-server.md

File metadata and controls

147 lines (90 loc) · 9.98 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords monikerRange
Change metadata: Cross-cluster availability group migration
When doing a cross-cluster migration, change which cluster manages the metadata for availability replicas within an Always On availability group by changing the HADR cluster context for an instance of SQL Server.
MashaMSFT
mathoma
05/17/2016
sql
availability-groups
how-to
Availability Groups [SQL Server], WSFC clusters
Availability replicas [SQL Server], change WSFC cluster context
>=sql-server-2016

Change which cluster manages the metadata for replicas in an Always On availability group

[!INCLUDEsql windows only]

This topic describes how to switch the HADR cluster context of an instance of [!INCLUDEssNoVersion] by using [!INCLUDEtsql] in [!INCLUDEssSQL11SP1] and later versions. The HADR cluster context determines which Windows Server Failover Clustering (WSFC) cluster manages the metadata for availability replicas hosted by the server instance.

Switch the HADR cluster context only during a cross-cluster migration of [!INCLUDEssHADR] to an instance of [!INCLUDEssSQL11SP1] on a new WSFC cluster. Cross-cluster migration of [!INCLUDEssHADR] supports OS upgrade to [!INCLUDEwin8] or [!INCLUDEwinserver2012] with minimal downtime of availability groups. For more information, see Cross-Cluster Migration of Always On Availability Groups for OS Upgrade.

Caution

Switch the HADR cluster context only during cross-cluster migration of [!INCLUDEssHADR] deployments.

Limitations and Restrictions

  • You can switch the HADR cluster context only from the local WSFC cluster to a remote cluster and then back from the remote cluster to the local cluster. You cannot switch the HADR cluster context from one remote cluster to another remote cluster.

  • The HADR cluster context can be switched to a remote cluster only when the instance of SQL Server is not hosting any availability replicas.

  • A remote HADR cluster context can be switched back to the local cluster at any time. However, the context cannot be switched again as long as the server instance is hosting any availability replicas.

Prerequisites

Recommendations

  • We recommend that you specify the full domain name. This is because to find the target IP address of a short name, ALTER SERVER CONFIGURATION uses DNS resolution. Under some situations, depending on the DNS searching order, using a short name could cause confusion. For example, consider the following command, which is executed on a node in the abc domain, (node1.abc.com). The intended destination cluster is the CLUS01 cluster in the xyz domain (clus01.xyz.com). However, the local domain hosts also hosts a cluster named CLUS01 (clus01.abc.com).

    If the short name of the target cluster, CLUS01, were specified, DNS name resolution could return the IP address of the wrong cluster, clus01.abc.com. To avoid such confusion, specify the full name of the target cluster, as in the following example:

    ALTER SERVER CONFIGURATION SET HADR CLUSTER CONTEXT = 'clus01.xyz.com'  
    

Permissions

  • SQL Server login

    Requires CONTROL SERVER permission.

  • SQL Server service account

    The [!INCLUDEssNoVersion] service account of the server instance must have:

    • Permission to open the destination WSFC cluster.

    • Remote WSFC read-write access.

Using Transact-SQL

To change the WSFC cluster context of an availability replica

  1. Connect to the server instance that hosts either the primary replica or a secondary replica of the availability group.

  2. Use the SET HADR CLUSTER CONTEXT clause of the ALTER SERVER CONFIGURATION statement, as follows:

    ALTER SERVER CONFIGURATION SET HADR CLUSTER CONTEXT = { 'windows_cluster' | LOCAL }

    where,

    windows_cluster
    The cluster object name (CON) of a WSFC cluster. You can specify either the short name or the full domain name. We recommend that you specify the full domain name. For more information, see Recommendations, earlier in this topic.

    LOCAL
    The local WSFC cluster.

Examples

The following example changes the HADR cluster context to a different cluster. To identify the destination WSFC cluster, clus01, the example specifies the full cluster object name, clus01.xyz.com.

ALTER SERVER CONFIGURATION SET HADR CLUSTER CONTEXT = 'clus01.xyz.com';  

The following example changes the HADR cluster context to the local WSFC cluster.

ALTER SERVER CONFIGURATION SET HADR CLUSTER CONTEXT = LOCAL;  

Follow Up: After Switching the Cluster Context of an Availability Replica

The new HADR cluster context takes effect immediately, without restarting the server instance. The HADR cluster context setting is a persistent instance-level setting that remains unchanged if the server instance restarts.

Confirm the new HADR cluster context by querying the sys.dm_hadr_cluster dynamic management view, as follows:

SELECT cluster_name FROM sys.dm_hadr_cluster  

This query should return the name of the cluster to which you set the HADR cluster context.

When the HADR cluster context is switched to a new cluster:

  • The metadata is cleaned up for any availability replicas that are currently hosted by the instance of [!INCLUDEssNoVersion].

  • All the databases that previously belonged to an availability replica are now in the RESTORING state.

Related Tasks

Related Content

See Also

Always On Availability Groups (SQL Server)
Windows Server Failover Clustering (WSFC) with SQL Server
ALTER SERVER CONFIGURATION (Transact-SQL)