娃哈哈好喝-真的!
技术够用就行,吃好喝好睡好!

Redis集群Hash槽分配异常解决办法

Redis集群Hash槽分配异常 CLUSTERDOWN Hash slot not served的解决方式

集群信息

10.20.20.161
10.20.20.162
10.20.20.163

redis多节点集群随便使用一台客户端连接,使用set命令时会出现类似这样的错误

10.20.20.161:6379> set e 500
(error) CLUSTERDOWN Hash slot not served

首先查看一下集群节点是否正常

10.20.20.161:6379> cluster nodes
54aeaa84d79bc63e66b971d3cb32ee09fc0aa1d2 :6379@16379 myself,master - 0 0 0 connected

再看一下集群状态

10.20.20.161:6379> cluster info
cluster_state:fail
cluster_slots_assigned:0
cluster_slots_ok:0
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:1
cluster_size:0
cluster_current_epoch:0
cluster_my_epoch:0
cluster_stats_messages_sent:0
cluster_stats_messages_received:0

集群状态异常,集群之间节点没有互相发现,需要在另外几个节点上执行下面的命令加入到本集群中

10.20.20.162:6379> cluster meet 10.20.20.161 6379
10.20.20.163:6379> cluster meet 10.20.20.161 6379

执行完再查看节点信息

10.20.20.161:6379> cluster nodes
c2750f62ccedb7a880cc57206c1feefc94f5c447 10.20.20.163:6379@16379 master - 0 1639410795898 0 connected
54aeaa84d79bc63e66b971d3cb32ee09fc0aa1d2 10.20.20.162:6379@16379 master - 0 1639410794885 1 connected
c63e66b971d3cb34c647557a880cc57206c1feef 10.20.20.161:6379@16379 myself,master - 0 1639410795000 2 connected

再查看集群信息

10.20.20.161:6379> cluster info
cluster_state:fail
cluster_slots_assigned:0
cluster_slots_ok:0
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:3
cluster_size:0
cluster_current_epoch:2
cluster_my_epoch:2
cluster_stats_messages_ping_sent:26
cluster_stats_messages_pong_sent:30
cluster_stats_messages_meet_sent:3
cluster_stats_messages_sent:59
cluster_stats_messages_ping_received:30
cluster_stats_messages_pong_received:29
cluster_stats_messages_received:59

集群还是失败的,执行一下修复命令

[root@centos bin]# ./redis-cli --cluster fix 10.20.20.161:6379

等运行完之后再去查看集群状态

10.20.20.161:6379> cluster info
cluster_state:ok
cluster_slots_assigned:0
cluster_slots_ok:0
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:3
cluster_size:0
cluster_current_epoch:2
cluster_my_epoch:2
cluster_stats_messages_ping_sent:26
cluster_stats_messages_pong_sent:30
cluster_stats_messages_meet_sent:3
cluster_stats_messages_sent:59
cluster_stats_messages_ping_received:30
cluster_stats_messages_pong_received:29
cluster_stats_messages_received:59

状态正常,测试一下set和get

127.0.0.1:6379> set e 500
-> Redirected to slot [15363] located at 10.20.20.163:6379
OK
10.20.20.163:6379> get e
"500"
10.20.20.163:6379>

done

赞(0)
未经允许不得转载:娃哈哈好喝 » Redis集群Hash槽分配异常解决办法
分享到: 更多 (0)