Skip to content

Commit cca3bf0

Browse files
committed
staged workgroup ag article
1 parent e363968 commit cca3bf0

File tree

9 files changed

+310
-0
lines changed

9 files changed

+310
-0
lines changed

articles/virtual-machines/windows/sql/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
href: virtual-machines-windows-sql-availability-group-quickstart-template.md
9898
- name: Multiple regions
9999
href: virtual-machines-windows-portal-sql-availability-group-dr.md
100+
- name: Domain-independent (workgroup)
101+
href: virtual-machines-windows-sql-workgroup-availability-group.md
100102
- name: Configure manually
101103
items:
102104
- name: Prerequisites
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Lines changed: 308 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,308 @@
1+
---
2+
title: Configure a domain-independent workgroup availability group
3+
description: Learn how to configure an Active Directory Domain-independent workgroup Always On availability group on a SQL Server virtual machine in Azure.
4+
services: virtual-machines-windows
5+
documentationcenter: na
6+
author: MashaMSFT
7+
editor: ''
8+
tags: azure-service-management
9+
10+
ms.assetid: 53981f7e-8370-4979-b26a-93a5988d905f
11+
ms.service: virtual-machines-sql
12+
13+
ms.topic: article
14+
ms.tgt_pltfrm: vm-windows-sql-server
15+
ms.workload: iaas-sql-server
16+
ms.date: 01/29/2020
17+
ms.author: mathoma
18+
19+
---
20+
# Configure a workgroup availability group
21+
22+
This article explains the steps necessary to create an Active Directory Domain-independent cluster with an Always On availability group; this is also known as a workgroup cluster. This article focuses on the steps that are relevant to preparing and configuring the workgroup and availability group, and glosses over steps that are covered in other articles, such as how to create the cluster, or deploy the availability group.
23+
24+
25+
## Prerequisites
26+
27+
To configure a workgroup availability group, you need the following:
28+
- At least two Windows Server 2016 (or higher) virtual machines running SQL Server 2016 (or higher), deployed to the same availability set, or different availability zones, using static IP addresses.
29+
- A local network with a minimum of 4 free IP addresses on the subnet.
30+
- An account on each machine in the administrator group that also has sysadmin rights within SQL Server.
31+
- Open ports: TCP 1433, TCP 5022, TCP 59999.
32+
33+
For reference, the following parameters are used in this article:
34+
35+
| **Name** | **Parameter** |
36+
| :------ | :---------------------------------- |
37+
| **Node1** | AGNode1 (10.0.0.4) |
38+
| **Node2** | AGNode2 (10.0.0.5) |
39+
| **Cluster name** | AGWGAG (10.0.0.6) |
40+
| **Listener** | AGListener (10.0.0.7) |
41+
| **User account** | SQLAGADMIN|
42+
| **DNS Suffix** | ag.wgcluster.example.com |
43+
| **Work group name** | AGWorkgroup |
44+
|   |   |
45+
46+
## 1 - Set DNS suffix
47+
48+
In this step, configure the DNS suffix for both servers. For example, `ag.wgcluster.example.com`. This allows you to use the name of the object you want to connect to as a fully qualified address within your network, such as `AGNode1.ag.wgcluster.example.com`.
49+
50+
To configure the DNS suffix, follow these steps:
51+
52+
1. RDP into your first node and open Server Manager.
53+
1. Select **Local Server** and then select the name of your virtual machine under **Computer name**.
54+
1. Select **Change...** under **To rename this computer...**.
55+
1. Change the name of the workgroup name to be something meaningful, such as `AGWORKGROUP`:
56+
57+
![Change workgroup name](media/virtual-machines-windows-sql-workgroup-availability-group/1-change-workgroup-name.png)
58+
59+
1. Select **More...** to open the **DNS Suffix and NetBIOS Computer Name** dialog box.
60+
1. Type the name of your DNS suffix under **Primary DNS suffix of this computer**, such as `ag.wgcluster.example.com` and then select **OK**:
61+
62+
![Add DNS suffix](media/virtual-machines-windows-sql-workgroup-availability-group/2-add-dns-suffix.png)
63+
64+
1. Confirm that the **Full computer name** is now showing the DNS suffix, and then select **OK** to save your changes:
65+
66+
![Add DNS suffix](media/virtual-machines-windows-sql-workgroup-availability-group/3-confirm-full-computer-name.png)
67+
68+
1. Reboot the server when you are prompted to do so.
69+
1. Repeat these steps on any other nodes to be used for the availability group.
70+
71+
## 2 - Edit host file
72+
73+
Since there is no active directory, there is no way to authenticate windows connections. As such, assign trust by editing the host file with a text editor.
74+
75+
To edit the host file, follow these steps:
76+
77+
1. RDP into your virtual machine.
78+
1. Use **File Explorer** to go to `c:\windows\system32\drivers\etc`.
79+
1. Right-click the **hosts** file and open the file with **Notepad** (or any other text editor).
80+
1. At the end of the file, add an entry for each node, the availability group, and the listener in the form of `IP Address, DNS Suffix #comment` like:
81+
82+
```
83+
10.0.0.4 AGNode1.ag.wgcluster.example.com #Availability group node
84+
10.0.0.5 AGNode2.ag.wgcluster.example.com #Availability group node
85+
10.0.0.6 AGWGAG.ag.wgcluster.example.com #Cluster IP
86+
10.0.0.7 AGListener.ag.wgcluster.example.com #Listener IP
87+
```
88+
89+
![Add entries for the IP address, cluster, and listener to the host file](media/virtual-machines-windows-sql-workgroup-availability-group/4-host-file.png)
90+
91+
## 3 - Set permissions
92+
93+
Since there is no Active Directory to manage permissions, you need to manually allow a non-builtin local administrator account to create the cluster.
94+
95+
To do so, run the following PowerShell cmdlet in an administrative PowerShell session on every node:
96+
97+
```PowerShell
98+
99+
new-itemproperty -path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name LocalAccountTokenFilterPolicy -Value 1
100+
```
101+
102+
## 4 - Create the failover cluster
103+
104+
In this step, you will create the failover cluster. If you're unfamiliar with these steps, you can follow them from the [failover cluster tutorial](virtual-machines-windows-portal-sql-create-failover-cluster.md#step-2-configure-the-windows-server-failover-cluster-with-storage-spaces-direct).
105+
106+
Notable differences between the tutorial and what should be done for a workgroup cluster:
107+
- Uncheck **Storage Spaces Direct** when running the cluster validation.
108+
- When adding the nodes to the cluster, add the fully qualified name, such as:
109+
- `AGNode1.ag.wgcluster.example.com`
110+
- `AGNode2.ag.wgcluster.example.com`
111+
- Uncheck **Add all eligible storage to the cluster**.
112+
113+
Once the cluster has been created, assign a static Cluster IP address. To do so, follow these steps:
114+
115+
1. On one of the nodes, open **Failover Cluster Manager**, select the cluster, right-click on the **Name: \<ClusterNam>** under **Cluster Core Resources** and then select **Properties**.
116+
117+
![Launch properties for the cluster name](media/virtual-machines-windows-sql-workgroup-availability-group/5-launch-cluster-name-properties.png)
118+
119+
1. Select the IP address under **IP Addresses** and select **Edit**.
120+
1. Select **Use Static**, provide the IP address of the cluster, and then select **OK**:
121+
122+
![Provide a static IP address for the cluster](media/virtual-machines-windows-sql-workgroup-availability-group/6-provide-static-ip-for-cluster.png)
123+
124+
1. Verify that your settings look correct, and then select **OK** to save them:
125+
126+
![Verify cluster properties](media/virtual-machines-windows-sql-workgroup-availability-group/7-verify-cluster-properties.png)
127+
128+
## 5 - Create a cloud witness
129+
130+
In this step, configure a cloud share witness. If you're unfamiliar with the steps, see the [failover cluster tutorial](virtual-machines-windows-portal-sql-create-failover-cluster.md#create-a-cloud-witness).
131+
132+
## 6 - Enable availability group feature
133+
134+
In this step, enable the availability group feature. If you're unfamiliar with the steps, see the [availability group tutorial](virtual-machines-windows-portal-sql-availability-group-tutorial.md#enable-availability-groups).
135+
136+
## 7 - Create keys and certificate
137+
138+
In this step, create certificates that a SQL login uses on the encrypted endpoint. Create a folder on each node to hold the certificate backups, such as `c:\certs`.
139+
140+
To configure the first node, follow these steps:
141+
142+
1. Open **SQL Server Management Studio** and connect to your first node, such as `AGNode1`.
143+
1. Open a **New Query** window and run the following Transact-SQL (T-SQL) statement after updating to a complex and secure password:
144+
145+
```sql
146+
USE master;
147+
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'PassWOrd123!';
148+
GO
149+
150+
--create a cert from the master key
151+
USE master;
152+
CREATE CERTIFICATE AGNode1Cert
153+
WITH SUBJECT = 'AGNode1 Certificate';
154+
GO
155+
156+
--Backup the cert and transfer it to AGNode2
157+
BACKUP CERTIFICATE AGNode1Cert TO FILE = 'C:\certs\AGNode1Cert.crt';
158+
GO
159+
```
160+
161+
1. Next, create the HADR endpoint, and use the certificate for authentication by running this Transact-SQL statement:
162+
163+
```sql
164+
--CREATE or ALTER the mirroring endpoint
165+
CREATE ENDPOINT hadr_endpoint
166+
STATE = STARTED
167+
AS TCP (
168+
LISTENER_PORT=5022
169+
, LISTENER_IP = ALL
170+
)
171+
FOR DATABASE_MIRRORING (
172+
AUTHENTICATION = CERTIFICATE AGNode1Cert
173+
, ENCRYPTION = REQUIRED ALGORITHM AES
174+
, ROLE = ALL
175+
);
176+
GO
177+
```
178+
179+
1. Use **File Explorer** to go to the file location where your certificate is, such as `c:\certs`.
180+
1. Manually make a copy of the certificate, such as `AGNode1Cert.crt`, from the first node, and transfer it to the same location on the second node.
181+
182+
To configure the second node, follow these steps:
183+
184+
1. Connect to the second node with **SQL Server Management Studio**, such as `AGNode2`.
185+
1. In a **New Query** window, run the following Transact-SQL (T-SQL) statement after updating to a complex and secure password:
186+
187+
```sql
188+
USE master;
189+
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'PassWOrd123!';
190+
GO
191+
192+
--create a cert from the master key
193+
USE master;
194+
CREATE CERTIFICATE AGNode2Cert
195+
WITH SUBJECT = 'AGNode2 Certificate';
196+
GO
197+
--Backup the cert and transfer it to AGNode1
198+
BACKUP CERTIFICATE AGNode2Cert TO FILE = 'C:\certs\AGNode2Cert.crt';
199+
GO
200+
```
201+
202+
1. Next, create the HADR endpoint, and use the certificate for authentication by running this Transact-SQL statement:
203+
204+
```sql
205+
--CREATE or ALTER the mirroring endpoint
206+
CREATE ENDPOINT hadr_endpoint
207+
STATE = STARTED
208+
AS TCP (
209+
LISTENER_PORT=5022
210+
, LISTENER_IP = ALL
211+
)
212+
FOR DATABASE_MIRRORING (
213+
AUTHENTICATION = CERTIFICATE AGNode2Cert
214+
, ENCRYPTION = REQUIRED ALGORITHM AES
215+
, ROLE = ALL
216+
);
217+
GO
218+
```
219+
220+
1. Use **File Explorer** to go to the file location where your certificate is, such as `c:\certs`.
221+
1. Manually make a copy of the certificate, such as `AGNode2Cert.crt`, from the second node, and transfer it to the same location on the first node.
222+
223+
If there are any other nodes in the cluster, repeat these steps there also, modifying the respective certificate names.
224+
225+
## 8 - Create logins
226+
227+
Certificate authentication is used to synchronize data across nodes. To allow this, create a login for the other node, create a user for the login, create a certificate for the login to use the backed-up certificate, and then grant connect on the mirroring endpoint.
228+
229+
To do so, first run the following Transact-SQL (T-SQL) query on the first node, such as `AGNode1`:
230+
231+
```sql
232+
--create a login for the AGNode2
233+
USE master;
234+
CREATE LOGIN AGNode2_Login WITH PASSWORD = 'PassWord123!';
235+
GO
236+
237+
--create a user from the login
238+
CREATE USER AGNode2_User FOR LOGIN AGNode2_Login;
239+
GO
240+
241+
--create a certificate that the login uses for authentication
242+
CREATE CERTIFICATE AGNode2Cert
243+
AUTHORIZATION AGNode2_User
244+
FROM FILE = 'C:\certs\AGNode2Cert.crt'
245+
GO
246+
247+
--grant connect for login
248+
GRANT CONNECT ON ENDPOINT::hadr_endpoint TO [AGNode2_login];
249+
GO
250+
```
251+
252+
Next, run the following Transact-SQL (T-SQL) query on the second node, such as `AGNode2`:
253+
254+
```sql
255+
--create a login for the AGNode1
256+
USE master;
257+
CREATE LOGIN AGNode1_Login WITH PASSWORD = 'PassWord123!';
258+
GO
259+
260+
--create a user from the login
261+
CREATE USER AGNode1_User FOR LOGIN AGNode1_Login;
262+
GO
263+
264+
--create a certificate that the login uses for authentication
265+
CREATE CERTIFICATE AGNode1Cert
266+
AUTHORIZATION AGNode1_User
267+
FROM FILE = 'C:\certs\AGNode1Cert.crt'
268+
GO
269+
270+
--grant connect for login
271+
GRANT CONNECT ON ENDPOINT::hadr_endpoint TO [AGNode1_login];
272+
GO
273+
```
274+
275+
If there are any other nodes in the cluster, repeat these steps there also, modifying the respective certificate and user names.
276+
277+
## 9 - Configure availability group
278+
279+
In this step, configure your availability group, and add your databases to it. Do not create a listener at this time. If you're not familiar with the steps, see the [availability group tutorial](virtual-machines-windows-portal-sql-availability-group-tutorial.md#create-the-availability-group). Be sure to initiate a failover and failback to verify that everything is working as it should be.
280+
281+
> [!NOTE]
282+
> If there is a failure during the synchronization process, you may need to grant `NT AUTHORITY\SYSTEM` sysadmin rights to create cluster resources on the first node, such as `AGNode1` temporarily.
283+
284+
## 10 - Configure load balancer
285+
286+
In this final step, configure the load balancer using either the [Azure portal](virtual-machines-windows-portal-sql-alwayson-int-listener.md) or [PowerShell](virtual-machines-windows-portal-sql-ps-alwayson-int-listener.md)
287+
288+
## 11 - Configure health probe
289+
290+
In this step, configure the health probe on both nodes with a single PowerShell command:
291+
292+
```PowerShell
293+
# Define variables
294+
$ClusterNetworkName = "Cluster Network 1" # the cluster network name (Use Get-ClusterNetwork on Windows Server 2012 of higher to find the name)
295+
296+
$IPResourceName = "AGListenerIP_10.0.0.7"# the IP Address resource name
297+
298+
$ILBIP = “10.0.0.7” # the IP Address of the Internal Load Balancer (ILB)/Listener
299+
300+
Import-Module FailoverClusters
301+
302+
Get-ClusterResource $IPResourceName | Set-ClusterParameter -Multiple @{"Address"="$ILBIP";"ProbePort"="59999";"SubnetMask"="255.255.255.255";"Network"="$ClusterNetworkName";"EnableDhcp"=0}
303+
```
304+
305+
### Other resources
306+
* [Configure an availability group with Az SQL VM CLI](virtual-machines-windows-sql-availability-group-cli.md)
307+
308+

0 commit comments

Comments
 (0)