|
| 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, but can be modified as is necessary: |
| 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 | +| **DNS Suffix** | ag.wgcluster.example.com | |
| 42 | +| **Work group name** | AGWorkgroup | |
| 43 | +| | | |
| 44 | + |
| 45 | +## Set DNS suffix |
| 46 | + |
| 47 | +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`. |
| 48 | + |
| 49 | +To configure the DNS suffix, follow these steps: |
| 50 | + |
| 51 | +1. RDP into your first node and open Server Manager. |
| 52 | +1. Select **Local Server** and then select the name of your virtual machine under **Computer name**. |
| 53 | +1. Select **Change...** under **To rename this computer...**. |
| 54 | +1. Change the name of the workgroup name to be something meaningful, such as `AGWORKGROUP`: |
| 55 | + |
| 56 | +  |
| 57 | + |
| 58 | +1. Select **More...** to open the **DNS Suffix and NetBIOS Computer Name** dialog box. |
| 59 | +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**: |
| 60 | + |
| 61 | +  |
| 62 | + |
| 63 | +1. Confirm that the **Full computer name** is now showing the DNS suffix, and then select **OK** to save your changes: |
| 64 | + |
| 65 | +  |
| 66 | + |
| 67 | +1. Reboot the server when you are prompted to do so. |
| 68 | +1. Repeat these steps on any other nodes to be used for the availability group. |
| 69 | + |
| 70 | +## Edit host file |
| 71 | + |
| 72 | +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. |
| 73 | + |
| 74 | +To edit the host file, follow these steps: |
| 75 | + |
| 76 | +1. RDP into your virtual machine. |
| 77 | +1. Use **File Explorer** to go to `c:\windows\system32\drivers\etc`. |
| 78 | +1. Right-click the **hosts** file and open the file with **Notepad** (or any other text editor). |
| 79 | +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: |
| 80 | + |
| 81 | + ``` |
| 82 | + 10.0.0.4 AGNode1.ag.wgcluster.example.com #Availability group node |
| 83 | + 10.0.0.5 AGNode2.ag.wgcluster.example.com #Availability group node |
| 84 | + 10.0.0.6 AGWGAG.ag.wgcluster.example.com #Cluster IP |
| 85 | + 10.0.0.7 AGListener.ag.wgcluster.example.com #Listener IP |
| 86 | + ``` |
| 87 | + |
| 88 | +  |
| 89 | + |
| 90 | +## Set permissions |
| 91 | + |
| 92 | +Since there is no Active Directory to manage permissions, you need to manually allow a non-builtin local administrator account to create the cluster. |
| 93 | + |
| 94 | +To do so, run the following PowerShell cmdlet in an administrative PowerShell session on every node: |
| 95 | + |
| 96 | +```PowerShell |
| 97 | +
|
| 98 | +new-itemproperty -path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name LocalAccountTokenFilterPolicy -Value 1 |
| 99 | +``` |
| 100 | + |
| 101 | +## Create the failover cluster |
| 102 | + |
| 103 | +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). |
| 104 | + |
| 105 | +Notable differences between the tutorial and what should be done for a workgroup cluster: |
| 106 | +- Uncheck **Storage**, and **Storage Spaces Direct** when running the cluster validation. |
| 107 | +- When adding the nodes to the cluster, add the fully qualified name, such as: |
| 108 | + - `AGNode1.ag.wgcluster.example.com` |
| 109 | + - `AGNode2.ag.wgcluster.example.com` |
| 110 | +- Uncheck **Add all eligible storage to the cluster**. |
| 111 | + |
| 112 | +Once the cluster has been created, assign a static Cluster IP address. To do so, follow these steps: |
| 113 | + |
| 114 | +1. On one of the nodes, open **Failover Cluster Manager**, select the cluster, right-click the **Name: \<ClusterNam>** under **Cluster Core Resources** and then select **Properties**. |
| 115 | + |
| 116 | +  |
| 117 | + |
| 118 | +1. Select the IP address under **IP Addresses** and select **Edit**. |
| 119 | +1. Select **Use Static**, provide the IP address of the cluster, and then select **OK**: |
| 120 | + |
| 121 | +  |
| 122 | + |
| 123 | +1. Verify that your settings look correct, and then select **OK** to save them: |
| 124 | + |
| 125 | +  |
| 126 | + |
| 127 | +## Create a cloud witness |
| 128 | + |
| 129 | +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). |
| 130 | + |
| 131 | +## Enable availability group feature |
| 132 | + |
| 133 | +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). |
| 134 | + |
| 135 | +## Create keys and certificate |
| 136 | + |
| 137 | +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`. |
| 138 | + |
| 139 | +To configure the first node, follow these steps: |
| 140 | + |
| 141 | +1. Open **SQL Server Management Studio** and connect to your first node, such as `AGNode1`. |
| 142 | +1. Open a **New Query** window and run the following Transact-SQL (T-SQL) statement after updating to a complex and secure password: |
| 143 | + |
| 144 | + ```sql |
| 145 | + USE master; |
| 146 | + CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'PassWOrd123!'; |
| 147 | + GO |
| 148 | + |
| 149 | + --create a cert from the master key |
| 150 | + USE master; |
| 151 | + CREATE CERTIFICATE AGNode1Cert |
| 152 | + WITH SUBJECT = 'AGNode1 Certificate'; |
| 153 | + GO |
| 154 | + |
| 155 | + --Backup the cert and transfer it to AGNode2 |
| 156 | + BACKUP CERTIFICATE AGNode1Cert TO FILE = 'C:\certs\AGNode1Cert.crt'; |
| 157 | + GO |
| 158 | + ``` |
| 159 | + |
| 160 | +1. Next, create the HADR endpoint, and use the certificate for authentication by running this Transact-SQL (T-SQL) statement: |
| 161 | + |
| 162 | + ```sql |
| 163 | + --CREATE or ALTER the mirroring endpoint |
| 164 | + CREATE ENDPOINT hadr_endpoint |
| 165 | + STATE = STARTED |
| 166 | + AS TCP ( |
| 167 | + LISTENER_PORT=5022 |
| 168 | + , LISTENER_IP = ALL |
| 169 | + ) |
| 170 | + FOR DATABASE_MIRRORING ( |
| 171 | + AUTHENTICATION = CERTIFICATE AGNode1Cert |
| 172 | + , ENCRYPTION = REQUIRED ALGORITHM AES |
| 173 | + , ROLE = ALL |
| 174 | + ); |
| 175 | + GO |
| 176 | + ``` |
| 177 | + |
| 178 | +1. Use **File Explorer** to go to the file location where your certificate is, such as `c:\certs`. |
| 179 | +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. |
| 180 | + |
| 181 | +To configure the second node, follow these steps: |
| 182 | + |
| 183 | +1. Connect to the second node with **SQL Server Management Studio**, such as `AGNode2`. |
| 184 | +1. In a **New Query** window, run the following Transact-SQL (T-SQL) statement after updating to a complex and secure password: |
| 185 | + |
| 186 | + ```sql |
| 187 | + USE master; |
| 188 | + CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'PassWOrd123!'; |
| 189 | + GO |
| 190 | + |
| 191 | + --create a cert from the master key |
| 192 | + USE master; |
| 193 | + CREATE CERTIFICATE AGNode2Cert |
| 194 | + WITH SUBJECT = 'AGNode2 Certificate'; |
| 195 | + GO |
| 196 | + --Backup the cert and transfer it to AGNode1 |
| 197 | + BACKUP CERTIFICATE AGNode2Cert TO FILE = 'C:\certs\AGNode2Cert.crt'; |
| 198 | + GO |
| 199 | + ``` |
| 200 | + |
| 201 | +1. Next, create the HADR endpoint, and use the certificate for authentication by running this Transact-SQL (T-SQL) statement: |
| 202 | + |
| 203 | + ```sql |
| 204 | + --CREATE or ALTER the mirroring endpoint |
| 205 | + CREATE ENDPOINT hadr_endpoint |
| 206 | + STATE = STARTED |
| 207 | + AS TCP ( |
| 208 | + LISTENER_PORT=5022 |
| 209 | + , LISTENER_IP = ALL |
| 210 | + ) |
| 211 | + FOR DATABASE_MIRRORING ( |
| 212 | + AUTHENTICATION = CERTIFICATE AGNode2Cert |
| 213 | + , ENCRYPTION = REQUIRED ALGORITHM AES |
| 214 | + , ROLE = ALL |
| 215 | + ); |
| 216 | + GO |
| 217 | + ``` |
| 218 | + |
| 219 | +1. Use **File Explorer** to go to the file location where your certificate is, such as `c:\certs`. |
| 220 | +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. |
| 221 | + |
| 222 | +If there are any other nodes in the cluster, repeat these steps there also, modifying the respective certificate names. |
| 223 | + |
| 224 | +## Create logins |
| 225 | + |
| 226 | +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. |
| 227 | + |
| 228 | +To do so, first run the following Transact-SQL (T-SQL) query on the first node, such as `AGNode1`: |
| 229 | + |
| 230 | +```sql |
| 231 | +--create a login for the AGNode2 |
| 232 | +USE master; |
| 233 | +CREATE LOGIN AGNode2_Login WITH PASSWORD = 'PassWord123!'; |
| 234 | +GO |
| 235 | + |
| 236 | +--create a user from the login |
| 237 | +CREATE USER AGNode2_User FOR LOGIN AGNode2_Login; |
| 238 | +GO |
| 239 | + |
| 240 | +--create a certificate that the login uses for authentication |
| 241 | +CREATE CERTIFICATE AGNode2Cert |
| 242 | + AUTHORIZATION AGNode2_User |
| 243 | + FROM FILE = 'C:\certs\AGNode2Cert.crt' |
| 244 | +GO |
| 245 | + |
| 246 | +--grant connect for login |
| 247 | +GRANT CONNECT ON ENDPOINT::hadr_endpoint TO [AGNode2_login]; |
| 248 | +GO |
| 249 | +``` |
| 250 | + |
| 251 | +Next, run the following Transact-SQL (T-SQL) query on the second node, such as `AGNode2`: |
| 252 | + |
| 253 | +```sql |
| 254 | +--create a login for the AGNode1 |
| 255 | +USE master; |
| 256 | +CREATE LOGIN AGNode1_Login WITH PASSWORD = 'PassWord123!'; |
| 257 | +GO |
| 258 | + |
| 259 | +--create a user from the login |
| 260 | +CREATE USER AGNode1_User FOR LOGIN AGNode1_Login; |
| 261 | +GO |
| 262 | + |
| 263 | +--create a certificate that the login uses for authentication |
| 264 | +CREATE CERTIFICATE AGNode1Cert |
| 265 | + AUTHORIZATION AGNode1_User |
| 266 | + FROM FILE = 'C:\certs\AGNode1Cert.crt' |
| 267 | +GO |
| 268 | + |
| 269 | +--grant connect for login |
| 270 | +GRANT CONNECT ON ENDPOINT::hadr_endpoint TO [AGNode1_login]; |
| 271 | +GO |
| 272 | +``` |
| 273 | + |
| 274 | +If there are any other nodes in the cluster, repeat these steps there also, modifying the respective certificate and user names. |
| 275 | + |
| 276 | +## Configure availability group |
| 277 | + |
| 278 | +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. |
| 279 | + |
| 280 | + > [!NOTE] |
| 281 | + > 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. |
| 282 | +
|
| 283 | +## Configure load balancer |
| 284 | + |
| 285 | +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) |
| 286 | + |
| 287 | + |
| 288 | +## Next Steps |
| 289 | + |
| 290 | +You can also use [Az SQL VM CLI](virtual-machines-windows-sql-availability-group-cli.md) to configure an availability group. |
| 291 | + |
| 292 | + |
0 commit comments