跳到主要内容

在 CIFS 服务器上配置 BranchCache

可配置 BranchCache,以便为每个共享提供 BranchCache 服务。或者,可配置 BranchCache 以自动启用所有 SMB 共享上的高速缓存。

关于本任务

可在 SVM 上配置 BranchCache。

  • 如果要为 CIFS 服务器上所有 SMB 共享中的所有内容提供高速缓存服务,可以创建所有共享 BranchCache 配置。

  • 如果要为 CIFS 服务器上选定 SMB 共享中的内容提供高速缓存服务,可以创建每个共享 BranchCache 配置。

配置 BranchCache 时,必须指定以下参数:

必需参数描述
SVM 名称每个 SVM 上已配置 BranchCache。必须指定要配置 BranchCache 服务的支持 CIFS 的 SVM
哈希存储路径BranchCache 哈希已存储在 SVM 卷的常规文件中。必须指定要 ONTAP 存储哈希数据的现有目录路径。

BranchCache 哈希路径必须可读写。不允许使用只读路径,例如快照目录。可在包含其他数据的卷中存储哈希数据,或创建单独的卷以存储哈希数据。

如果该 SVMSVM 灾难恢复源,则哈希路径无法在根卷上。这是因为根卷不会复制到灾难恢复目标。

哈希路径可包含空格和任何有效的文件名字符。

可选择指定以下参数:

可选参数描述
支持版本ONTAP 支持 BranchCache 1 和 2。可启用版本 1、版本 2 或同时启用两个版本。默认同时启用两个版本。
哈希存储最大大小可指定用于哈希数据存储的大小。如果哈希数据超过此值,ONTAP 则会删除旧哈希,而为新哈希留出空间。哈希存储的默认大小为 1 GB。

如果哈希不以过度积极的方式丢弃,则 BranchCache 会更有效执行。如果确定常因哈希存储已满而将哈希丢弃,可通过修改 BranchCache 配置增加哈希存储大小。

服务器密钥可指定 BranchCache 服务使用的服务器密钥以防止客户端模拟 BranchCache 服务器。如果未指定服务器密钥,则将在创建 BranchCache 配置时随机生成。

可以将此服务器密钥指定为一个特定值,这样,如果多台服务器为相同的文件提供 BranchCache 数据,则客户端便可使用共享这一服务器密钥的任一服务器中的哈希。如果此服务器密钥包含空格,则必须使用引号将服务器密钥引起来。

运行模式默认为每个共享启用 BranchCache。
  • 要在为每个共享启用 BranchCache 的位置创建 BranchCache 配置,可不指定此可选参数,或指定

    per-share .
  • 要在所有共享上自动启用 BranchCache,必须将运行模式设置为

    all-shares .
  1. 根据需要启用 SMB 2.1 和 3.0:
    1. 将权限级别设置为高级:set -privilege advanced
    2. 检查已配置的 SVM SMB 设置,以确定是否已启用所需的全部 SMB 版本:vserver cifs options show -vserver vserver_name
    3. 如有必要,请启用 SMB 2.1:vserver cifs options modify -vserver vserver_name -smb2-enabled true

      命令将同时启用 SMB 2.0 和 SMB 2.1。
    4. 如有必要,请启用 SMB 3.0:vserver cifs options modify -vserver vserver_name -smb3-enabled true
    5. 恢复为管理员权限级别:set -privilege admin
  2. 配置 BranchCache:vserver cifs branchcache create -vserver vserver_name -hash-store-path path [-hash-store-max-size {integer[KB|MB|GB|TB|PB]}] [-versions {v1-enable|v2-enable|enable-all] [-server-key text] -operating-mode {per-share|all-shares}

    指定的哈希存储路径必须存在,并且必须位于由 SVM 管理的卷。该路径还必须位于可读写卷。如果路径为只读路径或路径不存在,则该命令将失败。

    如果要将相同的服务器密钥用于其他 SVM BranchCache 配置,请记录输入的服务器密钥的值。显示关于 BranchCache 配置的信息时,服务器密钥不会显示。

  3. 验证 BranchCache 配置是否正确:vserver cifs branchcache show -vserver vserver_name

示例

以下命令可同时验证 SMB 2.1 和 3.0 是否启用,并配置 BranchCache 以自动启用 SVM vs1 上所有 SMB 共享的高速缓存:

cluster1::> set -privilege advanced
Warning: These advanced commands are potentially dangerous; use them
only when directed to do so by technical support personnel.
Do you wish to continue? (y or n): y

cluster1::*> vserver cifs options show -vserver vs1 -fields smb2-enabled,smb3-enabled
vserver smb2-enabled smb3-enabled
------- ------------ ------------
vs1 true true


cluster1::*> set -privilege admin

cluster1::> vserver cifs branchcache create -vserver vs1 -hash-store-path /
hash_data -hash-store-max-size 20GB -versions enable-all -server-key "my server key" -operating-mode all-shares

cluster1::> vserver cifs branchcache show -vserver vs1

Vserver: vs1
Supported BranchCache Versions: enable_all
Path to Hash Store: /hash_data
Maximum Size of the Hash Store: 20GB
Encryption Key Used to Secure the Hashes: -
CIFS BranchCache Operating Modes: all_shares

以下命令可同时验证 SMB 2.1 和 3.0 是否启用,并配置 BranchCache 以启用 SVM vs1 上的每个共享的高速缓存,并验证 BranchCache 配置:

cluster1::> set -privilege advanced
Warning: These advanced commands are potentially dangerous; use them
only when directed to do so by technical support personnel.
Do you wish to continue? (y or n): y

cluster1::*> vserver cifs options show -vserver vs1 -fields smb2-enabled,smb3-enabled
vserver smb2-enabled smb3-enabled
------- ------------ ------------
vs1 true true

cluster1::*> set -privilege admin

cluster1::> vserver cifs branchcache create -vserver vs1 -hash-store-path /
hash_data -hash-store-max-size 20GB -versions enable-all -server-key "my server key"

cluster1::> vserver cifs branchcache show -vserver vs1

Vserver: vs1
Supported BranchCache Versions: enable_all
Path to Hash Store: /hash_data
Maximum Size of the Hash Store: 20GB
Encryption Key Used to Secure the Hashes: -
CIFS BranchCache Operating Modes: per_share