redis在.Net程序中使用

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:重新设置访问密码即可
posted @ 2016-10-21 13:27  孤狼灬  阅读(488)  评论(0编辑  收藏  举报