Rediger

Del via


Configure SQL Server Replication on Linux

Applies to: SQL Server - Linux

SQL Server 2019 (15.x) introduces SQL Server Replication for instances of SQL Server on Linux.

For detailed information about replication, see SQL Server Replication.

Configure replication on Linux with either SQL Server Management Studio (SSMS) or Transact-SQL stored procedures.

Prerequisites

Before configuring publishers, distributors, and subscribers, you need to complete a couple configuration steps for the SQL Server instance.

  1. Enable SQL Server Agent to use replication agents. On all Linux servers, run the following commands in the terminal.
sudo /opt/mssql/bin/mssql-conf set sqlagent.enabled true
sudo systemctl restart mssql-server
  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.
USE msdb;
GO
exec sys.sp_MSrepl_createdatatypemappings;
GO
  1. Create a snapshot folder. The SQL Server agents require a snapshot folder to read/write to. Create the snapshot folder on the distributor.

To create the snapshot folder, and grant access to mssql user, run the following command:

sudo mkdir /var/opt/mssql/data/ReplData/
sudo chown mssql /var/opt/mssql/data/ReplData/
sudo chgrp mssql /var/opt/mssql/data/ReplData/

Configure and monitor replication with SQL Server Management Studio (SSMS)

Configure the distributor

To configure the distributor:

  1. On SSMS connect to your instance of SQL Server in Object Explorer.

  2. Right-click Replication, and select Configure Distribution....

  3. Follow the instructions on the Configure Distribution Wizard.

Create publication and articles

To create a publication and articles:

  1. In Object Explorer, select Replication > Local Publications> New Publication....

  2. Follow the instruction on the New Publication Wizard to configure the type of replication, and the articles that belong to the publication.

Configure the subscription

To configure the subscription in Object Explorer, select Replication > Local Subscriptions> New subscriptions....

Monitor replication jobs

Use Replication Monitor to monitor replication jobs.

In Object Explorer, right-click Replication, and select Launch Replication Monitor.