我可以使用专用(单独)群集进行appfabric会话存储吗?

时间:2013-06-03 04:25:02

标签: session-state appfabric appfabric-cache

我们不希望为此使用缓存集群,因为截至目前,我们在缓存集群上面临一些稳定性问题,因此它们处于持续维护状态(完全是我们的错)。我们可以使用专用集群进行会话存储吗? (忘记群集,至少有一个主机?)

在同一个应用程序中使用两个集群,一个用于缓存,一个用于会话存储,这些集群位于同一个配置文件中。

我的做法是对的吗?任何帮助,将不胜感激。谢谢!

感谢@Cyber​​Max,我能够设置这个环境。但是,当我运行页面时,我得到一个错误:

  

无法读取配置节'dataCacheClients',因为它缺少节声明

500 internal server error

这是我的配置:

<configuration>
  <configSections>
<!-- required to read the <dataCacheClient> element -->
<section name="dataCacheClient"     type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      allowLocation="true"
      allowDefinition="Everywhere"/>

 </configSections>

  <system.web>
<compilation debug="true" targetFramework="4.0">
  <assemblies>
    <add assembly="Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    <add assembly="Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </assemblies>
</compilation>
<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
  <providers>
    <!--specify the named cache for session data-->
    <add name="AppFabricCacheSessionStoreProvider"  type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider" cacheName="sample-cache" dataCacheClientName="VirtualCache"/>
  </providers>
</sessionState>

 </system.web>


 <dataCacheClients>
   <dataCacheClient name="serverCache">
     <localCache isEnabled="false" sync="NotificationBased" objectCount="100000"/>
     <clientNotification pollInterval="5"/>
     <!--cache host(s)-->
     <hosts>
       <host name="!@13452662.gf.com" cachePort="22233"/>
       <host name="!@13452663.gf.com" cachePort="22233"/>
     </hosts>
     <securityProperties mode="None" protectionLevel="None" />
     <transportProperties maxBufferPoolSize="2147483647" maxBufferSize="2147483647" channelInitializationTimeout="60000" receiveTimeout="900000"/>
    </dataCacheClient>

   <dataCacheClient name="VirtualCache">
     <localCache isEnabled="false" sync="NotificationBased" objectCount="100000"/>
     <clientNotification pollInterval="5"/>
    <hosts>
       <host name="localhost" cachePort="22233"/>
       <host name="localhost" cachePort="22234"/>
       <host name="localhost" cachePort="22235"/>
       <host name="localhost" cachePort="22236"/>
    </hosts>
   </dataCacheClient>
</dataCacheClients>
</configuration>

编辑:

dataCacheClient更改为dataCacheClients会导致此错误:

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

 Parser Error Message: Web configuration error. Check your Web.config file, or revert to     the last working version.dataCacheClientName

Source Error: 



Line 31:       <providers>
Line 32:         <!--specify the named cache for session data-->
Line 33:         <add name="AppFabricCacheSessionStoreProvider" type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider" cacheName="sample-cache" dataCacheClientName="VirtualCache"/>
Line 34:       </providers>
Line 35:     </sessionState>

1 个答案:

答案 0 :(得分:1)

是的,你可以。

配置AppFabric Sesison State Provider时,您可以提供dataCacheClient名称。它是dataCacheClients配置部分中使用的dataCacheClient部分的名称。默认情况下,提供程序将使用名为“default”的dataCacheClient部分。

,例如

<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider" compressionEnabled="false">
      <providers>
        <add name="AppFabricCacheSessionStoreProvider"
             type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache"
             cacheName="default"
             useBlobMode="true"
             dataCacheClientName="dataCacheClient1"/>
      </providers>
    </sessionState>

您可以在configuraiton文件中拥有多个dataCacheClient。

 <dataCacheClients>
    <dataCacheClient name="dataCacheClient1">
      <hosts>
        <host name="CacheServer1" cachePort="22233" />
      </hosts>
    </dataCacheClient>
    <dataCacheClient name="dataCacheClient2">
      <hosts>
        <host name="CacheServer1" cachePort="22233" />
      </hosts>
    </dataCacheClient>
  </dataCacheClients>

因此,拥有多个缓存集群没有问题。

修改:

这里是AppFabric 1.0的配置

<?xml version="1.0" encoding="utf-8" ?>
<configuration>

  <!--configSections must be the FIRST element -->
  <configSections>
     <!-- required to read the <dataCacheClient> element -->
     <section name="dataCacheClient"
         type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,
            Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0, 
            Culture=neutral, PublicKeyToken=31bf3856ad364e35"
         allowLocation="true"
         allowDefinition="Everywhere"/>
  </configSections>

  <!-- cache client -->
  <dataCacheClient>    
    <!-- cache host(s) -->
    <hosts>
      <host
         name="CacheServer1"
         cachePort="22233"/>
    </hosts>
  </dataCacheClient>

  <system.web>
    <sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
      <providers>
        <!-- specify the named cache for session data -->
        <add 
          name="AppFabricCacheSessionStoreProvider" 
          type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider" 
          cacheName="NamedCache1"
          sharedId="SharedApp"/>
      </providers>
    </sessionState>
  </system.web>
</configuration>

这里是AppFabric 1.1的配置

<?xml version="1.0"?>

<configuration>
  <configSections>
    <section name="dataCacheClients"
             type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core"
             allowLocation="true" allowDefinition="Everywhere"/>
  </configSections>

  <dataCacheClients>
    <dataCacheClient name="default" channelOpenTimeout="10000">
      <hosts>
        <host name="CacheServer1" cachePort="22233" />
      </hosts>
    </dataCacheClient>
  </dataCacheClients>

  <system.web>
    <sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider" compressionEnabled="false">
      <providers>
        <add name="AppFabricCacheSessionStoreProvider"
             type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache"
             cacheName="default"
             useBlobMode="true"
             dataCacheClientName="default"/>
      </providers>
    </sessionState>
  </system.web>
</configuration>