|
| 1 | +--- |
| 2 | +title: Configure SQL Server Replication on Linux | Microsoft Docs |
| 3 | +description: This article describes how to configure SQL Server replication on Linux. |
| 4 | +author: MikeRayMSFT |
| 5 | +ms.author: mikeray |
| 6 | +manager: craigg |
| 7 | +ms.date: 03/20/2018 |
| 8 | +ms.topic: article |
| 9 | +ms.prod: "sql-non-specified" |
| 10 | +ms.prod_service: "database-engine" |
| 11 | +ms.service: "" |
| 12 | +ms.component: "" |
| 13 | +ms.suite: "sql" |
| 14 | +ms.custom: "sql-linux" |
| 15 | +ms.technology: database-engine |
| 16 | +ms.assetid: |
| 17 | +ms.workload: "On Demand" |
| 18 | +monikerRange: ">=sql-server-ver15||>=sql-server-linux-ver15||=sqlallproducts-allversions" |
| 19 | +--- |
| 20 | +# Configure SQL Server Replication on Linux |
| 21 | + |
| 22 | +[!INCLUDE[appliesto-ss-xxxx-xxxx-xxx-md-linuxonly](../includes/appliesto-ss-xxxx-xxxx-xxx-md-linuxonly.md)] |
| 23 | + |
| 24 | +[!INCLUDE[sqlservervnext](../includes/sssqlv15-md.md)] CTP 2.0 introduces SQL Server Replication for instances of SQL Server on Linux. |
| 25 | + |
| 26 | +For detailed information about replication, see [SQL Server replication documentation](../relational-databases/replication/sql-server-replication.md). |
| 27 | + |
| 28 | +Configure replication on Linux with either SQL Server Management Studio (SSMS) or Transact-SQL stored procedures. |
| 29 | + |
| 30 | +* To use SSMS, follow the instructions in this article. |
| 31 | + |
| 32 | + Use SSMS on a Windows operating system to connect to instances of SQL Server. For background and instructions, see [Use SSMS to Manage SQL Server on Linux](./sql-server-linux-manage-ssms.md). |
| 33 | + |
| 34 | +* For an example with stored procedures, follow the [Configure SQL Server replication on Linux](sql-server-linux-replication-tutorial-tsql.md) tutorial. |
| 35 | + |
| 36 | +## Prerequisites |
| 37 | + |
| 38 | +Before configuring publishers, distributors, and subscribers, you need to complete a couple configuration steps for the SQL Server instance. |
| 39 | + |
| 40 | +1. Enable SQL Server Agent to use replication agents. On all Linux servers, run the following commands in the terminal. |
| 41 | + |
| 42 | + ```bash |
| 43 | + sudo /opt/mssql/bin/mssql-conf set sqlagent.enabled true |
| 44 | + sudo systemctl restart mssql-server |
| 45 | + ``` |
| 46 | + |
| 47 | +1. Configure the SQL Server instance for replication. To configure the SQL Server instance for replication, run `sys.sp_MSrepl_createdatatypemappings` on all instances participating in replication. |
| 48 | + |
| 49 | + ```sql |
| 50 | + USE msdb |
| 51 | + GO |
| 52 | + exec sys.sp_MSrepl_createdatatypemappings; |
| 53 | + GO |
| 54 | + ``` |
| 55 | + |
| 56 | +1. Create a snapshot folder. The SQL Server agents require a snapshot folder to read/write to. Create the snapshot folder on the distributor. |
| 57 | + |
| 58 | + To create the snapshot folder, and grant access to `mssql` user, run the following command: |
| 59 | + |
| 60 | + ```bash |
| 61 | + sudo mkdir /var/opt/mssql/data/ReplData/ |
| 62 | + sudo chown mssql /var/opt/mssql/data/ReplData/ |
| 63 | + sudo chgrp mssql /var/opt/mssql/data/ReplData/ |
| 64 | + ``` |
| 65 | + |
| 66 | +## Configure and monitor replication with SQL Server Management Studio (SSMS) |
| 67 | + |
| 68 | +### Configure the distributor |
| 69 | + |
| 70 | +To configure the distributor: |
| 71 | + |
| 72 | +1. On SSMS connect to your instance of SQL Server in Object Explorer. |
| 73 | + |
| 74 | +1. Right-click **Replication**, and click **Configure Distribution...**. |
| 75 | + |
| 76 | +1. Follow the instructions on the **Configure Distribution Wizard**. |
| 77 | + |
| 78 | +### Create publication and articles |
| 79 | + |
| 80 | +To create a publication and articles: |
| 81 | + |
| 82 | +1. In Object Explorer, click **Replication** > **Local Publications**> **New Publication...**. |
| 83 | + |
| 84 | +1. Follow the instruction on the **New Publication Wizard** to configure the type of replication, and the articles that belong to the publication. |
| 85 | + |
| 86 | +### Configure the subscription |
| 87 | + |
| 88 | +To configure the subscription in Object Explorer, click **Replication** > **Local Subscriptions**> **New subscriptions...**. |
| 89 | + |
| 90 | +### Monitor replication jobs |
| 91 | + |
| 92 | +Use Replication Monitor to monitor replication jobs. |
| 93 | + |
| 94 | +In Object Explorer, right-click **Replication**, and click **Launch Replication Monitor**. |
| 95 | + |
| 96 | +## Next steps |
| 97 | + |
| 98 | +[Concepts: SQL Server replication on Linux](sql-server-linux-replication.md) |
| 99 | + |
| 100 | +[Replication stored procedures](../relational-databases/system-stored-procedures/replication-stored-procedures-transact-sql.md). |
0 commit comments