2019-04-11笔记—Redis集群

Redis Cluster介绍

Redis Cluster为Redis官方提供的一种分布式集群解决方案。它支持在线节点增加和减少。 集群中的节点角色可能是主,也可能是从,但需要保证每个主节点都要有对应的从节点, 这样保证了其高可用。

Redis Cluster采用了分布式系统的分片(分区)的思路,每个主节点为一个分片,这样也就意味着 存储的数据是分散在所有分片中的。当增加节点或删除主节点时,原存储在某个主节点中的数据 会自动再次分配到其他主节点。

在这里插入图片描述

如图,各节点间是相互通信的,通信端口为各节点Redis服务端口+10000,这个端口是固定的,所以注意防火墙设置。 节点之间通过二进制协议通信,这样的目的是减少带宽消耗。

在Redis Cluster中有一个概念slot,我们翻译为槽。Slot数量是固定的,为16384个。这些slot会均匀地分布到各个 节点上。另外Redis的键和值会根据hash算法存储在对应的slot中。简单讲,对于一个键值对,存的时候在哪里是通过 hash算法算出来的,那么取得时候也会算一下,知道值在哪个slot上。根据slot编号再到对应的节点上去取。

Redis Cluster无法保证数据的强一致性,这是因为当数据存储时,只要在主节点上存好了,就会告诉客户端存好了, 如果等所有从节点上都同步完再跟客户端确认,那么会有很大的延迟,这个对于客户端来讲是无法容忍的。所以, 最终Redis Cluster只好放弃了数据强一致性,而把性能放在了首位。

Redis Cluster搭建

Redis Cluster至少需要三个节点,即一主二从,本实验中使用6个节点搭建,规划如下:

主机名IP:Port角色
linux2019_1192.168.85.129:6379Redis Master
linux2019_2192.168.85.130:6379Redis Master
linux2019_3192.168.85.128:6379Redis Master
linux2019_1192.168.85.129:6380Redis slave
linux2019_2192.168.85.130:6380Redis slave
linux2019_3192.168.85.128:6380Redis slave
  1. 安装部署redis
[root@linux2019_01 ~]# vim /etc/redis_6379.conf
bind 192.168.85.129
port 6379  
daemonize yes
pidfile /var/run/redis_6379.pid 
dir /var/redis_6379
appendonly yes 
#开启集群
cluster-enabled yes  
#集群的配置文件,首次启动会自动创建
cluster-config-file nodes-6379.conf  
#集群节点连接超时时间,15秒
cluster-node-timeout 15000 

[root@linux2019_01 ~]# vim /etc/redis_6380.conf
bind 192.168.85.129
port 6380  
daemonize yes
pidfile /var/run/redis_6380.pid 
dir /var/redis_6380
appendonly yes 
#开启集群
cluster-enabled yes  
#集群的配置文件,首次启动会自动创建
cluster-config-file nodes-6380.conf  
#集群节点连接超时时间,15秒
cluster-node-timeout 15000 

其他两台机器相同配置方法,修改对应的IP、端口;

  1. 部署Cluster
[root@linux2019_01 ~]# firewall-cmd --permanent --add-port 6379-6380/tcp
[root@linux2019_01 ~]# firewall-cmd --permanent --add-port  16379-16380/tcp
[root@linux2019_01 ~]# firewall-cmd --reload
[root@linux2019_01 ~]# redis-cli --cluster create 192.168.85.129:6379 192.168.85.129:6380 192.168.85.130:6379 192.168.85.130:6380 192.168.85.128:6379 192.168.85.128:6380 --cluster-replicas 1    # --cluster-replicas 1表示每个主对应一个从,实际环境中建议一个主分配2个以上的从
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 192.168.85.130:6380 to 192.168.85.129:6379
Adding replica 192.168.85.128:6380 to 192.168.85.130:6379
Adding replica 192.168.85.129:6380 to 192.168.85.128:6379
M: 7ac660a2444df7f3e29ab59ac9e1044b0dedd202 192.168.85.129:6379
   slots:[0-5460] (5461 slots) master
S: 863662b3ce6262ac13cab2ac0dda0a064d012310 192.168.85.129:6380
   replicates 04c36ee67da93e57d57a5a70c3ad6d2272a5f457
M: 41304e7b210c24a638098900bf9111e71e01f211 192.168.85.130:6379
   slots:[5461-10922] (5462 slots) master
S: 973c8a8e652018cbba4272e38821be5d6b350e66 192.168.85.130:6380
   replicates 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
M: 04c36ee67da93e57d57a5a70c3ad6d2272a5f457 192.168.85.128:6379
   slots:[10923-16383] (5461 slots) master
S: f099fa35151385a290ba09a5bd83c41c6314288d 192.168.85.128:6380
   replicates 41304e7b210c24a638098900bf9111e71e01f211
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join
.....
>>> Performing Cluster Check (using node 192.168.85.129:6379)
M: 7ac660a2444df7f3e29ab59ac9e1044b0dedd202 192.168.85.129:6379
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
S: 973c8a8e652018cbba4272e38821be5d6b350e66 192.168.85.130:6380
   slots: (0 slots) slave
   replicates 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
S: 863662b3ce6262ac13cab2ac0dda0a064d012310 192.168.85.129:6380
   slots: (0 slots) slave
   replicates 04c36ee67da93e57d57a5a70c3ad6d2272a5f457
M: 04c36ee67da93e57d57a5a70c3ad6d2272a5f457 192.168.85.128:6379
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
S: f099fa35151385a290ba09a5bd83c41c6314288d 192.168.85.128:6380
   slots: (0 slots) slave
   replicates 41304e7b210c24a638098900bf9111e71e01f211
M: 41304e7b210c24a638098900bf9111e71e01f211 192.168.85.130:6379
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

  1. 连接集群
[root@linux2019_01 ~]# redis-cli -c  -h 192.168.85.129 -p 6379
192.168.85.129:6379> keys *
(empty list or set)
192.168.85.129:6379> set k1 abc
-> Redirected to slot [12706] located at 192.168.85.128:6379
OK
192.168.85.128:6379> set k2 123bac
-> Redirected to slot [449] located at 192.168.85.129:6379
OK
192.168.85.129:6379> set m1 duan
-> Redirected to slot [6916] located at 192.168.85.130:6379
OK
192.168.85.130:6379> set m2 xiu
-> Redirected to slot [11111] located at 192.168.85.128:6379
OK
192.168.85.128:6379> set m3 guo
OK
192.168.85.128:6379> keys * #存储键值的时候由集群分配将数据存储到各个节点上
1) "m2"
2) "k1"
3) "m3"
192.168.85.128:6379> get k1
"abc"
192.168.85.128:6379> get k2
-> Redirected to slot [449] located at 192.168.85.129:6379
"123bac"
192.168.85.129:6379> get m1
-> Redirected to slot [6916] located at 192.168.85.130:6379
"duan"
192.168.85.130:6379> get m2
-> Redirected to slot [11111] located at 192.168.85.128:6379
"xiu"
192.168.85.128:6379> get m3
"guo"

再次查看集群各个节点对应的keys数量已发生变化

[root@linux2019_03 ~]# redis-cli  --cluster  check 192.168.85.128 6379
192.168.85.128:6379 (04c36ee6...) -> 3 keys | 5461 slots | 1 slaves.
192.168.85.129:6379 (7ac660a2...) -> 1 keys | 5461 slots | 1 slaves.
192.168.85.130:6379 (41304e7b...) -> 1 keys | 5462 slots | 1 slaves.
[OK] 5 keys in 3 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.85.128:6379)
M: 04c36ee67da93e57d57a5a70c3ad6d2272a5f457 192.168.85.128:6379
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
M: 7ac660a2444df7f3e29ab59ac9e1044b0dedd202 192.168.85.129:6379
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
S: 863662b3ce6262ac13cab2ac0dda0a064d012310 192.168.85.129:6380
   slots: (0 slots) slave
   replicates 04c36ee67da93e57d57a5a70c3ad6d2272a5f457
S: 973c8a8e652018cbba4272e38821be5d6b350e66 192.168.85.130:6380
   slots: (0 slots) slave
   replicates 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
S: f099fa35151385a290ba09a5bd83c41c6314288d 192.168.85.128:6380
   slots: (0 slots) slave
   replicates 41304e7b210c24a638098900bf9111e71e01f211
M: 41304e7b210c24a638098900bf9111e71e01f211 192.168.85.130:6379
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
  1. 集群管理
  • 查看集群情况(可以在任意一个节点上,指定任意一个节点查看集群的情况
[root@linux2019_01 ~]# redis-cli  --cluster check 192.168.85.128:6379
192.168.85.128:6379 (04c36ee6...) -> 0 keys | 5461 slots | 1 slaves.
192.168.85.129:6379 (7ac660a2...) -> 0 keys | 5461 slots | 1 slaves.
192.168.85.130:6379 (41304e7b...) -> 0 keys | 5462 slots | 1 slaves.
[OK] 0 keys in 3 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.85.128:6379)
M: 04c36ee67da93e57d57a5a70c3ad6d2272a5f457 192.168.85.128:6379
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
M: 7ac660a2444df7f3e29ab59ac9e1044b0dedd202 192.168.85.129:6379
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
S: 863662b3ce6262ac13cab2ac0dda0a064d012310 192.168.85.129:6380
   slots: (0 slots) slave
   replicates 04c36ee67da93e57d57a5a70c3ad6d2272a5f457
S: 973c8a8e652018cbba4272e38821be5d6b350e66 192.168.85.130:6380
   slots: (0 slots) slave
   replicates 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
S: f099fa35151385a290ba09a5bd83c41c6314288d 192.168.85.128:6380
   slots: (0 slots) slave
   replicates 41304e7b210c24a638098900bf9111e71e01f211
M: 41304e7b210c24a638098900bf9111e71e01f211 192.168.85.130:6379
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
  • 在线迁移槽
[root@linux2019_02 ~]# redis-cli  --cluster  reshard   192.168.85.128 6379 
>>> Performing Cluster Check (using node 192.168.85.128:6379)
M: 04c36ee67da93e57d57a5a70c3ad6d2272a5f457 192.168.85.128:6379
   slots:[11923-16383] (4461 slots) master
   1 additional replica(s)
M: 7ac660a2444df7f3e29ab59ac9e1044b0dedd202 192.168.85.129:6379
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
S: 863662b3ce6262ac13cab2ac0dda0a064d012310 192.168.85.129:6380
   slots: (0 slots) slave
   replicates 04c36ee67da93e57d57a5a70c3ad6d2272a5f457
S: 973c8a8e652018cbba4272e38821be5d6b350e66 192.168.85.130:6380
   slots: (0 slots) slave
   replicates 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
S: f099fa35151385a290ba09a5bd83c41c6314288d 192.168.85.128:6380
   slots: (0 slots) slave
   replicates 41304e7b210c24a638098900bf9111e71e01f211
M: 41304e7b210c24a638098900bf9111e71e01f211 192.168.85.130:6379
   slots:[5461-11922] (6462 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
How many slots do you want to move (from 1 to 16384)? 20    #指定需要迁移槽的数量
What is the receiving node ID? 04c36ee67da93e57d57a5a70c3ad6d2272a5f457 #指定接收槽的节点ID
Please enter all the source node IDs.
  Type 'all' to use all the nodes as source nodes for the hash slots.
  Type 'done' once you entered all the source nodes IDs.
Source node #1: 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
Source node #2: done

Ready to move 20 slots.
  Source nodes:
    M: 7ac660a2444df7f3e29ab59ac9e1044b0dedd202 192.168.85.129:6379
       slots:[0-5460] (5461 slots) master
       1 additional replica(s)
  Destination node:
    M: 04c36ee67da93e57d57a5a70c3ad6d2272a5f457 192.168.85.128:6379
       slots:[11923-16383] (4461 slots) master
       1 additional replica(s)
  Resharding plan:
    Moving slot 0 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 1 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 2 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 3 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 4 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 5 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 6 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 7 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 8 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 9 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 10 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 11 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 12 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 13 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 14 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 15 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 16 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 17 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 18 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
    Moving slot 19 from 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
Do you want to proceed with the proposed reshard plan (yes/no)? yes
Moving slot 0 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 1 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 2 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 3 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 4 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 5 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 6 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 7 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 8 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 9 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 10 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 11 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 12 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 13 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 14 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 15 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 16 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 17 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 18 from 192.168.85.129:6379 to 192.168.85.128:6379: 
Moving slot 19 from 192.168.85.129:6379 to 192.168.85.128:6379: 
[root@linux2019_02 ~]# redis-cli  --cluster  check 192.168.85.128 6379  #查看迁移后的集群节点情况
192.168.85.128:6379 (04c36ee6...) -> 2 keys | 4481 slots | 1 slaves.
192.168.85.129:6379 (7ac660a2...) -> 1 keys | 5441 slots | 1 slaves.
192.168.85.130:6379 (41304e7b...) -> 2 keys | 6462 slots | 1 slaves.
[OK] 5 keys in 3 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.85.128:6379)
M: 04c36ee67da93e57d57a5a70c3ad6d2272a5f457 192.168.85.128:6379
   slots:[0-19],[11923-16383] (4481 slots) master
   1 additional replica(s)
M: 7ac660a2444df7f3e29ab59ac9e1044b0dedd202 192.168.85.129:6379
   slots:[20-5460] (5441 slots) master
   1 additional replica(s)
S: 863662b3ce6262ac13cab2ac0dda0a064d012310 192.168.85.129:6380
   slots: (0 slots) slave
   replicates 04c36ee67da93e57d57a5a70c3ad6d2272a5f457
S: 973c8a8e652018cbba4272e38821be5d6b350e66 192.168.85.130:6380
   slots: (0 slots) slave
   replicates 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
S: f099fa35151385a290ba09a5bd83c41c6314288d 192.168.85.128:6380
   slots: (0 slots) slave
   replicates 41304e7b210c24a638098900bf9111e71e01f211
M: 41304e7b210c24a638098900bf9111e71e01f211 192.168.85.130:6379
   slots:[5461-11922] (6462 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
  • 平衡各节点槽数量
[root@linux2019_02 ~]# redis-cli --cluster rebalance --cluster-threshold 1 192.168.85.128:6379
>>> Performing Cluster Check (using node 192.168.85.128:6379)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Rebalancing across 3 nodes. Total weight = 3.00
Moving 981 slots from 192.168.85.130:6379 to 192.168.85.128:6379
#####################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################
Moving 20 slots from 192.168.85.130:6379 to 192.168.85.129:6379
####################
[root@linux2019_02 ~]# redis-cli --cluster check 192.168.85.128 6379
192.168.85.128:6379 (04c36ee6...) -> 2 keys | 5462 slots | 1 slaves.
192.168.85.129:6379 (7ac660a2...) -> 1 keys | 5461 slots | 1 slaves.
192.168.85.130:6379 (41304e7b...) -> 2 keys | 5461 slots | 1 slaves.
[OK] 5 keys in 3 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.85.128:6379)
M: 04c36ee67da93e57d57a5a70c3ad6d2272a5f457 192.168.85.128:6379
   slots:[0-19],[5461-6441],[11923-16383] (5462 slots) master
   1 additional replica(s)
M: 7ac660a2444df7f3e29ab59ac9e1044b0dedd202 192.168.85.129:6379
   slots:[20-5460],[6442-6461] (5461 slots) master
   1 additional replica(s)
S: 863662b3ce6262ac13cab2ac0dda0a064d012310 192.168.85.129:6380
   slots: (0 slots) slave
   replicates 04c36ee67da93e57d57a5a70c3ad6d2272a5f457
S: 973c8a8e652018cbba4272e38821be5d6b350e66 192.168.85.130:6380
   slots: (0 slots) slave
   replicates 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
S: f099fa35151385a290ba09a5bd83c41c6314288d 192.168.85.128:6380
   slots: (0 slots) slave
   replicates 41304e7b210c24a638098900bf9111e71e01f211
M: 41304e7b210c24a638098900bf9111e71e01f211 192.168.85.130:6379
   slots:[6462-11922] (5461 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
  • 删除集群节点
[root@linux2019_03 ~]# redis-cli --cluster del-node 192.168.85.130:6380 973c8a8e652018cbba4272e38821be5d6b350e66
>>> Removing node 973c8a8e652018cbba4272e38821be5d6b350e66 from cluster 192.168.85.130:6380
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.
[root@linux2019_03 ~]# redis-cli --cluster check 192.168.85.129 6379
192.168.85.129:6379 (7ac660a2...) -> 1 keys | 5461 slots | 0 slaves.
192.168.85.128:6379 (04c36ee6...) -> 2 keys | 5462 slots | 1 slaves.
192.168.85.130:6379 (41304e7b...) -> 2 keys | 5461 slots | 1 slaves.
[OK] 5 keys in 3 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.85.129:6379)
M: 7ac660a2444df7f3e29ab59ac9e1044b0dedd202 192.168.85.129:6379
   slots:[20-5460],[6442-6461] (5461 slots) master
S: 863662b3ce6262ac13cab2ac0dda0a064d012310 192.168.85.129:6380
   slots: (0 slots) slave
   replicates 04c36ee67da93e57d57a5a70c3ad6d2272a5f457
M: 04c36ee67da93e57d57a5a70c3ad6d2272a5f457 192.168.85.128:6379
   slots:[0-19],[5461-6441],[11923-16383] (5462 slots) master
   1 additional replica(s)
S: f099fa35151385a290ba09a5bd83c41c6314288d 192.168.85.128:6380
   slots: (0 slots) slave
   replicates 41304e7b210c24a638098900bf9111e71e01f211
M: 41304e7b210c24a638098900bf9111e71e01f211 192.168.85.130:6379
   slots:[6462-11922] (5461 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
  • 添加集群节点
[root@linux2019_03 ~]# redis-cli --cluster add-node 192.168.85.130:6382 192.168.85.129:6379 --cluster-slave --cluster-master-id 68753f15439d1fc496f320999560e217b1a31baa
#后面不带参数,添加的节点为主
#--cluster-slave  这样添加的节点为从
#--cluster-slave --cluster-master-id  添加从并指定主
>>> Adding node 192.168.85.130:6382 to cluster 192.168.85.129:6379
>>> Performing Cluster Check (using node 192.168.85.129:6379)
M: 7ac660a2444df7f3e29ab59ac9e1044b0dedd202 192.168.85.129:6379
   slots:[20-5460],[6442-6461] (5461 slots) master
   1 additional replica(s)
S: 973c8a8e652018cbba4272e38821be5d6b350e66 192.168.85.130:6380
   slots: (0 slots) slave
   replicates 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
S: 863662b3ce6262ac13cab2ac0dda0a064d012310 192.168.85.129:6380
   slots: (0 slots) slave
   replicates 04c36ee67da93e57d57a5a70c3ad6d2272a5f457
M: 04c36ee67da93e57d57a5a70c3ad6d2272a5f457 192.168.85.128:6379
   slots:[0-19],[5461-6441],[11923-16383] (5462 slots) master
   1 additional replica(s)
M: 68753f15439d1fc496f320999560e217b1a31baa 192.168.85.130:6381
   slots: (0 slots) master
S: f099fa35151385a290ba09a5bd83c41c6314288d 192.168.85.128:6380
   slots: (0 slots) slave
   replicates 41304e7b210c24a638098900bf9111e71e01f211
M: 41304e7b210c24a638098900bf9111e71e01f211 192.168.85.130:6379
   slots:[6462-11922] (5461 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
>>> Send CLUSTER MEET to node 192.168.85.130:6382 to make it join the cluster.
Waiting for the cluster to join
...
>>> Configure node as replica of 192.168.85.130:6381.
[OK] New node added correctly.
[root@linux2019_03 ~]# 
[root@linux2019_03 ~]# redis-cli --cluster check 192.168.85.129 6379
192.168.85.129:6379 (7ac660a2...) -> 0 keys | 5461 slots | 1 slaves.
192.168.85.128:6379 (04c36ee6...) -> 2 keys | 5462 slots | 1 slaves.
192.168.85.130:6381 (68753f15...) -> 0 keys | 0 slots | 1 slaves.
192.168.85.130:6379 (41304e7b...) -> 2 keys | 5461 slots | 1 slaves.
[OK] 4 keys in 4 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.85.129:6379)
M: 7ac660a2444df7f3e29ab59ac9e1044b0dedd202 192.168.85.129:6379
   slots:[20-5460],[6442-6461] (5461 slots) master
   1 additional replica(s)
S: 973c8a8e652018cbba4272e38821be5d6b350e66 192.168.85.130:6380
   slots: (0 slots) slave
   replicates 7ac660a2444df7f3e29ab59ac9e1044b0dedd202
S: 863662b3ce6262ac13cab2ac0dda0a064d012310 192.168.85.129:6380
   slots: (0 slots) slave
   replicates 04c36ee67da93e57d57a5a70c3ad6d2272a5f457
M: 04c36ee67da93e57d57a5a70c3ad6d2272a5f457 192.168.85.128:6379
   slots:[0-19],[5461-6441],[11923-16383] (5462 slots) master
   1 additional replica(s)
M: 68753f15439d1fc496f320999560e217b1a31baa 192.168.85.130:6381
   slots: (0 slots) master
   1 additional replica(s)
S: f099fa35151385a290ba09a5bd83c41c6314288d 192.168.85.128:6380
   slots: (0 slots) slave
   replicates 41304e7b210c24a638098900bf9111e71e01f211
S: 56adc709f69b47492852cc322f9ef9d40d257ba8 192.168.85.130:6382
   slots: (0 slots) slave
   replicates 68753f15439d1fc496f320999560e217b1a31baa
M: 41304e7b210c24a638098900bf9111e71e01f211 192.168.85.130:6379
   slots:[6462-11922] (5461 slots) master
   1 additional replica(s)
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
  • 修复参数#redis-cli --cluster fix 192.168.85.129 6379

  • 将集群外部redis实例中的数据导入到集群中去

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值