![v2-94c8c0e9dd061bcc2040955ebd5db8de_1440w.jpg?source=172ae18b](http://img-03.proxy.5ce.com/view/image?&type=2&guid=b7557276-7e2f-eb11-8da9-e4434bdf6706&url=https://pic2.zhimg.com/v2-94c8c0e9dd061bcc2040955ebd5db8de_1440w.jpg?source=172ae18b)
一、基础环境搭建
分析
- 这里为了避免资金和资源浪费所以我使用了一台Linux系统做部署服务器时的部署测试
- 在一台linux系统,创建6个实例,分为三组,三组每一组分别为一主一从。
- 在实际环境中可以根据公司的实际环境搭建
![v2-83b9f57682090f2b17f0295b0e81292d_b.jpg](http://img-03.proxy.5ce.com/view/image?&type=2&guid=b7557276-7e2f-eb11-8da9-e4434bdf6706&url=https://pic2.zhimg.com/v2-83b9f57682090f2b17f0295b0e81292d_b.jpg)
![v2-49d79ce40f7e3500399b84671dd924e7_b.jpg](http://img-02.proxy.5ce.com/view/image?&type=2&guid=b7557276-7e2f-eb11-8da9-e4434bdf6706&url=https://pic4.zhimg.com/v2-49d79ce40f7e3500399b84671dd924e7_b.jpg)
二、安装配置Redis集群搭建
1.下载安装Redis
[root@yichen-redis ~]# wget -c http://download.redis.io/releases/redis-5.0.8.tar.gz
[root@yichen-redis ~]# tar zxvf redis-5.0.8.tar.gz -C /usr/src/
[root@yichen-redis ~]# cd /usr/src/redis-5.0.8/
[root@yichen-redis redis-5.0.8]# make
[root@yichen-redis redis-5.0.8]# make PREFIX=/usr/local/redis install
[root@yichen-redis ~]# ln -s /usr/local/redis/bin/* /usr/local/bin/
[root@yichen-redis ~]# cd /usr/src/redis-5.0.8/
[root@yichen-redis redis-5.0.8]# find / -name redis-trib.rb
/usr/src/redis-5.0.8/src/redis-trib.rb
[root@yichen-redis redis-5.0.8]# cp src/redis-trib.rb /usr/local/bin/
2.创建6个实例所用的配置文件
- 创建实例配置文件目录
- 复制配置文件并修改
- 创建日志目录
[root@yichen-redis ~]# mkdir /etc/redis-cluster/7000 -p
[root@yichen-redis ~]# mkdir /etc/redis-cluster/7001 -p
[root@yichen-redis ~]# mkdir /etc/redis-cluster/7002 -p
[root@yichen-redis ~]# mkdir /etc/redis-cluster/7003 -p
[root@yichen-redis ~]# mkdir /etc/redis-cluster/7004 -p
[root@yichen-redis ~]# mkdir /etc/redis-cluster/7005 -p
[root@yichen-redis ~]# cp /usr/src/redis-5.0.8/redis.conf /etc/redis-cluster/7000
[root@yichen-redis ~]# vim /etc/redis-cluster/7000/redis.conf
bind 127.0.0.1 192.168.150.51 ### 不同的主机绑定不同的IP
protected-mode no
port 7000 ###不同的实例,端口要不同(7000-7005之间)
daemonize yes
pidfile /var/run/redis_7000.pid ###不同的实例,名字要不同(7000-7005之间)
loglevel notice
logfile "/var/log/redis-cluster/7000.log" ###不同的实例,文件名称要不同(7000-7005之间)
dir /etc/redis-cluster/7000 ###不同的实例,目录名称要不同(7000-7005之间)
appendonly yes
cluster-enabled yes
cluster-config-file nodes-7000.conf
cluster-node-timeout 15000
[root@yichen-redis ~]# mkdir /var/log/redis-cluster -p
[root@yichen-redis ~]# setfacl -m u:redis:rwx /var/log/redis-cluster/
[root@yichen-redis ~]# getfacl /var/log/redis-cluster/
getfacl: Removing leading '/' from absolute path names
# file: var/log/redis-cluster/
# owner: root
# group: root
user::rwx
user:redis:rwx
group::r-x
mask::rwx
other::r-x
3.启动6个Redis实例
[root@yichen-redis ~]# firewall-cmd --add-port=7000-7005/tcp --permanent
[root@yichen-redis ~]# firewall-cmd --add-port=17000-17005/tcp --permanent
[root@yichen-redis ~]# firewall-cmd --reload
[root@yichen-redis ~]# firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: ssh dhcpv6-client
ports: 7000-7005/tcp 17000-17005/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
rule protocol value="vrrp" accept
[root@yichen-redis 7000]# redis-server /etc/redis-cluster/7000/redis.conf
[root@yichen-redis 7000]# redis-server /etc/redis-cluster/7001/redis.conf
[root@yichen-redis 7000]# redis-server /etc/redis-cluster/7002/redis.conf
[root@yichen-redis 7000]# redis-server /etc/redis-cluster/7003/redis.conf
[root@yichen-redis 7000]# redis-server /etc/redis-cluster/7004/redis.conf
[root@yichen-redis 7000]# redis-server /etc/redis-cluster/7005/redis.conf
[root@yichen-redis 7000]# netstat -antp | grep redis-server
tcp 0 0 192.168.150.51:17000 0.0.0.0:* LISTEN 15978/redis-server
tcp 0 0 127.0.0.1:17000 0.0.0.0:* LISTEN 15978/redis-server
tcp 0 0 192.168.150.51:17001 0.0.0.0:* LISTEN 16910/redis-server
tcp 0 0 127.0.0.1:17001 0.0.0.0:* LISTEN 16910/redis-server
tcp 0 0 192.168.150.51:17002 0.0.0.0:* LISTEN 16917/redis-server
tcp 0 0 127.0.0.1:17002 0.0.0.0:* LISTEN 16917/redis-server
tcp 0 0 192.168.150.51:17003 0.0.0.0:* LISTEN 16925/redis-server
tcp 0 0 127.0.0.1:17003 0.0.0.0:* LISTEN 16925/redis-server
tcp 0 0 192.168.150.51:17004 0.0.0.0:* LISTEN 16932/redis-server
tcp 0 0 127.0.0.1:17004 0.0.0.0:* LISTEN 16932/redis-server
tcp 0 0 192.168.150.51:17005 0.0.0.0:* LISTEN 16940/redis-server
tcp 0 0 127.0.0.1:17005 0.0.0.0:* LISTEN 16940/redis-server
tcp 0 0 192.168.150.51:7000 0.0.0.0:* LISTEN 15978/redis-server
tcp 0 0 127.0.0.1:7000 0.0.0.0:* LISTEN 15978/redis-server
tcp 0 0 192.168.150.51:7001 0.0.0.0:* LISTEN 16910/redis-server
tcp 0 0 127.0.0.1:7001 0.0.0.0:* LISTEN 16910/redis-server
tcp 0 0 192.168.150.51:7002 0.0.0.0:* LISTEN 16917/redis-server
tcp 0 0 127.0.0.1:7002 0.0.0.0:* LISTEN 16917/redis-server
tcp 0 0 192.168.150.51:7003 0.0.0.0:* LISTEN 16925/redis-server
tcp 0 0 127.0.0.1:7003 0.0.0.0:* LISTEN 16925/redis-server
tcp 0 0 192.168.150.51:7004 0.0.0.0:* LISTEN 16932/redis-server
tcp 0 0 127.0.0.1:7004 0.0.0.0:* LISTEN 16932/redis-server
tcp 0 0 192.168.150.51:7005 0.0.0.0:* LISTEN 16940/redis-server
tcp 0 0 127.0.0.1:7005 0.0.0.0:* LISTEN 16940/redis-server
16940:M 09 Apr 2020 13:03:46.921 * No cluster configuration found, I'm 2a42f611cb46b68e90333fc7e1394db11060f3fe
16347:C 09 Apr 2020 12:54:27.446 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
16347:C 09 Apr 2020 12:54:27.446 # Redis version=5.0.8, bits=64, commit=00000000, modified=0, pid=16347, just started
16347:C 09 Apr 2020 12:54:27.446 # Configuration loaded
16347:M 09 Apr 2020 12:54:27.447 * Increased maximum number of open files to 10032 (it was originally set to 1024).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 5.0.8 (00000000/0) 64 bit
.-`` .-```. ```/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 16347
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
16347:M 09 Apr 2020 12:54:27.447 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
16347:M 09 Apr 2020 12:54:27.447 # Server initialized
16347:M 09 Apr 2020 12:54:27.447 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
16347:M 09 Apr 2020 12:54:27.447 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
16347:M 09 Apr 2020 12:54:27.447 * DB loaded from disk: 0.000 seconds
16347:M 09 Apr 2020 12:54:27.447 * Ready to accept connections
^C16347:signal-handler (1586408093) Received SIGINT scheduling shutdown...
16347:M 09 Apr 2020 12:54:54.003 # User requested shutdown...
16347:M 09 Apr 2020 12:54:54.003 * Saving the final RDB snapshot before exiting.
16347:M 09 Apr 2020 12:54:54.005 * DB saved on disk
16347:M 09 Apr 2020 12:54:54.005 * Removing the pid file.
16347:M 09 Apr 2020 12:54:54.005 # Redis is now ready to exit, bye bye...
查看日志可以发现,每个节点都会为其分配一个新的ID
[root@yichen-redis ~]# cd /var/log/redis-cluster/
[root@yichen-redis redis-cluster]# ll
总用量 28
-rw-r--r-- 1 redis redis 4449 4月 9 13:03 7000.log
-rw-r--r-- 1 root root 2605 4月 9 13:03 7001.log
-rw-r--r-- 1 root root 2605 4月 9 13:03 7002.log
-rw-r--r-- 1 root root 2605 4月 9 13:03 7003.log
-rw-r--r-- 1 root root 2605 4月 9 13:03 7004.log
-rw-r--r-- 1 root root 2605 4月 9 13:03 7005.log
[root@yichen-redis redis-cluster]# cat 7000.log |grep '^15978:M 09 Apr 2020 12:50:32.850 * '
15978:M 09 Apr 2020 12:50:32.850 * Increased maximum number of open files to 10032 (it was originally set to 1024).
15978:M 09 Apr 2020 12:50:32.850 * No cluster configuration found, I'm 37f4e990194be7511556b60ba81945db350464fd
[root@yichen-redis redis-cluster]# cat 7001.log |grep '^16910:M 09 Apr 2020 13:03:33.901 *'
16910:M 09 Apr 2020 13:03:33.901 * Increased maximum number of open files to 10032 (it was originally set to 1024).
16910:M 09 Apr 2020 13:03:33.901 * No cluster configuration found, I'm ba7968ed0cfc533edd57a70cbd3c0a9bb80d468d
[root@yichen-redis redis-cluster]# cat 7002.log |grep '^16917:M 09 Apr 2020 13:03:37.239 *'
16917:M 09 Apr 2020 13:03:37.239 * Increased maximum number of open files to 10032 (it was originally set to 1024).
16917:M 09 Apr 2020 13:03:37.239 * No cluster configuration found, I'm 88944428174d6d1ab854894f2afb548c3bf64e1d
[root@yichen-redis redis-cluster]# cat 7003.log |grep '^16925:M 09 Apr 2020 13:03:40.147 * '
16925:M 09 Apr 2020 13:03:40.147 * Increased maximum number of open files to 10032 (it was originally set to 1024).
16925:M 09 Apr 2020 13:03:40.147 * No cluster configuration found, I'm 3daba015991d2f53f19050bbc8b4472750a2836f
[root@yichen-redis redis-cluster]# cat 7004.log |grep '^16932:M 09 Apr 2020 13:03:43.277 *'
16932:M 09 Apr 2020 13:03:43.277 * Increased maximum number of open files to 10032 (it was originally set to 1024).
16932:M 09 Apr 2020 13:03:43.277 * No cluster configuration found, I'm 5c3cc3fec9253c8596b6cdedcd162ce446f8690b
[root@yichen-redis redis-cluster]# cat 7005.log |grep '^16940:M 09 Apr 2020 13:03:46.921 *'
4.创建集群
[root@yichen-redis ~]# redis-cli --cluster create 192.168.150.51:7000
> 192.168.150.51:7001 192.168.150.51:7002
> 192.168.150.51:7003 192.168.150.51:7004
> 192.168.150.51:7005
> --cluster-replicas 1
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383 ###分配的slots情况
Adding replica 192.168.150.51:7004 to 192.168.150.51:7000
Adding replica 192.168.150.51:7005 to 192.168.150.51:7001
Adding replica 192.168.150.51:7003 to 192.168.150.51:7002
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: 37f4e990194be7511556b60ba81945db350464fd 192.168.150.51:7000
slots:[0-5460] (5461 slots) master
M: ba7968ed0cfc533edd57a70cbd3c0a9bb80d468d 192.168.150.51:7001
slots:[5461-10922] (5462 slots) master
M: 88944428174d6d1ab854894f2afb548c3bf64e1d 192.168.150.51:7002
slots:[10923-16383] (5461 slots) master
S: 3daba015991d2f53f19050bbc8b4472750a2836f 192.168.150.51:7003
replicates 88944428174d6d1ab854894f2afb548c3bf64e1d
S: 5c3cc3fec9253c8596b6cdedcd162ce446f8690b 192.168.150.51:7004
replicates 37f4e990194be7511556b60ba81945db350464fd
S: 2a42f611cb46b68e90333fc7e1394db11060f3fe 192.168.150.51:7005
replicates ba7968ed0cfc533edd57a70cbd3c0a9bb80d468d
Can I set the above configuration? (type 'yes' to accept): yes ### 输入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.150.51:7000)
M: 37f4e990194be7511556b60ba81945db350464fd 192.168.150.51:7000
slots:[0-5460] (5461 slots) master
1 additional replica(s)
M: ba7968ed0cfc533edd57a70cbd3c0a9bb80d468d 127.0.0.1:7001
slots:[5461-10922] (5462 slots) master
1 additional replica(s)
S: 2a42f611cb46b68e90333fc7e1394db11060f3fe 127.0.0.1:7005
slots: (0 slots) slave
replicates ba7968ed0cfc533edd57a70cbd3c0a9bb80d468d
S: 5c3cc3fec9253c8596b6cdedcd162ce446f8690b 127.0.0.1:7004
slots: (0 slots) slave
replicates 37f4e990194be7511556b60ba81945db350464fd
M: 88944428174d6d1ab854894f2afb548c3bf64e1d 127.0.0.1:7002
slots:[10923-16383] (5461 slots) master
1 additional replica(s)
S: 3daba015991d2f53f19050bbc8b4472750a2836f 127.0.0.1:7003
slots: (0 slots) slave
replicates 88944428174d6d1ab854894f2afb548c3bf64e1d
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered. ### 看到这个消息,集群创建OK。
5.使用Redis集群
- 集群实例中写入数据测试
[root@yichen-redis ~]# redis-cli -c -p 7000 -h 192.168.150.51
192.168.150.51:7000> ping
PONG
192.168.150.51:7000> set password 123
-> Redirected to slot [9540] located at 127.0.0.1:7001
OK
127.0.0.1:7001> set userid 01
-> Redirected to slot [15270] located at 127.0.0.1:7002
OK
127.0.0.1:7002> set address hengbeihengshui
-> Redirected to slot [3680] located at 127.0.0.1:7000
OK
127.0.0.1:7000> quit
6.集群操作
6.1、查看集群成员
[root@yichen-redis ~]# redis-cli -p 7000 -h 192.168.150.51 cluster nodes
ba7968ed0cfc533edd57a70cbd3c0a9bb80d468d 127.0.0.1:7001@17001 master - 0 1586410090000 2 connected 5461-10922
88944428174d6d1ab854894f2afb548c3bf64e1d 127.0.0.1:7002@17002 master - 0 1586410091000 3 connected 10923-16383
3daba015991d2f53f19050bbc8b4472750a2836f 127.0.0.1:7003@17003 slave 88944428174d6d1ab854894f2afb548c3bf64e1d 0 1586410089000 4 connected
5c3cc3fec9253c8596b6cdedcd162ce446f8690b 127.0.0.1:7004@17004 slave 37f4e990194be7511556b60ba81945db350464fd 0 1586410090293 5 connected
2a42f611cb46b68e90333fc7e1394db11060f3fe 127.0.0.1:7005@17005 slave ba7968ed0cfc533edd57a70cbd3c0a9bb80d468d 0 1586410091300 6 connected
37f4e990194be7511556b60ba81945db350464fd 192.168.150.51:7000@17000 myself,master - 0 1586410088000 1 connected 0-5460
6.2、测试集群故障转移
- 关闭7002实例
- 查看状态
[root@yichen-redis ~]# redis-cli -p 7002 debug segfault
Error: Server closed the connection
[root@yichen-redis ~]# netstat -antp | grep 7002
[root@yichen-redis ~]# redis-cli -p 7000 cluster nodes
![v2-4396cc2d411b087ea1d89281e53d7aab_b.png](http://img-03.proxy.5ce.com/view/image?&type=2&guid=b7557276-7e2f-eb11-8da9-e4434bdf6706&url=https://pic4.zhimg.com/v2-4396cc2d411b087ea1d89281e53d7aab_b.png)
[root@yichen-redis ~]# redis-server /etc/redis-cluster/7002/redis.conf
[root@yichen-redis ~]# redis-cli -p 7000 cluster nodes
![v2-2fe7086918926ca8b437701efd35cbef_b.png](http://img-01.proxy.5ce.com/view/image?&type=2&guid=b7557276-7e2f-eb11-8da9-e4434bdf6706&url=https://pic4.zhimg.com/v2-2fe7086918926ca8b437701efd35cbef_b.png)
6.3、添加一个新的节点
- 创建一个新的实例7006,启动
- 加入到集群中
[root@yichen-redis ~]# mkdir /etc/redis-cluster/7006
[root@yichen-redis ~]# vim /etc/redis-cluster/7006/redis.conf
bind 127.0.0.1 192.168.150.51
protected-mode no
port 7006
daemonize yes
pidfile /var/run/redis_7006.pid
loglevel notice
logfile "/var/log/redis-cluster/7006.log"
dir /etc/redis-cluster/7006
appendonly yes
cluster-enabled yes
cluster-config-file nodes-7006.conf
cluster-node-timeout 15000
[root@yichen-redis ~]# redis-server /etc/redis-cluster/7006/redis.conf
[root@yichen-redis ~]# netstat -antp | grep :7006
tcp 0 0 192.168.150.51:7006 0.0.0.0:* LISTEN 31179/redis-server
tcp 0 0 127.0.0.1:7006 0.0.0.0:* LISTEN 31179/redis-server
[root@yichen-redis ~]# redis-cli --cluster add-node 192.168.150.51:7006 192.168.150.51:7000
![v2-e754714ac639fbf20bff5c247b431712_b.jpg](http://img-01.proxy.5ce.com/view/image?&type=2&guid=b7557276-7e2f-eb11-8da9-e4434bdf6706&url=https://pic3.zhimg.com/v2-e754714ac639fbf20bff5c247b431712_b.jpg)
[root@yichen-redis ~]# redis-cli --cluster check 192.168.150.51:7000
![v2-6a85327a0007797c25e852b609aa9674_b.jpg](http://img-01.proxy.5ce.com/view/image?&type=2&guid=b7557276-7e2f-eb11-8da9-e4434bdf6706&url=https://pic1.zhimg.com/v2-6a85327a0007797c25e852b609aa9674_b.jpg)
6.4、对集群重新分片
- 第一个问题是:问你需要移动多少个slots,这里为了均匀,可以填写1 6384/4=4096,填写4096个即可
How many slots do you want to move (from 1 to 16384)?
- 第二个问题:问你要将slots移动到哪个节点,添加7006实例的
Node IDwhat is the receiving node ID?
- 第三个问题:问你要从哪些节点移出slots, a代表从其它所有master节点移出,即每个节点移出一部分;
Please enter a11 the source node IDs.
Type 'a11' to use a11 the nodes as source nodes for. the hash slots.
Type
'done' once you entered a11 the source nodes IDS.
Source node #1:
[root@yichen-redis ~]# redis-cli --cluster reshard 192.168.150.51:7000
![v2-e61967fa03388f9e1221a46936e69f72_b.jpg](http://img-02.proxy.5ce.com/view/image?&type=2&guid=b7557276-7e2f-eb11-8da9-e4434bdf6706&url=https://pic3.zhimg.com/v2-e61967fa03388f9e1221a46936e69f72_b.jpg)
![v2-17dd82084913ccd32131da8cb2e133d9_b.jpg](http://img-02.proxy.5ce.com/view/image?&type=2&guid=b7557276-7e2f-eb11-8da9-e4434bdf6706&url=https://pic2.zhimg.com/v2-17dd82084913ccd32131da8cb2e133d9_b.jpg)
6.5、添加一个从节点
[root@yichen-redis ~]# mkdir /etc/redis-cluster/7007
[root@yichen-redis ~]# cp /etc/redis-cluster/7002/redis.conf /etc/redis-cluster/7007/
[root@yichen-redis ~]# vim /etc/redis-cluster/7007/redis.conf
bind 127.0.0.1 192.168.150.51
protected-mode no
port 7007
daemonize yes
pidfile /var/run/redis_7007.pid
loglevel notice
logfile "/var/log/redis-cluster/7007.log"
dir /etc/redis-cluster/7007
appendonly yes
cluster-enabled yes
cluster-config-file nodes-7007.conf
cluster-node-timeout 15000
[root@yichen-redis ~]# redis-server /etc/redis-cluster/7007/redis.conf
[root@yichen-redis ~]# redis-cli --cluster add-node 192.168.150.51:7007 192.168.150.51:7000 --cluster-slave
>>> Adding node 192.168.150.51:7007 to cluster 192.168.150.51:7000
>>> Performing Cluster Check (using node 192.168.150.51:7000)
M: 37f4e990194be7511556b60ba81945db350464fd 192.168.150.51:7000
slots:[1365-5460] (4096 slots) master
1 additional replica(s)
M: ba7968ed0cfc533edd57a70cbd3c0a9bb80d468d 127.0.0.1:7001
slots:[6827-10922] (4096 slots) master
1 additional replica(s)
S: 2a42f611cb46b68e90333fc7e1394db11060f3fe 127.0.0.1:7005
slots: (0 slots) slave
replicates ba7968ed0cfc533edd57a70cbd3c0a9bb80d468d
S: 5c3cc3fec9253c8596b6cdedcd162ce446f8690b 127.0.0.1:7004
slots: (0 slots) slave
replicates 37f4e990194be7511556b60ba81945db350464fd
S: 88944428174d6d1ab854894f2afb548c3bf64e1d 127.0.0.1:7002
slots: (0 slots) slave
replicates 3daba015991d2f53f19050bbc8b4472750a2836f
M: 7590bb119de987b9a6668f5f99ba0212a147185e 127.0.0.1:7006
slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master
M: 3daba015991d2f53f19050bbc8b4472750a2836f 127.0.0.1:7003
slots:[12288-16383] (4096 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.
Automatically selected master 127.0.0.1:7006
>>> Send CLUSTER MEET to node 192.168.150.51:7007 to make it join the cluster.
Waiting for the cluster to join
>>> Configure node as replica of 127.0.0.1:7006.
[OK] New node added correctly.
6.6、删除节点
[root@yichen-redis ~]# redis-cli --cluster del-node 127.0.0.1:7004 5c3cc3fec9253c8596b6cdedcd162ce446f8690b
>>> Removing node 5c3cc3fec9253c8596b6cdedcd162ce446f8690b from cluster 127.0.0.1:7004
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.
[root@yichen-redis ~]# redis-cli --cluster check 192.168.150.51:7000
![v2-8f8d9138b4aa920e25251d67c53789db_b.jpg](http://img-02.proxy.5ce.com/view/image?&type=2&guid=b7557276-7e2f-eb11-8da9-e4434bdf6706&url=https://pic4.zhimg.com/v2-8f8d9138b4aa920e25251d67c53789db_b.jpg)