You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Configure SQL Server Always On Availability Group on Windows and Linux
2
+
title: Configure SQL Server Always On availability group on Windows and Linux
3
3
description: Learn how to create a SQL Server Always On Availability Group (AG) with one replica on a Windows server and the other replica on a Linux server.
4
4
author: VanMSFT
5
5
ms.author: vanto
6
-
ms.reviewer: vanto
7
-
ms.date: 01/31/2018
8
-
ms.topic: conceptual
6
+
ms.reviewer: vanto, randolphwest
7
+
ms.date: 12/14/2022
9
8
ms.service: sql
10
9
ms.subservice: linux
11
-
ms.assetid:
10
+
ms.topic: conceptual
12
11
monikerRange: ">= sql-server-2017"
13
12
---
14
-
# Configure SQL Server Always On Availability Group on Windows and Linux (cross-platform)
13
+
# Configure SQL Server Always On availability group on Windows and Linux (cross-platform)
This article explains the steps to create an Always On Availability Group (AG) with one replica on a Windows server and the other replica on a Linux server. This configuration is cross-platform because the replicas are on different operating systems. Use this configuration for migration from one platform to the other or disaster recovery (DR). This configuration does not support high-availability because there is no cluster solution to manage a cross-platform configuration.
17
+
This article explains the steps to create an Always On availability group (AG) with one replica on a Windows server and the other replica on a Linux server.
18
+
19
+
> [!IMPORTANT]
20
+
> [!INCLUDE [ssnoversion-md](../includes/ssnoversion-md.md)] cross-platform availability groups, which include heterogeneous replicas with complete high-availability and disaster recovery support, is available with DH2i DxEnterprise. For more information, see [SQL Server Availability Groups with Mixed Operating Systems](https://support.dh2i.com/docs/guides/dxenterprise/sql_server/mssql-ag-mixed-os-qsg).
This configuration is cross-platform because the replicas are on different operating systems. Use this configuration for migration from one platform to the other or disaster recovery (DR). This configuration doesn't support high availability.
21
23
22
-
Before proceeding, you should be familiar with installation and configuration for SQL Server instances on Windows and Linux.
24
+
:::image type="content" source="media/sql-server-linux-availability-group-cross-platform/cluster-type-none.png" alt-text="Diagram of Availability group with cluster type of None.":::
25
+
26
+
Before proceeding, you should be familiar with installation and configuration for SQL Server instances on Windows and Linux.
23
27
24
28
## Scenario
25
29
26
-
In this scenario, two servers are on different operating systems. A Windows Server 2016 named `WinSQLInstance` hosts the primary replica. A Linux server named `LinuxSQLInstance` host the secondary replica.
30
+
In this scenario, two servers are on different operating systems. A Windows Server 2022 named `WinSQLInstance` hosts the primary replica. A Linux server named `LinuxSQLInstance` host the secondary replica.
27
31
28
-
## Configure the AG
32
+
## Configure the AG
29
33
30
-
The steps to create the AG are the same as the steps to create an AG for read-scale workloads. The AG cluster type is NONE, because there is no cluster manager.
34
+
The steps to create the AG are the same as the steps to create an AG for [read-scale workloads](sql-server-linux-availability-group-configure-rs.md). The AG cluster type is NONE, because there is no cluster manager.
31
35
32
-
>[!NOTE]
33
-
>For the scripts in this article, angle brackets `<` and `>` identify values that you need to replace for your environment. The angle brackets themselves are not required for the scripts.
36
+
> [!NOTE]
37
+
> For the scripts in this article, angle brackets `<` and `>` identify values that you need to replace for your environment. The angle brackets themselves are not required for the scripts.
34
38
35
-
1. Install SQL Server 2017 on Windows Server 2016, enable Always On Availability Groups from SQL Server Configuration Manager, and set mixed mode authentication.
39
+
1. Install [!INCLUDE [sssql22-md](../includes/sssql22-md.md)]on Windows Server 2022, enable **Always On Availability Groups** from SQL Server Configuration Manager, and set mixed mode authentication.
36
40
37
-
>[!TIP]
38
-
>If you are validating this solution in Azure, place both servers in the same availability set to ensure they are separated in the data center.
41
+
>[!TIP]
42
+
>If you are validating this solution in Azure, place both servers in the same availability set to ensure they are separated in the data center.
39
43
40
44
**Enable Availability Groups**
41
45
42
46
For instructions, see [Enable and disable Always On Availability Groups (SQL Server)](../database-engine/availability-groups/windows/enable-and-disable-always-on-availability-groups-sql-server.md).
:::image type="content" source="./media/sql-server-linux-availability-group-cross-platform/configuration-manager.png" alt-text="Screenshot showing how to enable Availability Groups.":::
45
49
46
-
SQL Server Configuration Manager notes that the computer is not a node in a failover cluster.
50
+
SQL Server Configuration Manager notes that the computer isn't a node in a failover cluster.
47
51
48
52
After you enable Availability Groups, restart SQL Server.
49
53
50
54
**Set mixed mode authentication**
51
55
52
56
For instructions, see [Change server authentication mode](../database-engine/configure-windows/change-server-authentication-mode.md#change-authentication-mode-with-ssms).
53
57
54
-
1. Install SQL Server 2017 on Linux. For instructions, see [Install SQL Server](sql-server-linux-setup.md). Enable `hadr`via mssql-conf.
58
+
1. Install [!INCLUDE [sssql22-md](../includes/sssql22-md.md)]on Linux. For instructions, see [Install SQL Server](sql-server-linux-setup.md). Enable `hadr`with **mssql-conf**.
55
59
56
-
To enable `hadr` via mssql-conf from a shell prompt, issue the following command:
60
+
To enable `hadr` via **mssql-conf** from a shell prompt, issue the following command:
57
61
58
62
```bash
59
63
sudo /opt/mssql/bin/mssql-conf set hadr.hadrenabled 1
60
64
```
61
65
62
-
After you enable `hadr`, restart the SQL Server instance.
63
-
64
-
The following image shows this complete step.
66
+
After you enable `hadr`, restart the SQL Server instance:
65
67
66
-

68
+
```bash
69
+
sudo systemctl restart mssql-server.service
70
+
```
67
71
68
-
1. Configure hosts file on both servers or register the server names with DNS.
72
+
1. Configure the `hosts` file on both servers, or register the server names with DNS.
69
73
70
-
1. Open up firewall ports for TPC 1433 and 5022 on both Windows and Linux.
74
+
1. Open up firewall ports for TCP 1433 and 5022 on both Windows and Linux.
71
75
72
76
1. On the primary replica, create a database login and password.
73
77
@@ -83,19 +87,19 @@ The steps to create the AG are the same as the steps to create an AG for read-sc
83
87
CREATE MASTER KEY ENCRYPTION BY PASSWORD ='<C0m9L3xP@55w0rd!>';
84
88
CREATE CERTIFICATE dbm_certificate WITH SUBJECT ='dbm';
85
89
BACKUP CERTIFICATE dbm_certificate
86
-
TO FILE ='C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\dbm_certificate.cer'
90
+
TO FILE ='C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\dbm_certificate.cer'
1. Copy the certificate and private key to the Linux server (secondary replica) at `/var/opt/mssql/data`. You can use `pscp` to copy the files to the Linux server.
98
+
1. Copy the certificate and private key to the Linux server (secondary replica) at `/var/opt/mssql/data`. You can use `pscp` to copy the files to the Linux server.
95
99
96
100
1. Set the group and ownership of the private key and the certificate to `mssql:mssql`.
97
101
98
-
The following script sets the group and ownership of the files.
102
+
The following script sets the group and ownership of the files.
@@ -104,8 +108,7 @@ The steps to create the AG are the same as the steps to create an AG for read-sc
104
108
105
109
In the following diagram, ownership and group are set correctly for the certificate and key.
106
110
107
-

108
-
111
+
:::image type="content" source="./media/sql-server-linux-availability-group-cross-platform/certificate-key-owner-group.png" alt-text="Screenshot of a Git Bash window showing the .cer and the .pvk in the /var/opt/mssql/data folder.":::
109
112
110
113
1. On the secondary replica, create a database login and password and create a master key.
111
114
@@ -117,10 +120,10 @@ The steps to create the AG are the same as the steps to create an AG for read-sc
117
120
GO
118
121
```
119
122
120
-
1. On the secondary replica, restore the certificate you copied to `/var/opt/mssql/data`.
123
+
1. On the secondary replica, restore the certificate you copied to `/var/opt/mssql/data`.
121
124
122
125
```sql
123
-
CREATE CERTIFICATE dbm_certificate
126
+
CREATE CERTIFICATE dbm_certificate
124
127
AUTHORIZATION dbm_user
125
128
FROM FILE ='/var/opt/mssql/data/dbm_certificate.cer'
126
129
WITH PRIVATE KEY (
@@ -141,106 +144,106 @@ The steps to create the AG are the same as the steps to create an AG for read-sc
141
144
ENCRYPTION = REQUIRED ALGORITHM AES
142
145
);
143
146
ALTER ENDPOINT [Hadr_endpoint] STATE = STARTED;
144
-
GRANT CONNECT ON ENDPOINT::[Hadr_endpoint] TO [dbm_login]
147
+
GRANT CONNECT ON ENDPOINT::[Hadr_endpoint] TO [dbm_login];
145
148
GO
146
149
```
147
150
148
-
>[!IMPORTANT]
149
-
>The firewall must be open for the listener TCP port. In the preceding script, the port is 5022. Use any available TCP port.
151
+
>[!IMPORTANT]
152
+
>The firewall must be open for the listener TCP port. In the preceding script, the port is 5022. Use any available TCP port.
150
153
151
-
1. On the secondary replica, create the endpoint. Repeat the preceding script on the secondary replica to create the endpoint.
154
+
1. On the secondary replica, create the endpoint. Repeat the preceding script on the secondary replica to create the endpoint.
152
155
153
-
1. On the primary replica, create the AG with `CLUSTER_TYPE = NONE`. The example script uses `SEEDING_MODE = AUTOMATIC` to create the AG.
156
+
1. On the primary replica, create the AG with `CLUSTER_TYPE = NONE`. The example script uses `SEEDING_MODE = AUTOMATIC` to create the AG.
154
157
155
-
>[!NOTE]
156
-
>When the Windows instance of SQL Server uses different paths for data and log files, automatic seeding fails to the Linux instance of SQL Server because these paths do not exist on the secondary replica. To use the following script for a cross-platform AG, the database requires the same path for the data and log files on the Windows server. Alternatively you can update the script to set `SEEDING_MODE = MANUAL` and then back up and restore the database with `NORECOVERY` to seed the database.
158
+
>[!NOTE]
159
+
>When the Windows instance of SQL Server uses different paths for data and log files, automatic seeding fails to the Linux instance of SQL Server, because these paths do not exist on the secondary replica. To use the following script for a cross-platform AG, the database requires the same path for the data and log files on the Windows server. Alternatively you can update the script to set `SEEDING_MODE = MANUAL` and then back up and restore the database with `NORECOVERY` to seed the database.
157
160
>
158
-
>This behavior applies to Azure Marketplace images.
161
+
>This behavior applies to Azure Marketplace images.
159
162
>
160
-
>For more information about automatic seeding, see [Automatic Seeding - Disk Layout](../database-engine/availability-groups/windows/automatic-seeding-secondary-replicas.md#disklayout).
163
+
>For more information about automatic seeding, see [Automatic Seeding - Disk Layout](../database-engine/availability-groups/windows/automatic-seeding-secondary-replicas.md#disklayout).
161
164
162
165
Before you run the script, update the values for your AGs.
163
166
164
-
* Replace `<WinSQLInstance>` with the server name of the primary replica SQL Server instance.
167
+
- Replace `<WinSQLInstance>` with the server name of the primary replica SQL Server instance.
165
168
166
-
* Replace `<LinuxSQLInstance>` with the server name of the secondary replica SQL Server instance.
169
+
- Replace `<LinuxSQLInstance>` with the server name of the secondary replica SQL Server instance.
167
170
168
-
To create the AG, update the values and run the script on the primary replica.
171
+
To create the AG, update the values and run the script on the primary replica.
169
172
170
173
```sql
171
-
CREATE AVAILABILITY GROUP [ag1]
172
-
WITH (CLUSTER_TYPE = NONE)
173
-
FOR REPLICA ON
174
-
N'<WinSQLInstance>'
175
-
WITH (
176
-
ENDPOINT_URL = N'tcp://<WinSQLInstance>:5022',
177
-
AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT,
178
-
SEEDING_MODE = AUTOMATIC,
179
-
FAILOVER_MODE = MANUAL,
180
-
SECONDARY_ROLE (ALLOW_CONNECTIONS = ALL)
181
-
),
182
-
N'<LinuxSQLInstance>'
183
-
WITH (
184
-
ENDPOINT_URL = N'tcp://<LinuxSQLInstance>:5022',
185
-
AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT,
186
-
SEEDING_MODE = AUTOMATIC,
187
-
FAILOVER_MODE = MANUAL,
188
-
SECONDARY_ROLE (ALLOW_CONNECTIONS = ALL)
189
-
)
174
+
CREATE AVAILABILITY
175
+
GROUP [ag1]
176
+
WITH (CLUSTER_TYPE = NONE)
177
+
FOR REPLICA
178
+
ON N'<WinSQLInstance>'
179
+
WITH (
180
+
ENDPOINT_URL = N'tcp://<WinSQLInstance>:5022',
181
+
AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT,
182
+
SEEDING_MODE = AUTOMATIC,
183
+
FAILOVER_MODE = MANUAL,
184
+
SECONDARY_ROLE(ALLOW_CONNECTIONS = ALL)
185
+
),
186
+
N'<LinuxSQLInstance>'
187
+
WITH (
188
+
ENDPOINT_URL = N'tcp://<LinuxSQLInstance>:5022',
189
+
AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT,
190
+
SEEDING_MODE = AUTOMATIC,
191
+
FAILOVER_MODE = MANUAL,
192
+
SECONDARY_ROLE(ALLOW_CONNECTIONS = ALL);
193
+
)
190
194
GO
191
195
```
192
-
196
+
193
197
For more information, see [CREATE AVAILABILITY GROUP (Transact-SQL)](../t-sql/statements/create-availability-group-transact-sql.md).
194
198
195
199
1. On the secondary replica, join the AG.
196
200
197
201
```sql
198
-
ALTER AVAILABILITY GROUP [ag1] JOIN WITH (CLUSTER_TYPE = NONE)
199
-
ALTER AVAILABILITY GROUP [ag1] GRANT CREATE ANY DATABASE
202
+
ALTER AVAILABILITY GROUP [ag1] JOIN WITH (CLUSTER_TYPE = NONE);
203
+
ALTER AVAILABILITY GROUP [ag1] GRANT CREATE ANY DATABASE;
200
204
GO
201
205
```
202
206
203
-
1. Create a database for the AG. The example steps use a database named `<TestDB>`. If you are using automatic seeding, set the same path for both the data and the log files.
207
+
1. Create a database for the AG. The example steps use a database named `TestDB`. If you are using automatic seeding, set the same path for both the data and the log files.
204
208
205
209
Before you run the script, update the values for your database.
206
210
207
-
*Replace `<TestDB>` with the name of your database.
211
+
-Replace `TestDB` with the name of your database.
208
212
209
-
*Replace `<F:\Path>` with the path for your database and log files. Use the same path for the database and log files.
213
+
-Replace `<F:\Path>` with the path for your database and log files. Use the same path for the database and log files.
210
214
211
-
You can also use the default paths.
215
+
You can also use the default paths.
212
216
213
-
To create your database, run the script.
217
+
To create your database, run the script.
214
218
215
219
```sql
216
-
CREATE DATABASE [<TestDB>]
220
+
CREATE DATABASE [TestDB]
217
221
CONTAINMENT = NONE
218
-
ON PRIMARY ( NAME = N'<TestDB>', FILENAME = N'<F:\Path>\<TestDB>.mdf')
219
-
LOG ON ( NAME = N'<TestDB>_log', FILENAME = N'<F:\Path>\<TestDB>_log.ldf')
222
+
ON PRIMARY ( NAME = N'TestDB', FILENAME = N'<F:\Path>\TestDB.mdf')
223
+
LOG ON ( NAME = N'TestDB_log', FILENAME = N'<F:\Path>\TestDB_log.ldf');
220
224
GO
221
225
```
222
226
223
-
1. Take a full backup of the database.
227
+
1. Take a full backup of the database.
224
228
225
-
1. If you are not using automatic seeding, restore the database on the secondary replica (Linux) server. [Migrate a SQL Server database from Windows to Linux using backup and restore](sql-server-linux-migrate-restore-database.md). Restore the database `WITH NORECOVERY` on the secondary replica.
229
+
1. If you aren't using automatic seeding, restore the database on the secondary replica (Linux) server. [Migrate a SQL Server database from Windows to Linux using backup and restore](sql-server-linux-migrate-restore-database.md). Restore the database `WITH NORECOVERY` on the secondary replica.
226
230
227
-
1. Add the database to the AG. Update the example script. Replace `<TestDB>` with the name of your database. On the primary replica, run the SQL query to add the database to the AG.
231
+
1. Add the database to the AG. Update the example script. Replace `TestDB` with the name of your database. On the primary replica, run the T-SQL query to add the database to the AG.
228
232
229
233
```sql
230
-
ALTER AG [ag1] ADD DATABASE <TestDB>
234
+
ALTER AG [ag1] ADD DATABASE TestDB;
231
235
GO
232
236
```
233
237
234
-
1. Verify that the database is getting populated on the secondary replica.
238
+
1. Verify that the database is getting populated on the secondary replica.
This article reviewed the steps to create a cross-platform AG to support migration or read-scale workloads. It can be used for manual disaster recovery. It also explained how to fail over the AG. A cross-platform AG uses cluster type `NONE` and does not support high availability because there is no cluster tool across-platforms.
244
+
This article reviewed the steps to create a cross-platform AG to support migration or read-scale workloads. It can be used for manual disaster recovery. It also explained how to fail over the AG. A cross-platform AG uses cluster type `NONE` and doesn't support high availability.
241
245
242
246
## Next steps
243
247
244
-
[Overview of Always On Availability Groups](../database-engine/availability-groups/windows/overview-of-always-on-availability-groups-sql-server.md)
245
-
246
-
[SQL Server availability basics for Linux deployments](sql-server-linux-ha-basics.md)
248
+
-[Overview of Always On Availability Groups](../database-engine/availability-groups/windows/overview-of-always-on-availability-groups-sql-server.md)
249
+
-[SQL Server availability basics for Linux deployments](sql-server-linux-ha-basics.md)
0 commit comments