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.
To use SSMS, follow the instructions in this article.
Use SSMS on a Windows operating system to connect to instances of SQL Server. For background and instructions, see Use SQL Server Management Studio on Windows to manage SQL Server on Linux.
For an example with stored procedures, follow the Configure Replication with T-SQL tutorial.
Prerequisites
Before configuring publishers, distributors, and subscribers, you need to complete a couple configuration steps for the SQL Server instance.
- 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
- 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
EXECUTE sys.sp_MSrepl_createdatatypemappings;
GO
- 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:
On SSMS connect to your instance of SQL Server in Object Explorer.
Right-click Replication, and select Configure Distribution....
Follow the instructions on the Configure Distribution Wizard.
Create publication and articles
To create a publication and articles:
In Object Explorer, select Replication > Local Publications> New Publication....
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.