文章目录

  • 1、部署规划
  • 2、句柄调整
  • 3、内核调整(可选)
  • 4、部署 jdk (可选)
    • 4.1、解压版本
    • 4.2、环境变量
  • 5、上传解压
  • 6、编译安装
  • 7、创建配置
  • 8、启动服务
  • 9、创建集群
  • 10、验证集群
  • 11、停止服务
  • 12、附录
    • 12.1、增加节点
    • 12.2、删除节点
    • 12.3、选举机制
    • 12.4、安装ruby(参考)
    • 12.4、集群修复
    • 12.5、aof损坏
    • 12.6、恢复数据(可选)
    • 12.7、数据迁移
    • 12.8、故障转移
    • 12.9、动态扩缩
      • 12.9.1、新增主机
      • 12.9.2、查看集群
      • 12.9.3、分配槽位
    • 12.10、动态缩容
      • 12.10.1、查看集群
      • 12.10.2、删除槽位
        • 12.10.2.1、分配slot给master1
        • 12.10.2.2、分配slot给master2
        • 12.10.2.3、分配slot给master3
      • 12.10.3、移除主机

1、部署规划

IP host 版本 端口
192.168.179.10 node1 redis-6.2.5 9821,9822,9823
192.168.179.11 node2 redis-6.2.5 9824,9825,9826

2、句柄调整

【所有节点均需操作】

1、检查limits.conf,增加如下2行配置:
# vim /etc/security/limits.conf
*   soft   core  0
*   hard   core  0
*   soft   nofile  131072
*   hard   nofile  131072
*   soft   nproc   131072
*   hard   nproc   131072

3、内核调整(可选)

【所有节点均需操作】

【增加配置】
# vim /etc/sysctl.conf
<追加>
vm.max_map_count=262144
net.core.somaxconn=32768
vm.overcommit_memory=0
vm.max_map_count=262144【生效修改】
# sysctl -p

4、部署 jdk (可选)

4.1、解压版本

# tar xf jdk-8u301-linux-x64.tar.gz -C /home/
# mv /home/jdk1.8.0_301 /home/java

4.2、环境变量

【追加配置】
# cat << EOF >> /etc/profile
#jdk#
export JAVA_HOME=/home/java
export JRE_HOME=\$JAVA_HOME/jre
export CLASS_PATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar
export PATH=\$JAVA_HOME/bin:\$PATH
EOF【生效配置】
# source /etc/profile

5、上传解压

# tar zxvf redis-6.2.5.tar.gz -C /home/
# mv /home/redis-6.2.5 /home/redis

6、编译安装

# cd /home/redis
# make MALLOC=libc && make install【如果报错ld不存在,则执行如下命令】
# cd /usr/bin;ll ld*ld -> /etc/alternatives/ldld.gold
# mv ld ld_old
# ln -s  ld.gold ld

7、创建配置

# mkdir -p /home/redis/cluster /home/redis/logs/ /home/redis/data/
# cd cluster/【配置一个文件后,其它配置文件只需拷贝并修改端口】
# cat << EOF > redis_9821.conf
bind 0.0.0.0
protected-mode yes
port 9821
daemonize yes
tcp-backlog 511
timeout 0
tcp-keepalive 300
supervised no
pidfile /home/redis/run/redis_9821.pid
loglevel notice
logfile "/home/redis/logs/redis_9821.log"
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump_9821.rdb
dir /home/redis/data/
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
replica-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
appendonly yes
appendfilename "appendonly_9821.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
requirepass Drms@12#$
masterauth Drms@12#$
cluster-enabled yes
cluster-config-file nodes-9821.conf
cluster-node-timeout 5000
EOF【拷贝文件】
# for i in {2..6};do cp redis_9821.conf redis_982${i}.conf ;sed -i "s/9821/982${i}/g" redis_982${i}.conf;done

8、启动服务

【192.168.179.10】
# /home/redis/src/redis-server /home/redis/cluster/redis_9821.conf \
&& /home/redis/src/redis-server /home/redis/cluster/redis_9822.conf \
&& /home/redis/src/redis-server /home/redis/cluster/redis_9823.conf【192.168.179.11】
# /home/redis/src/redis-server /home/redis/cluster/redis_9824.conf \
&& /home/redis/src/redis-server /home/redis/cluster/redis_9825.conf \
&& /home/redis/src/redis-server /home/redis/cluster/redis_9826.conf

9、创建集群

【192.168.179.10】
# /home/redis/src/redis-cli -a 'Drms@12#$' --cluster create 192.168.179.10:9821 192.168.179.10:9822 192.168.179.10:9823 192.168.179.11:9824 192.168.179.11:9825 192.168.179.11:9826 --cluster-replicas 1Can I set the above configuration? (type 'yes' to accept): yes说明:--cluster-replicas master和slave的比例,此处权重1,则3主3从。

10、验证集群

# /home/redis/src/redis-cli -c -h 192.168.179.10 -p 9821 -a 'Drms@12#$'
@ 测试读写
172.16.12.229:9821> set k1 v1
172.16.12.229:9823> keys *
172.16.12.229:9823> get "k1"
@ 查看集群节点
172.16.12.229:9821> cluster nodes
@ 查看集群信息
172.16.12.229:9821> cluster info
@ 查看槽位信息
172.16.12.229:9821> cluster slots
@ 计算key的槽位
172.16.12.229:9821> cluster keyslot "k1"

11、停止服务

# ps -ef|grep -v grep|grep "/home/redis/src/redis-server.*982.*"|awk '{print $2}'|xargs kill -9

12、附录

12.1、增加节点

【新增配置】【192.168.179.11】
# cp redis_9821.conf redis_7006.conf ;sed -i "s/9821/7006/g" redis_7006.conf【启动服务】
# /home/redis/src/redis-server /home/redis/cluster/redis_7006.conf【增加节点】
# /home/redis/src/redis-cli -c -h 192.168.179.10 -p 9821 -a 'Drms@12#$'
192.168.179.10:9822> CLUSTER MEET 192.168.179.11 7006
192.168.179.10:9822> CLUSTER NODES注意:新增的节点都是以master身份加入集群。

12.2、删除节点

# /home/redis/src/redis-cli -c -h 192.168.179.10 -p 9821 -a 'Drms@12#$'
192.168.179.10:9822> CLUSTER FORGET 6788453ee9a8d7f72b1d45a9093838efd0e501f1
OK              #可以删除master节点(除myself)
192.168.179.10:9822> CLUSTER FORGET b4d3eb411a7355d4767c6c23b4df69fa183ef8bc
OK              #可以删除slave节点(除myself)
192.168.179.10:9822> CLUSTER NODES

12.3、选举机制

注意:master节点如果挂掉,则它的slave节点变为新master节点继续对外提供服务,而原来的master节点如果恢复,则变为新master节点的slave节点。

12.4、安装ruby(参考)

【新版已开始弃用ruby,可使用redis-cli代替redis-trib.rb】

【下载离线rpm】【有网络的linux主机(虚拟机)操作】
# yum install --downloadonly --downloaddir=temp ruby
【强制安装rpm包】
# rpm -ivh --force --nodeps *.rpm

12.4、集群修复

【检查节点】
# /home/redis/src/redis-cli --cluster check 192.168.179.10:9821 -a 'Drms@12#$'【修复节点】
# /home/redis/src/redis-cli --cluster fix 192.168.179.10:9821 -a 'Drms@12#$'
<选择yes>

12.5、aof损坏

# /home/redis/src/redis-check-aof --fix appendonly.aof
<选择yes>注意:可能会清空aof文件。

12.6、恢复数据(可选)

【默认无需手动操作,重启会自动恢复】

【检查aof文件】
# /home/redis/src/redis-check-aof /home/redis/data/appendonly.aof
# /home/redis/src/redis-cli -h 192.168.179.10 -p 9821 -a 'Drms@12#$' --pipe < /home/redis/data/appendonly.aof
All data transferred. Waiting for the last reply...
Last reply received from server.
errors: 0, replies: 7108

12.7、数据迁移

【方式1】
1、复制源节点的AOF文件到目标主机后
2、清空目标实例所有key:flushall
3、导入AOF文件至目标实例:/home/redis/src/redis-cli -h 192.168.179.10 -p 9821 -a 'Drms@12#$' --pipe < /home/redis/data/appendonly.aof【方式2】
1、复制源节点的RDB文件到目标主机后
2、重启目标实例的服务,触发自动恢复RDB文件

12.8、故障转移

【master异常后,slave自动切换为master,人工干预启动原实例后,原实例自动变为slave,并加入集群】

【=== 查询集群信息 ===】
# /home/redis/src/redis-cli -h 192.168.179.10 -p 9821 -a 'Drms@12#$' cluster nodes
8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824@19824 slave fb96a9aa70b269936cd266f860e8e36960b90058 0 1661394989000 4 connected
fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821@19821 myself,master - 0 1661394989000 1 connected 0-5460
df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825@19825 slave 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 0 1661394990000 5 connected
1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823@19823 master - 0 1661394990322 3 connected 10923-16383
6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822@19822 master - 0 1661394990526 2 connected 5461-10922
75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826@19826 slave 1e4432f5bc7fb4ecebf12291eafb987d901872f7 0 1661394989508 6 connected【=== 停止master 9822来模拟故障 ===】
# kill -9 # ps -ef|grep 9822
root      37467      1  0 08:59 ?        00:00:06 /home/redis/src/redis-server 0.0.0.0:9822 [cluster]
# kill -9 37467【=== 检查集群 ===】
# /home/redis/src/redis-cli -h 192.168.179.10 -p 9821 -a 'Drms@12#$' cluster nodes
8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824@19824 slave fb96a9aa70b269936cd266f860e8e36960b90058 0 1661395169509 4 connected
fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821@19821 myself,master - 0 1661395166000 1 connected 0-5460
df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825@19825 master - 0 1661395168000 7 connected 5461-10922           # --- 切换为master
1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823@19823 master - 0 1661395168492 3 connected 10923-16383
6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822@19822 master,fail - 1661395063725 1661395063587 2 disconnected  # --- 9822断连
75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826@19826 slave 1e4432f5bc7fb4ecebf12291eafb987d901872f7 0 1661395168000 6 connected# /home/redis/src/redis-cli --cluster check 192.168.179.10:9821 -a 'Drms@12#$'
Could not connect to Redis at 192.168.179.10:9822: Connection refused
192.168.179.10:9821 (fb96a9aa...) -> 6672 keys | 5461 slots | 1 slaves.
192.168.179.10:9825 (df0a8e45...) -> 6672 keys | 5462 slots | 0 slaves.
192.168.179.10:9823 (1e4432f5...) -> 6656 keys | 5461 slots | 1 slaves.
[OK] 20000 keys in 3 masters.
1.22 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.179.10:9821)
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[0-5460] (5461 slots) master1 additional replica(s)
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[5461-10922] (5462 slots) master
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[10923-16383] (5461 slots) master1 additional replica(s)
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.【=== 启动9822实例 ===】
# /home/redis/src/redis-server /home/redis/cluster/redis_9822.conf【=== 检查集群 ===】
# /home/redis/src/redis-cli -h 192.168.179.10 -p 9821 -a 'Drms@12#$' cluster nodes
8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824@19824 slave fb96a9aa70b269936cd266f860e8e36960b90058 0 1661395344000 4 connected
fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821@19821 myself,master - 0 1661395346000 1 connected 0-5460
df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825@19825 master - 0 1661395345571 7 connected 5461-10922
1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823@19823 master - 0 1661395346000 3 connected 10923-16383
6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822@19822 slave df0a8e4503c472be07ed2770ef435e018d07e3cc 0 1661395346077 7 connected  # 启动后变为slave
75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826@19826 slave 1e4432f5bc7fb4ecebf12291eafb987d901872f7 0 1661395345366 6 connected# /home/redis/src/redis-cli --cluster check 192.168.179.10:9821 -a 'Drms@12#$'
192.168.179.10:9821 (fb96a9aa...) -> 6672 keys | 5461 slots | 1 slaves.
192.168.179.10:9825 (df0a8e45...) -> 6672 keys | 5462 slots | 1 slaves.
192.168.179.10:9823 (1e4432f5...) -> 6656 keys | 5461 slots | 1 slaves.
[OK] 20000 keys in 3 masters.
1.22 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.179.10:9821)
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[0-5460] (5461 slots) master1 additional replica(s)
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[5461-10922] (5462 slots) master1 additional replica(s)
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[10923-16383] (5461 slots) master1 additional replica(s)
S: 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

12.9、动态扩缩

【正常扩容应该是扩主机,此处举例仅为扩实例】

12.9.1、新增主机

【新增9827实例】
# cp redis_9821.conf redis_9827.conf ;sed -i "s/9821/9827/g" redis_9827.conf
# cp redis_9821.conf redis_9828.conf ;sed -i "s/9821/9828/g" redis_9828.conf【启动服务】
# /home/redis/src/redis-server /home/redis/cluster/redis_9827.conf
# /home/redis/src/redis-server /home/redis/cluster/redis_9828.conf    # --- 后面用作slave加入集群【加入集群】
# /home/redis/src/redis-cli -c -h 192.168.179.10 -p 9821 -a 'Drms@12#$'
192.168.179.10:9826> CLUSTER MEET 192.168.179.10 9827
OK
192.168.179.10:9826> CLUSTER NODES
439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827@19827 master - 0 1661395861093 0 connected  # --- 新增实例,角色为master
6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822@19822 slave df0a8e4503c472be07ed2770ef435e018d07e3cc 0 1661395861502 7 connected
fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821@19821 master - 0 1661395861000 1 connected 0-5460
df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825@19825 master - 0 1661395861502 7 connected 5461-10922
8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824@19824 slave fb96a9aa70b269936cd266f860e8e36960b90058 0 1661395861000 4 connected
75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826@19826 myself,slave 1e4432f5bc7fb4ecebf12291eafb987d901872f7 0 1661395859000 6 connected
1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823@19823 master - 0 1661395862011 3 connected 10923-16383

12.9.2、查看集群

# /home/redis/src/redis-cli --cluster check 192.168.179.10:9821 -a 'Drms@12#$'
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.179.10:9821 (fb96a9aa...) -> 6672 keys | 5461 slots | 1 slaves.
192.168.179.10:9825 (df0a8e45...) -> 6672 keys | 5462 slots | 1 slaves.
192.168.179.10:9827 (439686e1...) -> 0 keys | 0 slots | 0 slaves.         # --- 新增实例此时并没有分配slot槽位,所以现在无法写入数据
192.168.179.10:9823 (1e4432f5...) -> 6656 keys | 5461 slots | 1 slaves.
[OK] 20000 keys in 4 masters.
1.22 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.179.10:9821)
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[0-5460] (5461 slots) master1 additional replica(s)
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[5461-10922] (5462 slots) master1 additional replica(s)
M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827slots: (0 slots) master
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[10923-16383] (5461 slots) master1 additional replica(s)
S: 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

12.9.3、分配槽位

【新节点加到集群之后,默认为master节点,且没有slots,需要重新分配,添加主机之后需要对添加至集群种的新主机重新分片,否则其没有分片也就无法写入数据】

【分配槽位】
# /home/redis/src/redis-cli --cluster reshard 192.168.179.10:9821 -a 'Drms@12#$'
>>> Performing Cluster Check (using node 192.168.179.10:9821)
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[0-5460] (5461 slots) master1 additional replica(s)
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[5461-10922] (5462 slots) master1 additional replica(s)
M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827   # ID 从这获取slots: (0 slots) master
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[10923-16383] (5461 slots) master1 additional replica(s)
S: 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
[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)? 4096  #==== 输入需要新分配多少个槽位 16384 (槽总数) / 4(master数) = 4096
What is the receiving node ID? 439686e1130c6ac7a1d8b87f7d485875dc3872a3  #==== 输入新实例master的ID
Please enter all the source node IDs.Type 'all' to use all the nodes as source nodes for the hash slots. #==== 从所有节点中划分出4096个哈希槽分配给新节点Type 'done' once you entered all the source nodes IDs. #==== 从cluster删除某个主机,并将该主机上的槽位全部移动到新增节点
Source node #1: all   #==== 输入allReady to move 4096 slots.Source nodes:M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[0-5460] (5461 slots) master1 additional replica(s)M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[5461-10922] (5462 slots) master1 additional replica(s)M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[10923-16383] (5461 slots) master1 additional replica(s)Destination node:M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827slots: (0 slots) masterResharding plan:Moving slot 5461 from df0a8e4503c472be07ed2770ef435e018d07e3cc......
Do you want to proceed with the proposed reshard plan (yes/no)? yes  #==== 输入yes确认分配
Moving slot 5461 from 192.168.179.10:9825 to 192.168.179.10:9827: ..
......【确定槽位是否分配成功】
# /home/redis/src/redis-cli --cluster check 192.168.179.10:9821 -a 'Drms@12#$'
192.168.179.10:9821 (fb96a9aa...) -> 4988 keys | 4096 slots | 1 slaves.
192.168.179.10:9825 (df0a8e45...) -> 5011 keys | 4096 slots | 1 slaves.
192.168.179.10:9827 (439686e1...) -> 5000 keys | 4096 slots | 0 slaves.   #==== 槽位分配成功
192.168.179.10:9823 (1e4432f5...) -> 5001 keys | 4096 slots | 1 slaves.
[OK] 20000 keys in 4 masters.
1.22 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.179.10:9821)
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[1365-5460] (4096 slots) master1 additional replica(s)
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[6827-10922] (4096 slots) master1 additional replica(s)
M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[12288-16383] (4096 slots) master1 additional replica(s)
S: 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.【确认新master是否有数据】
# /home/redis/src/redis-cli -h 192.168.179.10 -p 9827 -a 'Drms@12#$' dbsize
(integer) 5000【给新增的master分配slave节点】
# /home/redis/src/redis-cli -c -h 192.168.179.10 -p 9821 -a 'Drms@12#$' --cluster add-node 192.168.179.10:9828 192.168.179.10:9827 --cluster-slave --cluster-master-id 439686e1130c6ac7a1d8b87f7d485875dc3872a3
>>> Adding node 192.168.179.10:9828 to cluster 192.168.179.10:9827   #==== 添加9828为9827的slave
>>> Performing Cluster Check (using node 192.168.179.10:9827)
M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[6827-10922] (4096 slots) master1 additional replica(s)
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[12288-16383] (4096 slots) master1 additional replica(s)
S: 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[1365-5460] (4096 slots) master1 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.179.10:9828 to make it join the cluster.
Waiting for the cluster to join
..
>>> Configure node as replica of 192.168.179.10:9827.
[OK] New node added correctly.【检查9828是否已添加,并作为9827的slave】
# /home/redis/src/redis-cli -h 192.168.179.10 -p 9821 -a 'Drms@12#$' cluster nodes
8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824@19824 slave fb96a9aa70b269936cd266f860e8e36960b90058 0 1661398788143 4 connected
fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821@19821 myself,master - 0 1661398788000 1 connected 1365-5460
df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825@19825 master - 0 1661398788000 7 connected 6827-10922
439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827@19827 master - 0 1661398789594 8 connected 0-1364 5461-6826 10923-12287
1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823@19823 master - 0 1661398788000 3 connected 12288-16383
6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822@19822 slave df0a8e4503c472be07ed2770ef435e018d07e3cc 0 1661398789187 7 connected
75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826@19826 slave 1e4432f5bc7fb4ecebf12291eafb987d901872f7 0 1661398789594 6 connected
fc983b60f3d81199da82871cf937c9053ce8c7a2 192.168.179.10:9828@19828 slave 439686e1130c6ac7a1d8b87f7d485875dc3872a3 0 1661398789086 8 connected  #====9827的slave

12.10、动态缩容

【删除节点需先将槽位迁移到集群中的其他节点上,然后再将其删除】

12.10.1、查看集群

# /home/redis/src/redis-cli --cluster check 192.168.179.10:9821 -a 'Drms@12#$'
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.179.10:9821 (fb96a9aa...) -> 4988 keys | 4096 slots | 1 slaves.
192.168.179.10:9825 (df0a8e45...) -> 5011 keys | 4096 slots | 1 slaves.
192.168.179.10:9827 (439686e1...) -> 5000 keys | 4096 slots | 1 slaves.      #==== 将4096个槽位迁移到其他3个节点
192.168.179.10:9823 (1e4432f5...) -> 5001 keys | 4096 slots | 1 slaves.
[OK] 20000 keys in 4 masters.
1.22 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.179.10:9821)
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[1365-5460] (4096 slots) master1 additional replica(s)
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[6827-10922] (4096 slots) master1 additional replica(s)
M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master1 additional replica(s)
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[12288-16383] (4096 slots) master1 additional replica(s)
S: 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
S: fc983b60f3d81199da82871cf937c9053ce8c7a2 192.168.179.10:9828slots: (0 slots) slavereplicates 439686e1130c6ac7a1d8b87f7d485875dc3872a3
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

12.10.2、删除槽位

12.10.2.1、分配slot给master1

【删除槽位】
# /home/redis/src/redis-cli --cluster reshard 192.168.179.10:9821 -a 'Drms@12#$'
>>> Performing Cluster Check (using node 192.168.179.10:9821)
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821   # 迁入节点IDslots:[0-5460] (5461 slots) master1 additional replica(s)
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[5461-10922] (5462 slots) master1 additional replica(s)
M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827   # 迁出节点IDslots: (0 slots) master
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[10923-16383] (5461 slots) master1 additional replica(s)
S: 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
[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)? 1366     #==== 输入4096 中的 1366 (大致均分)
What is the receiving node ID? fb96a9aa70b269936cd266f860e8e36960b90058    #==== 输入迁入节点ID
Please enter all the source node IDs.Type 'all' to use all the nodes as source nodes for the hash slots.   #==== 从所有节点中划分出4096个哈希槽分配给新节点Type 'done' once you entered all the source nodes IDs.    #==== 从cluster删除某个主机,并将该主机上的槽位全部移动到该节点
Source node #1: 439686e1130c6ac7a1d8b87f7d485875dc3872a3          #==== 输入迁出节点ID
Source node #1: done      #==== 输入doneReady to move 1366 slots.Source nodes:M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master1 additional replica(s)Destination node:M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[1365-5460] (4096 slots) master1 additional replica(s)Resharding plan:Moving slot 0 from 439686e1130c6ac7a1d8b87f7d485875dc3872a3......
Do you want to proceed with the proposed reshard plan (yes/no)? yes  #==== 输入yes确认分配
Moving slot 5461 from 192.168.179.10:9827 to 192.168.179.10:9821: ..
......【确定槽位是否分配成功】
# /home/redis/src/redis-cli --cluster check 192.168.179.10:9821 -a 'Drms@12#$'
192.168.179.10:9821 (fb96a9aa...) -> 6674 keys | 5462 slots | 1 slaves.
192.168.179.10:9825 (df0a8e45...) -> 5011 keys | 4096 slots | 1 slaves.
192.168.179.10:9827 (439686e1...) -> 3314 keys | 2730 slots | 1 slaves.   #==== 部分槽位已迁移至master1
192.168.179.10:9823 (1e4432f5...) -> 5001 keys | 4096 slots | 1 slaves.
[OK] 20000 keys in 4 masters.
1.22 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.179.10:9821)
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[0-5461] (5462 slots) master1 additional replica(s)
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[6827-10922] (4096 slots) master1 additional replica(s)
M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827slots:[5462-6826],[10923-12287] (2730 slots) master1 additional replica(s)
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[12288-16383] (4096 slots) master1 additional replica(s)
S: 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
S: fc983b60f3d81199da82871cf937c9053ce8c7a2 192.168.179.10:9828slots: (0 slots) slavereplicates 439686e1130c6ac7a1d8b87f7d485875dc3872a3
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

12.10.2.2、分配slot给master2

【删除槽位】
# /home/redis/src/redis-cli --cluster reshard 192.168.179.10:9821 -a 'Drms@12#$'
>>> Performing Cluster Check (using node 192.168.179.10:9821)
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[0-5460] (5461 slots) master1 additional replica(s)
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[5461-10922] (5462 slots) master1 additional replica(s)
M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827   # 迁出节点IDslots: (0 slots) master
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823   # 迁入节点IDslots:[10923-16383] (5461 slots) master1 additional replica(s)
S: 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
[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)? 1366     #==== 输入4096 中的 1366 (大致均分)
What is the receiving node ID? 1e4432f5bc7fb4ecebf12291eafb987d901872f7    #==== 输入迁入节点ID
Please enter all the source node IDs.Type 'all' to use all the nodes as source nodes for the hash slots.   #==== 从所有节点中划分出4096个哈希槽分配给新节点Type 'done' once you entered all the source nodes IDs.    #==== 从cluster删除某个主机,并将该主机上的槽位全部移动到该节点
Source node #1: 439686e1130c6ac7a1d8b87f7d485875dc3872a3          #==== 输入迁出节点ID
Source node #1: done      #==== 输入doneReady to move 1366 slots.Source nodes:M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master1 additional replica(s)Destination node:M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[1365-5460] (4096 slots) master1 additional replica(s)Resharding plan:Moving slot 0 from 439686e1130c6ac7a1d8b87f7d485875dc3872a3......
Do you want to proceed with the proposed reshard plan (yes/no)? yes  #==== 输入yes确认分配
Moving slot 5461 from 192.168.179.10:9827 to 192.168.179.10:9821: ..
......【确定槽位是否分配成功】
# /home/redis/src/redis-cli --cluster check 192.168.179.10:9821 -a 'Drms@12#$'
192.168.179.10:9821 (fb96a9aa...) -> 6674 keys | 5462 slots | 1 slaves.
192.168.179.10:9825 (df0a8e45...) -> 5011 keys | 4096 slots | 1 slaves.
192.168.179.10:9827 (439686e1...) -> 2716 keys | 1364 slots | 1 slaves.   #==== 部分槽位已迁移至master2
192.168.179.10:9823 (1e4432f5...) -> 6669 keys | 5462 slots | 1 slaves.
[OK] 20000 keys in 4 masters.
1.22 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.179.10:9821)
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[0-5461] (5462 slots) master1 additional replica(s)
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[6827-10922] (4096 slots) master1 additional replica(s)
M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827slots:[5462-6826],[10923-12287] (2730 slots) master1 additional replica(s)
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[12288-16383] (4096 slots) master1 additional replica(s)
S: 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
S: fc983b60f3d81199da82871cf937c9053ce8c7a2 192.168.179.10:9828slots: (0 slots) slavereplicates 439686e1130c6ac7a1d8b87f7d485875dc3872a3
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

12.10.2.3、分配slot给master3

【删除槽位】
# /home/redis/src/redis-cli --cluster reshard 192.168.179.10:9821 -a 'Drms@12#$'
>>> Performing Cluster Check (using node 192.168.179.10:9821)
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[0-5460] (5461 slots) master1 additional replica(s)
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825   # 迁入节点IDslots:[5461-10922] (5462 slots) master1 additional replica(s)
M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827   # 迁出节点IDslots: (0 slots) master
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[10923-16383] (5461 slots) master1 additional replica(s)
S: 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
[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)? 1364     #==== 输入4096 中剩余的 1364 (大致均分)
What is the receiving node ID? df0a8e4503c472be07ed2770ef435e018d07e3cc    #==== 输入迁入节点ID
Please enter all the source node IDs.Type 'all' to use all the nodes as source nodes for the hash slots.   #==== 从所有节点中划分出4096个哈希槽分配给新节点Type 'done' once you entered all the source nodes IDs.    #==== 从cluster删除某个主机,并将该主机上的槽位全部移动到该节点
Source node #1: 439686e1130c6ac7a1d8b87f7d485875dc3872a3          #==== 输入迁出节点ID
Source node #1: done      #==== 输入doneReady to move 1366 slots.Source nodes:M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master1 additional replica(s)Destination node:M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[1365-5460] (4096 slots) master1 additional replica(s)Resharding plan:Moving slot 0 from 439686e1130c6ac7a1d8b87f7d485875dc3872a3......
Do you want to proceed with the proposed reshard plan (yes/no)? yes  #==== 输入yes确认分配
Moving slot 5461 from 192.168.179.10:9827 to 192.168.179.10:9821: ..
......【确定槽位是否分配成功】
# /home/redis/src/redis-cli --cluster check 192.168.179.10:9821 -a 'Drms@12#$'
192.168.179.10:9821 (fb96a9aa...) -> 6674 keys | 5462 slots | 1 slaves.
192.168.179.10:9825 (df0a8e45...) -> 6666 keys | 5460 slots | 2 slaves. #====  slave自动切换至此master下(需要删除)
192.168.179.10:9827 (439686e1...) -> 0 keys | 0 slots | 0 slaves.     #==== 剩余槽位已迁移至master3
192.168.179.10:9823 (1e4432f5...) -> 6660 keys | 5462 slots | 1 slaves.
[OK] 20000 keys in 4 masters.
1.22 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.179.10:9821)
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[0-5461] (5462 slots) master1 additional replica(s)
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[6827-10922],[10924-12287] (5460 slots) master2 additional replica(s)
M: 439686e1130c6ac7a1d8b87f7d485875dc3872a3 192.168.179.10:9827slots: (0 slots) master
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[5462-6826],[10923],[12288-16383] (5462 slots) master1 additional replica(s)
S: 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
S: fc983b60f3d81199da82871cf937c9053ce8c7a2 192.168.179.10:9828slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

12.10.3、移除主机

【删除master 9827节点】
# /home/redis/src/redis-cli --cluster del-node 192.168.179.10:9821 439686e1130c6ac7a1d8b87f7d485875dc3872a3 -a 'Drms@12#$'
>>> Removing node 439686e1130c6ac7a1d8b87f7d485875dc3872a3 from cluster 192.168.179.10:9821
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.【删除slave 9828节点】
# /home/redis/src/redis-cli --cluster del-node 192.168.179.10:9821 fc983b60f3d81199da82871cf937c9053ce8c7a2 -a 'Drms@12#$'
>>> Removing node fc983b60f3d81199da82871cf937c9053ce8c7a2 from cluster 192.168.179.10:9821
>>> Sending CLUSTER FORGET messages to the cluster...
>>> SHUTDOWN the node.【检查集群状态,9827、9828是否移除】
# /home/redis/src/redis-cli -h 192.168.179.10 -p 9821 -a 'Drms@12#$' cluster nodes
8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824@19824 slave fb96a9aa70b269936cd266f860e8e36960b90058 0 1661404424407 9 connected
fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821@19821 myself,master - 0 1661404424000 9 connected 0-5461
df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825@19825 master - 0 1661404424000 11 connected 6827-10922 10924-12287
1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823@19823 master - 0 1661404425434 10 connected 5462-6826 10923 12288-16383
6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822@19822 slave df0a8e4503c472be07ed2770ef435e018d07e3cc 0 1661404424926 11 connected
75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826@19826 slave 1e4432f5bc7fb4ecebf12291eafb987d901872f7 0 1661404424000 10 connected【检查数据、slots是否正常】
# /home/redis/src/redis-cli --cluster check 192.168.179.10:9821 -a 'Drms@12#$'
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.179.10:9821 (fb96a9aa...) -> 6674 keys | 5462 slots | 1 slaves.
192.168.179.10:9825 (df0a8e45...) -> 6666 keys | 5460 slots | 1 slaves.
192.168.179.10:9823 (1e4432f5...) -> 6660 keys | 5462 slots | 1 slaves.
[OK] 20000 keys in 3 masters.
1.22 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.179.10:9821)
M: fb96a9aa70b269936cd266f860e8e36960b90058 192.168.179.10:9821slots:[0-5461] (5462 slots) master1 additional replica(s)
S: 8b97a9866d154781b8ca3a1e29232823ea2c106b 192.168.179.10:9824slots: (0 slots) slavereplicates fb96a9aa70b269936cd266f860e8e36960b90058
M: df0a8e4503c472be07ed2770ef435e018d07e3cc 192.168.179.10:9825slots:[6827-10922],[10924-12287] (5460 slots) master1 additional replica(s)
M: 1e4432f5bc7fb4ecebf12291eafb987d901872f7 192.168.179.10:9823slots:[5462-6826],[10923],[12288-16383] (5462 slots) master1 additional replica(s)
S: 6b70a0ebceafeaa0f804e1414f95dc17a26a81c1 192.168.179.10:9822slots: (0 slots) slavereplicates df0a8e4503c472be07ed2770ef435e018d07e3cc
S: 75dc98c54fa983e7dcf57b9e670f496e09278a85 192.168.179.10:9826slots: (0 slots) slavereplicates 1e4432f5bc7fb4ecebf12291eafb987d901872f7
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

redis-6.2.5集群部署手册相关推荐

  1. redis 3.0的集群部署

    2019独角兽企业重金招聘Python工程师标准>>> redis 3.0的集群部署 博客分类: 缓存 文章转载自:http://hot66hot.iteye.com/blog/20 ...

  2. java redis 多节点,Redis单机多节点集群部署,超简单

    1.在虚拟机中部署具有三个主节点,三个从节点的集群(注,必须要有从节点),虚拟机的IP地址为192.168.133.129,三个主节点的部口号分别为7001(从:7004).7002(从:7005). ...

  3. 泛微ecology nginx+resin集群部署手册

    目录 一.安装配置nginx 1.1拷贝nginx配置 1.2安装依赖程序包 1.3配置nginx 1.4管理nginx 二.ecology在resin集群上需要共享的资源文件 2.1资源共享设置 2 ...

  4. centos7 Redis单机多节点集群部署

    centos7 redis的安装请参考一下链接  http://blog.csdn.net/duguxingfeng/article/details/78911640 1.Reids安装包里有个集群工 ...

  5. redis 配置文件解释 以及集群部署

    redis是一款开源的.高性能的键-值存储(key-value store),和memcached类似,redis常被称作是一款key-value内存存储系统或者内存数据库,同时由于它支持丰富的数据结 ...

  6. redis 主从 + 哨兵模式集群部署(3台机器)

    前言 本文只讲如何部署,然后会贴出具体配置,以及如何验证是否部署成功(redis 版本采用 4.0.6 ).既不会介绍 redis 如何安装(本人采用源码安装方式),也不会涉及主从复制,哨兵模式具体原 ...

  7. Redis集群部署的三种模式

    一.Redis简介 Redis 是一款完全开源免费.遵守BSD协议的高性能(NOSQL)的key-value数据库.它使用ANSI C语言编写,支持网络.可基于内存亦可持久化的日志型.Key-Valu ...

  8. 堡垒机jumpserver集群部署

    本文参考老广二次开发后的堡垒机部署方案,在此基础上进行集群部署,提高其可靠性.尽管国外已经有类似的功能的堡垒机的发布,但是还是要感谢老广在百忙之中开发出更加实用的堡垒机. 本文内容虽然亲测,但内容难免 ...

  9. redis-5.0.4集群部署

    redis-5.0.4 集群搭建 redis-cluster介绍 ​ 1:redis是一个开源的key value存储系统,受到了广大互联网公司的青睐. ​ 2:redis集群采用P2P模式,是完全去 ...

  10. redis 槽点重新分配 集群_5000+字硬核干货!Redis 分布式集群部署实战

    原理: Redis集群采用一致性哈希槽的方式将集群中每个主节点都分配一定的哈希槽,对写入的数据进行哈希后分配到某个主节点进行存储. 集群使用公式(CRC16 key)& 16384计算键key ...

最新文章

  1. [转]后期-快速消除痘痘,完美修复MM肌肤
  2. 医院六级电子病历建设思路及要点
  3. 图像修复中的方法--AI智能.
  4. php 下载exe 打不开,EXE文件打不开的解决方法
  5. spyder 护眼背景
  6. 绝地求生 android版支持蓝牙吗,《绝地求生》吃鸡必须要顶配吗?这些配置也能畅玩...
  7. css 对话框阴影,科技常识:css实现不规则图形的阴影(如对话框)
  8. IOS和Android测试分别有什么侧重点?
  9. 每天一个linux命令:du 与 df
  10. echarts自适应
  11. 银行卡号识别(CTPN、Densenet、CTC)附数据集
  12. 【Unity】Unity3D RPG游戏制作实例(二)开发思路及概要设计
  13. 如何制作微信答题小程序(微信答题考试小程序开发制作功能介绍)
  14. xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  15. 读书百客:《四时田园杂兴·其一》鉴赏
  16. 占带宽测试软件,铁通网速测试
  17. 驾考记录之科目三(2021-06-16)(上海旗忠考场)
  18. 千万不要死于无知—几条健康忠告(三)
  19. 【Kay】Java的一些Bonus
  20. 滴滴治理算法探索与实践

热门文章

  1. nginx的安装和配置
  2. 【经验贴】小汽车科目二科目三 经验
  3. KUCAS清关文件申请形式 TER与TIR认证介绍
  4. 错误记录:FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecate
  5. 手机充值 html,仿京东手机充值进度导航_html/css_WEB-ITnose
  6. kettle- linux定时执行ktr shell脚本
  7. 这可能是关于 TCP 和 UDP 最好的一篇文章!!
  8. PHP获取服务器图片并添加水印
  9. HTML中基于表单的文件上传(post,get)
  10. CentOS7下collectd简单安装使用