zoukankan      html  css  js  c++  java
  • ServiceStack.Redis连接阿里云redis服务时使用连接池出现的(密码验证)问题

    创建连接池

    复制代码
     1      private static PooledRedisClientManager prcm = CreateManager(new string[] { "password@ip:port" }, new string[] { "password@ip:port" });
     2         public static PooledRedisClientManager CreateManager(string[] readWriteHosts, string[] readOnlyHosts)
     3         {
     4            //支持读写分离,均衡负载
     5             return new PooledRedisClientManager(readWriteHosts, readOnlyHosts, new RedisClientManagerConfig
     6             {
     7                 MaxWritePoolSize = 5,//“写”链接池链接数
     8                 MaxReadPoolSize = 5,//“读”链接池链接数
     9                 AutoStart = true,
    10                 DefaultDb = 0
    11             });
    12         }
    复制代码

    调用

    using (IRedisClient Redis = prcm.GetClient()) {
                    Redis.Set(key, value, dateTime);
                }

    这是会出现错误  command role not support for your account

    解决方案:

    在创建连接池的时候 加入这样一句代码  RedisConfig.VerifyMasterConnections = false;

    复制代码
     1 public static PooledRedisClientManager CreateManager(string[] readWriteHosts, string[] readOnlyHosts)
     2         {
     3             RedisConfig.VerifyMasterConnections = false;
     4             //支持读写分离,均衡负载
     5             return new PooledRedisClientManager(readWriteHosts, readOnlyHosts, new RedisClientManagerConfig
     6             {
     7                 MaxWritePoolSize = 5,//“写”链接池链接数
     8                 MaxReadPoolSize = 5,//“读”链接池链接数
     9                 AutoStart = true,
    10                 DefaultDb = 0
    11             });
    12         }
    复制代码

    问题解决!

    另外一个错误

    NOAUTH Authentication required

    解决方法

    private static PooledRedisClientManager prcm = CreateManager(new string[] { "password@ip:port" }, new string[] { "password@ip:port" });

  • 相关阅读:
    实现用户信息的增删改-mongoose数据库操作
    gulp使用流程及常用插件
    Js面向对象动态添加标签页,Tab栏切换
    类似淘宝侧边栏jq代码编写
    jQuery选择器
    jQuery-突出显示案例
    隔行变色加高亮显示
    ajax请求到后台
    LOOK OUT THE HOLE!
    应用keyup监测输入框兼容IE处理
  • 原文地址:https://www.cnblogs.com/kevin860/p/11267468.html
Copyright © 2011-2022 走看看