หมายเหตุ
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลอง ลงชื่อเข้าใช้หรือเปลี่ยนไดเรกทอรีได้
การเข้าถึงหน้านี้ต้องได้รับการอนุญาต คุณสามารถลองเปลี่ยนไดเรกทอรีได้
Applies to:
SQL Server on 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.
Replication snapshot folder share explained
Before the examples, let's walk through how SQL Server uses samba shares in replication. Following 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
Configure a samba share for the snapshot folder
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.
Steps
As an example, we will configure a snapshot folder on Host 1 (the distributor) to be shared with Host 2 (the subscriber) using Samba.
Install and start Samba on both machines
Set up the Samba share on distributor (host1)
Set-up user and password for samba:
sudo smbpasswd -a mssqlEdit 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 = mssqlThe following table describes each setting.
Setting Description [mssql_data]Name of the shared directory pathLocation of directory we wish to share writableDetermine if the share is writable from other hosts create maskLinux permissions for files created directory maskLinux permissions for directories created valid usersList of users who can login to this share Example
[mssql_data] path = /var/opt/mssql/repldata writable = yes create mask = 770 directory mask = 770 valid users = mssql
Mount the Samba share on subscriber (host2)
Edit 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=mssql
Example
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 directory
Configure SQL Server on both Linux hosts to use snapshot share
Add 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/1
On host2:
[uncmapping]
//host1/mssql_data = /local/path/on/hosts/2
Configure publisher with shared paths
- 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.