Επεξεργασία

Κοινή χρήση μέσω


Use FILESTREAM and FileTable with Always On availability groups

Applies to: SQL Server - Windows only

This article contains information about the using the FILESTREAM and FileTable features with Always On availability groups in SQL Server.

All FILESTREAM functionality is supported. After a failover, FILESTREAM data is accessible on both readable secondary replicas and on the new primary.

FileTable functionality is partially supported. After a failover, FileTable data is accessible on the primary replica, but FileTable data isn't accessible on readable secondary replicas.

Prerequisites

Use Virtual Network Names (VNNs) for FILESTREAM and FileTable access

When you enable FILESTREAM on an instance of SQL Server, an instance-level share is created to provide access to the FILESTREAM data. You access this share by using the computer name in the following format:

  • \\<computer_name>\<filestream_share_name>

In an Always On availability group, however, the name of the computer is virtualized by using a Virtual Network Name, or VNN. When the computer is the primary replica in an availability group, and databases in the availability group contain FILESTREAM data, then a VNN-scoped share is also created to provide access to the FILESTREAM data. This doesn't affect Transact-SQL access to FILESTREAM data. However applications that use file system APIs have to use the VNN-scoped share, which has a path in the following format:

  • \\<VNN>\<filestream_share_name>

This VNN-scoped share is created when one of the following events occurs.

  • You add a database that contains FILESTREAM data to an Always On availability group on the primary replica. In this case, the share \\<computer_name>\<filestream_share_name> already exists. The share \\<VNN>\<filestream_share_name> is created.

  • You enable FILESTREAM for file i/o streaming access on a primary replica that has availability groups. The following shares are created:

    1. \\<computer_name>\<filestream_share_name>.
    2. \\<VNN1>\<filestream_share_name> for availability group 1.
    3. \\<VNN2>\<filestream_share_name> for availability group 2.

These VNN-scoped shares are also propagated to all secondary replicas.

When the database that contains FILESTREAM or FileTable data belongs to an Always On availability group:

  • The FILESTREAM and FileTable functions accept or return virtual network names (VNNs) instead of computer names. For more information about these functions, see FILESTREAM and FileTable Functions (Transact-SQL).

  • All access to FILESTREAM or FileTable data through the file system APIs should use VNNs instead of computer names.

If your application tries to access the share by using the computer name in the format \\<computer_name>\<filestream_share_name> when the database is part of an availability group, then an error is raised.

If your application tries to access the share by using a VNN-scoped path when the database isn't part of an availability group, then the request may succeed. In this case, the virtual network name is resolved to the computer name. However this usage is strongly discouraged, since the VNN-scoped path stops working if the availability group is dropped.