redis cluster command

1.列出集群中的slot分配

cluster slots

1) 1) (integer) 10923
   2) (integer) 16383
   3) 1) "127.0.0.1"
      2) (integer) 7002
   4) 1) "127.0.0.1"
      2) (integer) 7005
2) 1) (integer) 5461
   2) (integer) 10922
   3) 1) "127.0.0.1"
      2) (integer) 7001
   4) 1) "127.0.0.1"
      2) (integer) 7004
3) 1) (integer) 0
   2) (integer) 5460
   3) 1) "127.0.0.1"
      2) (integer) 7000
   4) 1) "127.0.0.1"
      2) (integer) 7003

2.列出集群中的节点

Cluster nodes

10332dcc956ed930789572f431d25730b9341ba9 127.0.0.1:7002 master - 0 1428550980814 3 connected 10923-16383
e956d0f4cbe4a0ee688d7d561088d8878738274b 127.0.0.1:7001 master - 0 1428550982315 2 connected 5461-10922
88a78c882554a45039967becd489c27b120cf8ff 127.0.0.1:7000 myself,master - 0 0 1 connected 0-5460
a86e9770d1783edc1ed3753a4b784c1a41126cdc 127.0.0.1:7005 slave 10332dcc956ed930789572f431d25730b9341ba9 0 1428550982815 6 connected
130e772599b1f0fce606f58794ebd962d0ab8963 127.0.0.1:7003 slave 88a78c882554a45039967becd489c27b120cf8ff 0 1428550982815 4 connected
dfa1b2444a1c3200a9d1c9be858b47f0e3756f3f 127.0.0.1:7004 slave e956d0f4cbe4a0ee688d7d561088d8878738274b 0 1428550981315 5 connected

3.查看集群信息

cluster info

cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:1
cluster_stats_messages_sent:291518
cluster_stats_messages_received:291518

4.查询key的keyslot值

cluster keyslot “hello”

127.0.0.1:7000> cluster keyslot hello
(integer) 866

5.执行failover

CLUSTER FAILOVER [FORCE|TAKEOVER]

FORCE 直接进入第4步,特别适用于主挂了的情况,特别注意,主服务要数量能够达到failover最低值。
TAKEOVER 慎用,适用于FOECE搞不定的情况。

failover过程:

1.The slave tells the master to stop processing queries from clients.从告诉主停止处理客户端请求。
2.The master replies to the slave with the current replication offset.主服务告诉从服务现在的复制偏移量(就是复制到哪了,主会记录每个从的复制进度)。
3.The slave waits for the replication offset to match on its side, to make sure it processed all the data from the slave before to continue.从服务根据主服务返回的复制偏移量和自己保存的值对比,确保数据一致。
4.The slave starts a failover, obtains a new configuration epoch from the majority of the masters, and broadcast the new configuration.启动failover就,获取投票epoch,广播配置。 
5.The old master receives the configuration update: unblocks its clients and start replying with redirection messages so that they'll continue the chat with the new master.旧主收到配置更新,下台。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值