一.原理

和Memcached类似,采用C/S的模式,在 server 端启动服务进程,在启动时可以指定监听的 ip,自己的端口号,所使用的内存大小等几个关键参数。一旦启动,服务就一直处于可用状态。

二.常用命令

1.Start-CacheCluster
   2.Stop-CacheCluster
   3.Get-CacheHost 可以得到所有的Cache主机
   4.Start-CacheHost GFTEST:22233 启动一个Cache主机
   5.Stop-CacheHost GFTEST:22233 停止一个Cache主机
   6.Get-CacheAllowedClientAccounts 得到授权的用户.
   7.Grant-CacheAllowedClientAccount NetworkService 给用户授权
   8.Export-CacheClusterConfig -File E:\VelocityCache\ClusterConfig.xml
   9.Import-CacheClusterConfig -File E:\VelocityCache\ClusterConfig.xml

10.Get-CacheStatistics default 得到默认或当前cache的详细统计结果。

三.安全设置

在开发机上可以设置授权用户如下:
    <securityProperties mode="None" protectionLevel="None">
                <authorization>
                    <allow users="administrator" />
                    <allow users="NetworkService" />
                </authorization>
    </securityProperties>

但放服务器上不工作,可能因为服务器的种种安全设置,没仔细找到具体原因。知道要让程序顺利访问cache, 最好将securityProperties 的模式设置为None。

<securityProperties mode="None" protectionLevel="None">
    </securityProperties>

四.多个node

在多台机器上装cache服务时,第一台服务器叫做lead host,用来创建一个new cluster,其他服务器joint就可以了。

通过get-cachehost命令可以查到现在工作中的host列表。

PS C:\Windows\System32\WindowsPowerShell\v1.0\Modules\DistributedCacheAdministration> get-cachehost

HostName : CachePort      Service Name            Service Status Version Info
--------------------      ------------            -------------- ------------
DesktopPc:22233        AppFabricCachingService UP             1 [1,1][1,1]
TESTServer:22233      AppFabricCachingService UP             1 [1,1][1,1]

五.配置文件不能访问导致的cache服务瘫痪(crash), 报出的异常是:An error occurred loading a configuration file: The network path was not found.
平时配置文件都能访问,cache 服务也工作正常,不知怎的,每隔些日子,就会因为这个原因瘫痪一下,因为服务器放在机房,不知道是否是被机房所害.

AppFabric Caching service crashed with exception {Microsoft.ApplicationServer.Caching.DataCacheException: ErrorCode<ERRCMS0001>:SubStatus<ES0001>:Error while trying to load configuration: An error occurred loading a configuration file: The network path was not found.
 (//companywebserver/AppFabricConfig/ClusterConfig.xml) ---> System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: The network path was not found.
 (//companywebserver/AppFabricConfig/ClusterConfig.xml) ---> System.IO.IOException: The network path was not found.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at System.Configuration.Internal.InternalConfigHost.System.Configuration.Internal.IInternalConfigHost.OpenStreamForRead(String streamName, Boolean assertPermissions)
   at System.Configuration.BaseConfigurationRecord.InitConfigFromFile()
   --- End of inner exception stack trace ---
   at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
   at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
   at System.Configuration.Configuration..ctor(String locationSubPath, Type typeConfigHost, Object[] hostInitConfigurationParams)
   at System.Configuration.ClientConfigurationHost.OpenExeConfiguration(ConfigurationFileMap fileMap, Boolean isMachine, ConfigurationUserLevel userLevel, String exePath)
   at Microsoft.ApplicationServer.Caching.GlobalConfigReader.LoadConfigurationFromFile(String path, Boolean throwIfSectionNotFound)
   --- End of inner exception stack trace ---
   at Microsoft.ApplicationServer.Caching.ConfigFile.ThrowException(Exception e)
   at Microsoft.ApplicationServer.Caching.GlobalConfigReader.LoadConfigurationFromFile(String path, Boolean throwIfSectionNotFound)
   at Microsoft.ApplicationServer.Caching.ClusterConfigurationFactory.GetReader(ClusterConfigElement cs)
   at Microsoft.ApplicationServer.Caching.ServiceConfigurationManager..ctor()
   at Microsoft.ApplicationServer.Caching.VelocityWindowsService.StartService(Boolean deleteTKT)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()}. Check debug log for more information

查了一下, 分析说很可能是dns服务器的问题, 我测试了一下果然如此, 又上网搜了搜北京dns (202.96.199.133 202.96.0.133 202.106.0.20 202.106.148.1 202.106.0.20 202.106.196.115) , 结果都不行, 不知道怎么回事, 总之不太相信这个结果.

暂时的解决办法是修改host文件,将companywebserver 和127.0.0.1绑定,这样读cache时不出本机,观察几天看能否解决这个问题,但这样一来,多点cache集群就做不成了, 或许可以用内网ip代替127.0.0.1来解决这个问题。

最后找到google有个公共dns: 8.8.8.8, 还找到个河北的, 202.99.168.8, 也可以用, 先这样观察几天吧!

Hosts文件位置
C:\Windows\System32\drivers\etc

Hosts文件
http://zh.wikipedia.org/wiki/Hosts%E6%96%87%E4%BB%B6\

六.重起cache服务到真正可用的gap

经过测试, cache服务重起后, 已经是started状态了, 但程序一连还是不成, 也就是此时cache还没有ready, 等大概2-18分钟就好了, 没找到ms官方的解释, 纯粹个人经验.

七.参考

使用微软分布式缓存服务Velocity(Windows Server AppFabric Caching Service)

http://www.cnblogs.com/mlj322/archive/2010/04/05/1704624.html

The Network Path was not Found - Server 2008

http://social.technet.microsoft.com/Forums/zh-CN/winserverGP/thread/280e5e43-b6d1-461d-950d-de4a49b81632

八.一个完整的配置文件 ClusterConfig.xml

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <section name="dataCache" type="Microsoft.ApplicationServer.Caching.DataCacheSection, Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </configSections>
    <dataCache size="Small">
        <caches>
            <cache consistency="StrongConsistency" name="default">
                <policy>
                    <eviction type="Lru" />
                    <expiration defaultTTL="10" isExpirable="false" />
                </policy>
            </cache>
        </caches>
        <hosts>
            <host replicationPort="22236" arbitrationPort="22235" clusterPort="22234"
                hostId="883100817" size="4093" leadHost="true" account="CompanyWEBSERVER\AppFabricUser"
                cacheHostName="AppFabricCachingService" name="CompanyWEBSERVER"
                cachePort="22233" />
        </hosts>
        <advancedProperties>
            <securityProperties mode="None" protectionLevel="None">
            </securityProperties>
        </advancedProperties>
    </dataCache>
</configuration>

Appfabric caching 使用半年总结相关推荐

  1. Windows Server AppFabric Caching

    这套 AppFabric Caching 比我用过的 memcached 复杂多了,MSDN有一篇文章进行介绍Introduction to Caching with Windows Server A ...

  2. AppFabric Caching Admin Tool

    最近试用了一下MS的AppFabric的分布是缓存(Velocity),发现了一个不错的可视化配置工具挺有用,先介绍给大家,后续再详细介绍. http://mdcadmintool.codeplex. ...

  3. Windows Server AppFabric Caching支持大数据量的配置

    Memcache支持的数据量大小为1M,最新版本可以通过配置调整突破1M(参看http://www.cnblogs.com/shanyou/archive/2010/02/01/1661271.htm ...

  4. Windows Server AppFabric Beta 2 for For Vistual Studio 2010已经发布

    Windows Server AppFabric Beta 2 For Vistual Studio 2010/.NET Framework 4.0已经发布了,参看EndPonit上的博客文章http ...

  5. Windows Server AppFabric 缓存容量规划指南

    此主题尚未评级 - 评价此主题 Jason Roth.Rama Ramani.Jaime Alva Bravo 2011 年 3 月 本白皮书为 Windows Server AppFabric 缓存 ...

  6. 【转载】6种.net分布式缓存解决方案

    1. 使用内置ASP.NET Cache (System.Web.Caching) : https://msdn.microsoft.com/en-us/library/system.web.cach ...

  7. 现实世界的Windows Azure:就Metanga采访MetraTech公司CEO,Scott Swartz先生

    MSDN:和我们谈谈你们公司和你们的解决方案. Swartz:我在1998年开始创办MetraTech,Metanga是我们的一款新的软件即服务(SaaS)产品.Metanga是一款多租户的SaaS计 ...

  8. 分布式缓存中间件:Redis

    Redis 是一个高性能的key-value数据库. redis的出现,很大程度补偿了memcached这类key-value存储的不足,在部 分场合可以对关系数据库起到很好的补充作用.它提供了Pyt ...

  9. Windows Azure AppFabric概述

    公告    :本博客为微软云计算中文博客  的镜像博客.   部分文章因为博客兼容性问题  ,会影响阅读体验  .如遇此情况,请访问  原博客    . Windows Azure AppFabric ...

最新文章

  1. SDL2 自建对话框
  2. rails开发随手记-0
  3. Java,JavaFX的流畅设计风格滑块
  4. 动态Java代码注入
  5. 区块链开发公司谈区块链与大数据的关系
  6. java数据结构之快速排序
  7. DevExpress xtraTabbedMdiManager控件双击关闭MDI标签页
  8. 独立站现在好不好做?个人适合做跨境电商独立站吗?
  9. 文本分类(2)-基于传统机器学习方法进行文本分类
  10. 所在位置 行:1 字符: 1+ cnpm i+ ~~~~ + CategoryInfo : SecurityError: (:) [],PSSecurityExcepti
  11. python 接入百度地图数据包下载_Python爬虫-利用百度地图API接口爬取数据并保存至MySQL数据库...
  12. 漫谈阿里那些大数据技术,大数据学习者必看
  13. 对待二手车过户要理性
  14. 详解Qt字体设置 (QFont)
  15. MVP+Dragger2+Rxjava2+Retrofit+OKhttp进行开发。
  16. samba服务器介绍
  17. 如何理解照片后期处理
  18. linux服务开机自启动
  19. R代码学习(1)——算术运算、关系运算、逻辑运算
  20. 项目中如何修改element-ui的默认样式

热门文章

  1. Keil C251V557破解
  2. 深扒互联网大佬高考往事,状元辈出,马云数学1分被DISS
  3. 华为ensp常用简单命令(一)
  4. 1+X云计算平台运维与开发认证 资源
  5. 机器人导论(第四版)学习笔记——第二章
  6. FFmpeg 4.0.2编码YUV序列为H264视频文件
  7. 算法 队列问题(浙大数据结构视频作业)
  8. 统计系列(一)统计基础
  9. Uber上市第二日股价继续大跌 市值缩水至622亿美元
  10. 在Windows 10中HP 5100打印出来是黑方框的解决方法