This manual describes how to configure DFS data replication in the Active Directory domain on servers running Windows Server 2016.
There are two types of Distributed File System (DFS):
- Namespace DFS – DFS allows you to create virtual directory trees that unite shared folders across the network. It is possible to configure multiple DFS namespaces. It uses simplified user access to geographically distributed files;
- Replication DFS – creates a replicated shared folder and tracks changes in files.
Installing DFS Namespaces and DFS Replication Roles on Windows Server 2016
Install the DFS Namespaces and DFS Replication roles on the two servers running Windows Server 2016 between which the replication will be configured.
Use the DFS Management console (dfsmgmt.msc) to create a new DFS namespace.
You can create a domain-based namespace or stand-alone namespace.
- Domain-based namespace – namespace integrated into the AD. Allows you to hide the DFS namespace server name from the users, simplifies the replacement of the namespace server as well as transfer the namespace to another server;
- Stand-alone namespace – allows you to create DFS structures without using an Active Directory Domain Services (AD DS). The high availability of the namespace can be achieved using a failover cluster.
Create a folder in the new namespace. Make sure that the new directory is accessible over the network by the path\\dfsnamespacename\foldername (in our example it is \\contoso.com\public\shareddocs).
Configuring DFS Replication Between 2 Servers Running Windows Server 2016
Now you can configure DFS replication. DFS Replication allows you to synchronize directories with files (replicated folders) between servers that are part of a DFS replication group. The servers into DFS replication group are connected to each other using DFS connections.
Changes are replicated using the Remote Differential Compression Algorithm (RDC). Only the changed parts of the files are replicated. DFS replication is performed asynchronously, i.e. at a specific point in time, sources may not be consistent.
It is necessary to distinguish between simple FRS replication (File Replication Service) and DFSR (Distributed File System Replication). DFSR appeared in Windows Server 2008, it became possible to use differential compression when performing some changes in the file, but not the entire file, are transferred over the network. In FRS replication, the entire file is copied.
DFS replication is advantageous to use folders between remote branches over slow WAN link for replicating.
When communication between replication partners is lost, replication stops. After the network is restored, replication will continue.
A replication group is a set of servers (members) that participate in the replication of one or more folders.
Before configuring replication, you need to add a network shared folder on the second DFS server. Open the DFS Management console, select the desired namespace, and select Add Folder Target from the context menu.
Enter the name of the shared folder and click OK (in our example this is \\host2\dfssharedocs).
You will be prompted to create a new replication group. Click Yes.
Tip. If you clicked No, then to create a new replication group in the DFS management console, right-click on the Replication section and select New Replication Group.
In the DFS Replication Configuration Wizard, you need to verify the name of the replication group and the directory you want to replicate.
Check the paths to the shared folders on the servers.
Select the primary member node on which the initial data is stored and from which initial replication will be performed.
As a rule, Full mesh is selected as the replication topology. In this topology all changes on one node are immediately replicated to all the others.
It remains to adjust the schedule and bandwidth that can be used to replicate data. Check the settings and click Create.
A message should appear after the successful creation of a new replication group.
This completes the configuration of the DFS distributed file system and data replication in it.
Try creating a new file in the shared folder on the one of the member server. If the file size is very large, its replication can take several hours or even days, depending on the bandwidth of the communication channel between DFS servers and the DFS replication settings.
If 2 users simultaneously edit (or create) the same file, then DFS replicates the version of the file that was changed (created) last. An earlier version of the file is stored in DfsrPrivate\ConflictandDeleted directory on the server that resolves the DFS replication conflict. In this case, an entry about the conflict that has occurred appears in the ConflictandDeletedManifest.xml file.
Tweaking DFS Replication
After creating a DFS replication group, you can change various settings to provide better performance.
In the DFS Management console, expand the Replication section, which contains all the replication groups.
Select the replication group you created. In the right window you will see 4 tabs:
- Membership – this is a list of network folders between which data is replicated;
- Connections – describes the topology of relationships between DFS replication partners;
- Replicated Folders – DFS folder settings;
- Delegation – replication group permissions.
On the Membership tab, note the Staging Quota value — 4 GB. What it is? When replicating, the DFS service uses intermediate hidden folders that store modified files that need to be transferred to replication partners. These files are stored on each server in a local folder DfsrPrivate\Staging.
On the Membership tab, open the properties of any folder and go to the Staging tab. As you can see, here you specify the path to the Staging folder and its maximum size (Quota). The default is 4 GB. In large infrastructures, it is desirable to increase the quota size to increase the performance of the DFS file replication service.
Microsoft recommends that this quota should be not less than the total size of the 32 largest files in the replication directory. The total size of the 32 largest files in the directory can be obtained using the following PowerShell command:
Get-ChildItem C:\SharedDOCS -recurse –force | Sort-Object length -descending | select-object -first 32 | measure-object -property length -sum).sum /1gb
If the staging quota for the DFS server is insufficient, events with EventID 4208 will often be recorded in the event log. In this case, it is recommended to increase the staging quota size by 20%.
Tip. Some admins believe that a file that is larger than the quota on the Staging folder cannot be replicated via DFS. This is not true. Such a file can also be replicated normally, just the replication process will take place in several stages (the file will be cut into several parts and transferred in parts), which will somewhat slow down the process.
On the Advanced tab, you can specify whether to save the files deleted by users in the ConflictandDeleted folder (it is very convenient to restore) and the quota for this folder (by default, it is also 4 GB).
To switch the DFS directory on a specific server to read-only mode, click the directory and select Make read-only. As a result, users won’t be able to edit or create files in this directory.
On the Connection tab, you can temporarily suspend replication to one of the servers in the DFS replication group (Disable), or start forced replication (Replication Now).
On the Replication Folders tab open the properties of any folder. The File filter field contains a list of file extensions that are not replicated between DFS servers. The default file extensions are .bak, and .tmp. You can add other types of file extensions that don’t need to be replicated, for example video (*.avi, *.mpeg), audio (*.mp3, *.wav), image files (*.iso, *.wim) or other file types.
To diagnose DFS replication, you can use system event logs, as well as the current (%windir%\debug\DFSR*.log) and archive DFSR replication log (%windir%\debug\DFSR*.log.gz).
Information about DFS replication settings on the server can be obtained using the PowerShell cmdlet Get-DFSRConnection.