| title | Configure snapshot folder shares |
|---|---|
| titleSuffix | SQL Server on Linux |
| description | Learn to configure snapshot folder shares SQL Server replication on Linux. |
| ms.custom | seo-lt-2019 |
| author | VanMSFT |
| ms.author | vanto |
| ms.reviewer | vanto |
| ms.date | 09/24/2018 |
| ms.topic | article |
| ms.prod | sql |
| ms.technology | linux |
| monikerRange | >=sql-server-ver15||>=sql-server-linux-ver15 |
[!INCLUDE SQL Server - Linux]
The snapshot folder is a directory that you have designated as a share; agents that read from and write to this folder must have enough permissions to access it.
Before the examples, let's walk through how SQL Server uses samba shares in replication. Below is a basic example of how this works.
- Samba shares are configured that files written to
/local/path1by the replication agents on publisher can be seen by the subscriber - SQL Server is configured to use share paths when setting up the publisher on the distribution server such that all instances would look at the
//share/path - SQL Server finds the local path from the
//share/pathto know where to look for the files - SQL Server reads/writes to local paths backed by a samba share
Replication agents will need a shared directory between replication hosts to access snapshot folders on other machines. For example, in transactional pull replication, the distribution agent resides on the subscriber, which requires access to the distributor to get articles. In this section, we'll go through an example of how to configure a samba share on two replication hosts.
As an example, we will configure a snapshot folder on Host 1 (the distributor) to be shared with Host 2 (the subscriber) using Samba.
On Ubuntu:
sudo apt-get -y install samba
sudo service smbd restartOn RHEL:
sudo yum install samba
sudo service smb start
sudo service smb status- Set-up user and password for samba:
sudo smbpasswd -a mssql - Edit the
/etc/samba/smb.confto include the following entry and fill in the share_name and path fields
<[share_name]>
path = </local/path/on/host/1>
writable = yes
create mask = 770
directory mask
valid users = mssql Example
[mssql_data] <- Name of the shared directory
path = /var/opt/mssql/repldata <- location of directory we wish to share
writable = yes <- determines if the share is writable from other hosts
create mask = 770 <- Linux permissions for files created
directory mask = 770 <- Linux permissions for directories created
valid users = mssql <- list of users who can login to this shareEdit the command with the correct paths and run the following command on machine2:
sudo mount //<name_of_host_1>/<share_name> </local/path/on/host/2> -o user=mssql,uid=mssql,gid=mssqlExample
mount //host1/mssql_data /var/opt/mssql/repldata_shared -o user=mssql,uid=mssql,gid=mssql
user=mssql <- sets the login name for samba
uid=mssql <- makes the mssql user as the owner of the mounted directory
gid=mssql <- sets the mssql group as the owner of the mounted directoryAdd the following section to mssql.conf on both machines. Use wherever the samba share for the //share/path. In this example, it would be //host1/mssql_data
[uncmapping]
//share/path = /local/path/on/hosts/Example
On host1:
[uncmapping]
//host1/mssql_data = /local/path/on/hosts/1On host2:
[uncmapping]
//host1/mssql_data = /local/path/on/hosts/2- When setting up replication, use the shares path (example
//host1/mssql_data - Map
//host1/mssql_datato a local directory and the mapping added tomssql.conf.
