redis在.Net程序中使用
摘要:1.设置访问密码configsetrequirepass1234562.连接redis服务器privatestaticstringredisHost=ConfigHelper.GetAppSetting("redisHost");privatestaticintredisPort=ConfigHelper.GetAppSetting("redisPort").AsInt32();privatest
1.设置访问密码
config set requirepass 123456
2.连接redis服务器
private static string redisHost = ConfigHelper.GetAppSetting("redisHost");
private static int redisPort = ConfigHelper.GetAppSetting("redisPort").AsInt32();
private static string redisPass = ConfigHelper.GetAppSetting("redisPass");
private static RedisClient redis = new RedisClient(redisHost, redisPort, redisPass);
可能遇到的问题:
1.如果报如下错误:
DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode
可能就是因为没有设置访问密码
2.如果无法连接redis服务器,可能是因为端口的问题:
/sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEPT
如果都设置好了还报错,稍等一会即可
3.NOAUTH Authentication required.
auth 123456:重新设置访问密码即可
免责声明:文章转载自《redis在.Net程序中使用》仅用于学习参考。如对内容有疑问,请及时联系本站处理。
上篇springboot + spring cloudeurekamac 安装配置 tomcat下篇
宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=
在上一篇博客----Redis详解(八)------ 主从复制,我们简单介绍了Redis的主从架构,但是这种主从架构存在一个问题,当主服务器宕机,从服务器不能够自动切换成主服务器,为了解决这个问题,我们又介绍了哨兵模式,本篇博客我们继续深入的介绍一下这种模式. 1、架构图 2、服务器列表 3、搭建主从模式 ①、主要配置项 主服务器(上图的Node1)配...