qua_cluster_set_name#

Changes the cluster name of a two-node cluster, which its metabase stores - the DNS name clients connect to the cluster by - and returns one row with the old and the new name. Each node reports the new name from its next start.

Syntax#

qua_cluster_set_name
    [ @cluster_name = ] 'cluster_name'
    [ , [ @dry_run = ] dry_run ] [;]

Arguments#

[ @cluster_name = ] ‘cluster_name’

The new cluster name, up to 253 characters. Required. It follows the rules of the @cluster_name argument of qua_cluster_provision: a DNS name of letters, digits and hyphens, not an IP address, not localhost or a name in its domain, and naming neither node’s computer - the computer names the nodes are bound to and the DNS name of the computer the procedure runs on. Give it exactly as clients dial it and as both nodes’ certificates carry it.

[ @dry_run = ] dry_run

1 checks the name and reports what the procedure would do, and changes nothing. Optional; the default is 0.

Result set#

Column

Type

Description

cluster_id

uniqueidentifier

The identifier of the cluster.

stored_cluster_name

nvarchar(253)

The name the metabase stored before the call; empty for a cluster provisioned before the cluster name existed.

new_cluster_name

nvarchar(253)

The name the metabase stores after the call, or would store in a dry run.

is_changed

bit

1 when the new name differs from the stored one; a change of case is a change.

is_dry_run

bit

1 when nothing was changed because @dry_run = 1.

After a change the procedure also sends a message that each node reports the name from its next start, and writes a Cluster: line with the old and new name into the log of the instance it runs on.

Remarks#

Each instance reads the cluster name when it starts. Until it restarts, @@SERVERNAME, the server name properties of SERVERPROPERTY, sys.servers and the server column of the job history keep reporting the first part of the old name, so the two instances report different names until both have restarted. Restart the standby first, move the serving role to it with qua_cluster_failover, then restart the other instance: a clean shutdown of the serving instance does not hand the role over in the manual failover mode, so restarting it first leaves the cluster without a serving instance until it is back. Renaming a SQL Server failover cluster instance works the same way: the new network name is reported once the SQL Server resource has been restarted, and the instance itself keeps its identity.

Before you restart the instances, make the name reachable and trusted:

  • create the new name in DNS with the address of each node;

  • give both nodes’ certificates the new name as a subject alternative name - an instance in cluster mode checks its certificate against the stored name when it starts;

  • register the service principal names for the new name for the account the instances run under.

Then run qua_cluster_preflight on the serving instance: it checks the stored name, the certificate and the service principal names. The standby has no client port; each instance runs the same checks when it starts and writes their findings into its log, so read the standby’s log after its restart. Clients, linked servers and job steps that name the old name must be changed to the new one.

An instance whose stored cluster name breaks these rules - a cluster provisioned as localhost or under a node’s computer name before they were checked - starts and logs a warning that points to this procedure, and qua_cluster_preflight fails its addressing.stored-cluster-name check for a loopback name or one that is no DNS name.

Run the procedure on the instance that serves the cluster; an instance in cluster mode that does not serve refuses a change but not a dry run, which only reads. The standby has no client port, so in practice both run on the serving instance. Before the first instance is restarted in cluster mode, the procedure also runs there, outside cluster mode. It is refused when the metabase carries no cluster or more than one. A name equal to the stored one changes nothing.

The change is stored when the procedure ends, outside any transaction the session has open, so a ROLLBACK does not undo it. Do not run the procedure while qua_cluster_provision runs or while the cluster is reset.

Permissions#

Requires the CONTROL SERVER permission.

Example#

Checks the name db-cluster.contoso.com for a cluster that was provisioned under the name of one of its nodes, then stores it.

EXEC qua_cluster_set_name @cluster_name = N'db-cluster.contoso.com', @dry_run = 1;
EXEC qua_cluster_set_name @cluster_name = N'db-cluster.contoso.com';

See Also#