【问题标题】:Microsoft.Web.RedisSessionStateProvider specify multiple IPMicrosoft.Web.RedisSessionStateProvider 指定多个 IP
【发布时间】:2019-04-27 22:58:30
【问题描述】:

我正在使用Microsoft.Web.RedisSessionStateProvider 在 Redis 上存储会话信息。
配置文件如下

<!--
      <add name="MySessionStateStore" 
        host = "127.0.0.1" [String]
        port = "" [number]
        accessKey = "" [String]
        ssl = "false" [true|false]
        throwOnError = "true" [true|false]
        retryTimeoutInMilliseconds = "5000" [number]
        databaseId = "0" [number]
        applicationName = "" [String]
        connectionTimeoutInMilliseconds = "5000" [number]
        operationTimeoutInMilliseconds = "1000" [number]
        connectionString = "<Valid StackExchange.Redis connection string>" [String]
        loggingClassName = "<Assembly qualified class name that contains logging method specified below>" [String]
        loggingMethodName = "<Logging method should be defined in loggingClass. It should be public, static, does not take any parameters and should have a return type of System.IO.TextWriter.>" [String]
      />

我能够读取集群上的写入会话信息。

我的集群有多个 IP 3 节点集群,其中一个主节点和另一个子节点。
我无法在 Web 配置文件中指定其他 IP 来处理故障转移情况。

假设我有一个包含 172.29.10.11、172.29.10.12、172.29.10.13 的集群,其中 172.29.10.11 是我的主节点,所以我将此 IP 放在 web.config 文件中

host = "172.29.10.11"

现在万一发生故障,0.12 或 .13 将成为我的主节点。
如何处理故障转移情况。

【问题讨论】:

    标签: c# asp.net redis session-state


    【解决方案1】:

    我找到了解决方案。我在这里发帖以防有人遇到类似问题。

    有两个参数可以指定IP:

    1. 主持人
    2. 连接字符串

    如果你使用连接字符串,你需要指定所有的属性值,例如

    <add name="MySessionStateStore" applicationName = "testapp" 
          type="Microsoft.Web.Redis.RedisSessionStateProvider" 
    connectionString ="172.29.10.11:6379,172.29.10.12:6379,172.29.10.13:6379,ssl=false,abortConnect=False" />
    

    【讨论】:

      猜你喜欢
      • 2019-08-29
      • 2013-04-13
      • 2018-11-12
      • 1970-01-01
      • 1970-01-01
      • 2020-05-13
      • 1970-01-01
      • 2012-01-22
      • 1970-01-01
      相关资源
      最近更新 更多