2881099 / csredis

.NET Core or .NET Framework 4.0+ client for Redis and Redis Sentinel (2.8) and Cluster. Includes both synchronous and asynchronous clients.
MIT License
2k stars 414 forks source link

状态不可用,等待后台检查程序恢复方可使用 #229

Open XuMengEnEli opened 4 years ago

XuMengEnEli commented 4 years ago

您好:我的连接串是:10.27.26.59:6379,allowadmin=true,preheat=1 。使用哨兵模式下报错如下: 请问这是啥情况?

【255.255.255.255:19736/0】恢复检查时间:2019/12/27 10:47:45 [10:47:40]:System.Exception: Redis Sentinel Master is switching:Connection was not opened at CSRedis.CSRedisClient.GetAndExecute[T](RedisClientPool pool, Func2 handler, Int32 jump, Int32 errtimes) at CSRedis.CSRedisClient.ExecuteScalar[T](String key, Func3 hander) at CSRedis.CSRedisClient.HSet(String key, String field, Object value) at RedisHelper1.HSet(String key, String field, Object value) at ReadyFly.Web.Application.LoginService.SaveUserInfoRedis(UserInfoModel userInfo) in D:\Project\新建文件夹 (2)\20190107_ReadyFly_新航前准备网升级包_2019001(李晖,唐永雁)\附件\ReadyFly.Web\ReadyFly.Web\Application\LoginService.cs:line 378 at ReadyFly.Web.Application.LoginService.VerifyUserLoginAsync(Dictionary2 dic) in D:\Project\新建文件夹 (2)\20190107_ReadyFly_新航前准备网升级包_2019001(李晖,唐永雁)\附件\ReadyFly.Web\ReadyFly.Web\Application\LoginService.cs:line 45 Redis Sentinel Master is switching:Connection was not opened

2881099 commented 4 years ago

配置错了,哨兵不是这样,看 readme

XuMengEnEli commented 4 years ago

非常感谢您的回复,连接串改成:mymaster,allowadmin=true,preheat=1 后 又有新的报错:

【255.255.255.255:19736/0】恢复检查时间:2019/12/27 11:49:55 [11:49:50]:System.Exception: Redis Sentinel Master is switching:Connection was not opened at CSRedis.CSRedisClient.GetAndExecute[T](RedisClientPool pool, Func2 handler, Int32 jump, Int32 errtimes) at CSRedis.CSRedisClient.ExecuteScalar[T](String key, Func3 hander) at CSRedis.CSRedisClient.HSet(String key, String field, Object value) at RedisHelper1.HSet(String key, String field, Object value) at ReadyFly.Web.Application.LoginService.SaveUserInfoRedis(UserInfoModel userInfo) in D:\Project\新建文件夹 (2)\20190107_ReadyFly_新航前准备网升级包_2019001(李晖,唐永雁)\附件\ReadyFly.Web\ReadyFly.Web\Application\LoginService.cs:line 378 at ReadyFly.Web.Application.LoginService.VerifyUserLoginAsync(Dictionary2 dic) in D:\Project\新建文件夹 (2)\20190107_ReadyFly_新航前准备网升级包_2019001(李晖,唐永雁)\附件\ReadyFly.Web\ReadyFly.Web\Application\LoginService.cs:line 45 Redis Sentinel Master is switching:Connection was not opened

2881099 commented 4 years ago

哨兵节点,给了吗

XuMengEnEli commented 4 years ago

image

XuMengEnEli commented 4 years ago

请问这个哨兵连接未打开的报错是哨兵的配置文件设置的有问题么,配置文件:

port 26379 bind 127.0.0.1 sentinel myid 57ac1ecb2246136aff2ff728ba6c565ab13d522b sentinel monitor master 127.0.0.1 6380 1 sentinel down-after-milliseconds master 5000 sentinel config-epoch master 13

XuMengEnEli commented 4 years ago

这个是最新的报错: 【255.255.255.255:19736/0】恢复检查时间:2019/12/27 11:49:55 [11:49:50]:System.Exception: Redis Sentinel Master is switching:Connection was not opened at CSRedis.CSRedisClient.GetAndExecute[T](RedisClientPool pool, Func2 handler, Int32 jump, Int32 errtimes) at CSRedis.CSRedisClient.ExecuteScalar[T](String key, Func3 hander) at CSRedis.CSRedisClient.HSet(String key, String field, Object value) at RedisHelper1.HSet(String key, String field, Object value) at ReadyFly.Web.Application.LoginService.SaveUserInfoRedis(UserInfoModel userInfo) in D:\Project\新建文件夹 (2)\20190107_ReadyFly_新航前准备网升级包_2019001(李晖,唐永雁)\附件\ReadyFly.Web\ReadyFly.Web\Application\LoginService.cs:line 378 at ReadyFly.Web.Application.LoginService.VerifyUserLoginAsync(Dictionary2 dic) in D:\Project\新建文件夹 (2)\20190107_ReadyFly_新航前准备网升级包_2019001(李晖,唐永雁)\附件\ReadyFly.Web\ReadyFly.Web\Application\LoginService.cs:line 45 Redis Sentinel Master is switching:Connection was not opened

2881099 commented 4 years ago

去找下哨兵配置的资料,一般最少三个哨兵,你这个配置只有两个。

2881099 commented 4 years ago

先确定哨兵配置正确,并且连接任何一个哨兵,可以得到 mymaster 节点,执行命令:

SENTINEL get-master-addr-by-name mymaster

XuMengEnEli commented 4 years ago

已经搞定了。第一次玩Redis,非常非常感谢您的耐心回复。

wangjianblue commented 2 years ago

Hi 你好,想问一下这种情况怎么解决啊,我也遇到同样的问题Redis Sentinel Master is switching:Connection was not opened