部署在不同城市文件拷贝的缓存技术

部署在不同城市文件拷贝缓存技术

不同城市文件缓存又称Branch Cache,是Windows下的一种缓存技术。

简单的讲,如果你的公司有在两个或者两个以上的分公司分别在不同城市,在这个时候,如果城市A的不同员工要多次访问城市B的文件,这个时候最好开启缓存。

缓存开启后起到的效果是,在城市A的文件服务器会自动在本地做一个备份,当有第二个用户请求拷贝时,服务器或者PC会将请求自动指向本地备份的文件,这样就不用经过互联网再次请求拷贝了,从而也降低了拷贝文件所需的时间。

在部署的时候有两种模式,一种是Hosted mode,就是说你缓存的文件全部储存在你所在城市的服务器;另一种则是Distributed cache mode,就是说你缓存的文件储存在你相邻的计算机中,如果有计算机请求远端服务器文件,首先会在网内进行广播,如果发现本地有备份,则直接向相邻计算机请求拷贝。

所有的模式均只在你的服务器或者PC开启的时候才能正常使用,这里其实不难看出如果你采用Hosted Mode将比Distribute Mode拥有更高的可用性。

要求:你的计算机必须是Windows 7 Enterprise或者Ultimate以上的版本,如果你希望用组策略部署,你还要拥有一个Windows Server 2008 R2或以上。

另外Hosted Mode需要Windows Server 2008 有SSL Certificate

如果你有Windows Server 2008 R2,你想用GPO来部署Branch Cache功能。
你需要打开组策略编辑器,找到以下:
Computer configuration >> Administrative templates >>Network >> Branch Cache
一共有5个相关选项:
Turn on BranchCache: Enable/Disable
Set BrancheCache Distributed Cache Mode: Enable/Disable
Set BranchCache Hosted Cache Mode: Specify server
Configure BrancheCache for Network files: Latency value Default 80
Set percentage of disk space used for client computer cache: Default 5%
以上内容需要根据自己公司的实际需求来调试。
如果你利用GPO,你还需要将试防火墙的设置成如下:
Inbound & outbound TCP Port 80 (distributed and hosted mode)
Distributed mode:
Inbound & outbound UDP Port 3702
Hosted mode:
Outbound TCP port 43

同时,你也可以选择用Netsh commands来调试。
显示当前branche是否开启
netsh branchcache show status
设置Hosted Mode
netsh branchcache set service mode=hostedclient location=servername.com
设置distributed cache Mode
netsh branchcache set service mode=distributed
在利用command部署时,命令行会自动开启防火墙端口
设置缓存大小:
netsh branchcache set cachesize=100000000
netsh branchcache set cachesize=25 percent=true
查看缓存状态:
netsh branchcache show localcache
你同时可以将latency设置为0来测试缓存是否开启:
netsh branchcache smb set latency 0
当然如果测试功能正常后,你可以根据实际情况来设置缓存大小。