❤️作者简介:2022新星计划第三季云原生与云计算赛道Top5、华为云享专家、云原生领域潜力新星
博客首页:C站个人主页
作者目的:如有错误请指正,将来会不断的完善笔记,帮助更多的Java爱好者入门,共同进步!
本博文一共有6篇,如下
等你对Docker有一定理解的时候可以看高级篇,不过不太建议。
剧透:未来将出云原生技术-Kubernetes(k8s),此时的你可以对Docker进行统一管理、动态扩缩容等等。
看完之后你会对Docker有一定的理解,并能熟练的使用Docker进行容器化开发、以及Docker部署微服务、Docker网络等等。干起来!
Pivotal公司的Matt Stine于2013年首次提出云原生(Cloud-Native)的概念;2015年,云原生刚推广时,Matt Stine在《迁移到云原生架构》一书中定义了符合云原生架构的几个特征:12因素、微服务、自敏捷架构、基于API协作、扛脆弱性;到了2017年,Matt Stine在接受InfoQ采访时又改了口风,将云原生架构归纳为模块化、可观察、可部署、可测试、可替换、可处理6特质;而Pivotal最新官网对云原生概括为4个要点:DevOps+持续交付+微服务+容器。
总而言之,符合云原生架构的应用程序应该是:采用开源堆栈(K8S+Docker)进行容器化,基于微服务架构提高灵活性和可维护性,借助敏捷方法、DevOps支持持续迭代和运维自动化,利用云平台设施实现弹性伸缩、动态调度、优化资源利用率。
(此处摘选自《知乎-华为云官方帐号》)
总而言之:
Docker是一个高性能的容器引擎;
可以把本地源代码、配置文件、依赖、环境通通打包成一个容器即可以到处运行;
使用Docker安装软件十分方便,而且安装的软件十分精简,方便扩展。
docker run -p 3307:3306 \
-v /my-sql/mysql-master/log:/var/log/mysql \
-v /my-sql/mysql-master/data:/var/lib/mysql \
-v /my-sql/mysql-master/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
--name mysql-master \
-d mysql:5.7
vim /my-sql/mysql-master/conf/my.cnf
[client]
# 指定编码格式为utf8,默认的MySQL会有中文乱码问题
default_character_set=utf8
[mysqld]
collation_server=utf8_general_ci
character_set_server=utf8
# 全局唯一id(不允许有相同的)
server_id=200
binlog-ignore-db=mysql
# 指定MySQL二进制日志
log-bin=order-mysql-bin
# binlog最大容量
binlog_cache_size=1M
# 二进制日志格式(这里指定的是混合日志)
binlog_format=mixed
# binlog的有效期(单位:天)
expire_logs_days=7
slave_skip_errors=1062
docker restart mysql-master
$ docker exec -it mysql-master /bin/bash
$ mysql -uroot -p
在主数据库创建的该帐号密码只是用来进行同步数据。
create user 'slave'@'%' identified by '123456';
grant replication slave, replication client on *.* to 'slave'@'%';
docker run -p 3308:3306 \
-v /my-sql/mysql-slave/log:/var/log/mysql \
-v /my-sql/mysql-slave/data:/var/lib/mysql \
-v /my-sql/mysql-slave/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
--name mysql-slave \
-d mysql:5.7
vim /my-sql/mysql-slave/conf/my.cnf
[client]
# 指定编码格式为utf8,默认的MySQL会有中文乱码问题
default_character_set=utf8
[mysqld]
collation_server=utf8_general_ci
character_set_server=utf8
# 全局唯一id(不允许有相同的)
server_id=201
binlog-ignore-db=mysql
# 指定MySQL二进制日志
log-bin=order-mysql-bin
# binlog最大容量
binlog_cache_size=1M
# 二进制日志格式(这里指定的是混合日志)
binlog_format=mixed
# binlog的有效期(单位:天)
expire_logs_days=7
slave_skip_errors=1062
# 表示slave将复制事件写进自己的二进制日志
log_slave_updates=1
# 表示从机只能读
read_only=1
docker restart mysql-slave
[root@aubin ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2c4136668536 mysql:5.7 "docker-entrypoint.s…" 3 minutes ago Up 9 seconds 33060/tcp, 0.0.0.0:3308->3306/tcp, :::3308->3306/tcp mysql-slave
20fc7174d1a7 mysql:5.7 "docker-entrypoint.s…" 15 hours ago Up 8 minutes 33060/tcp, 0.0.0.0:3307->3306/tcp, :::3307->3306/tcp mysql-master
mysql> show master status;
+------------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------------+----------+--------------+------------------+-------------------+
| order-mysql-bin.000001 | 617 | | mysql | |
+------------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
$ docker exec -it mysql-slave /bin/bash
$ mysql -uroot -p
在Master节点中找到ens33的ip地址并放到下面的master_host中(记住这个ip是Master数据库的服务器ip,不是从数据库的):
[root@aubin ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.184.132 netmask 255.255.255.0 broadcast 192.168.184.255
inet6 fe80::5c87:5037:8d1d:7650 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:23:28:59 txqueuelen 1000 (Ethernet)
RX packets 4186 bytes 443992 (433.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3146 bytes 428816 (418.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
记住下面这个命令要在从(slave)数据库执行:
change master to master_host='192.168.184.132',master_user='slave',master_password='123456',master_port=3307,master_log_file='order-mysql-bin.000001',master_log_pos=617,master_connect_retry=30;
配置参数解析
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 192.168.184.132
Master_User: slave
Master_Port: 3307
Connect_Retry: 30
Master_Log_File: order-mysql-bin.000001
Read_Master_Log_Pos: 617
Relay_Log_File: 2c4136668536-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: order-mysql-bin.000001
Slave_IO_Running: No
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 617
Relay_Log_Space: 154
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 0
Master_UUID:
Master_Info_File: /var/lib/mysql/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State:
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
1 row in set (0.00 sec)
我们找到里面的Slave_IO_Running: No,Slave_SQL_Running: No属性,发现都是No的状态,证明主从同步还没有开始。。。
start slave;
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.184.132
Master_User: slave
Master_Port: 3307
Connect_Retry: 30
Master_Log_File: order-mysql-bin.000001
Read_Master_Log_Pos: 617
Relay_Log_File: 2c4136668536-relay-bin.000002
Relay_Log_Pos: 326
Relay_Master_Log_File: order-mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
.......
我们可以看到已经都为yes了,说明主从同步已经开启。
在Master数据库执行:
create database mall;
use mall;
CREATE TABLE `order` (
`id` bigint(20) NOT NULL,
`imgUrl` varchar(255) NOT NULL,
`goodsInfo` varchar(255) NOT NULL,
`goodsParams` varchar(255) DEFAULT NULL,
`goodsCount` int(20) NOT NULL,
`singleGoodsMoney` decimal(10,2) NOT NULL,
`realname` varchar(255) NOT NULL,
`phone` varchar(255) NOT NULL,
`address` text NOT NULL,
`created` datetime DEFAULT NULL COMMENT '创建时间',
`userid` bigint(20) NOT NULL,
`productid` bigint(20) NOT NULL,
`statusid` bigint(20) NOT NULL COMMENT '订单状态',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO `order` VALUES (3655575498130437, 'http://localhost/static/img/nav/max.jpg', '小米Max', '全网通 4GB内存+64GB容量 指纹识别 黑色 每月20G流量套餐', 2, 2998.00, '张三', '123123666', '广东省河源市源城区', '2021-11-26 16:40:57', 1, 1, 2);
INSERT INTO `order` VALUES (3655575610852357, 'http://localhost/static/img/nav/max.jpg', '小米Max', '全网通 4GB内存+64GB容量 指纹识别 黑色 每月20G流量套餐', 2, 2998.00, '张三', '123123666', '广东省河源市源城区', '2021-11-26 16:40:59', 1, 1, 6);
INSERT INTO `order` VALUES (3672761237177349, 'http://localhost/static/img/nav/max.jpg', '小米Max', '全网通 4GB内存+64GB容量 指纹识别 黑色 每月20G流量套餐', 2, 2998.00, '张三', '123123666', '广东省河源市源城区', '2021-11-29 17:31:31', 1, 1, 6);
INSERT INTO `order` VALUES (3678103231529989, 'http://localhost/static/img/nav/max.jpg', '小米Max', '全网通 4GB内存+64GB容量 指纹识别 黑色 每月20G流量套餐', 1, 1499.00, '张三', '123123666', '广东省河源市源城区', '2021-11-30 16:10:03', 1, 1, 6);
INSERT INTO `order` VALUES (3678347308893189, 'http://localhost/static/img/nav/mi5.jpg', '小米手机5', '标准版', 1, 1999.00, '张三', '123123666', '广东省河源市源城区', '2021-11-30 17:12:07', 1, 2, 4);
mysql> select * from `order`;
+------------------+-----------------------------------------+-----------+-----------------+------------+------------------+----------+-----------+---------+---------------------+--------+-----------+----------+
| id | imgUrl | goodsInfo | goodsParams | goodsCount | singleGoodsMoney | realname | phone | address | created | userid | productid | statusid |
+------------------+-----------------------------------------+-----------+-----------------+------------+------------------+----------+-----------+---------+---------------------+--------+-----------+----------+
| 3655575498130437 | http://localhost/static/img/nav/max.jpg | Max | 4GB+64GB 20G | 2 | 2998.00 | | 123123666 | | 2021-11-26 16:40:57 | 1 | 1 | 2 |
| 3655575610852357 | http://localhost/static/img/nav/max.jpg | Max | 4GB+64GB 20G | 2 | 2998.00 | | 123123666 | | 2021-11-26 16:40:59 | 1 | 1 | 6 |
| 3672761237177349 | http://localhost/static/img/nav/max.jpg | Max | 4GB+64GB 20G | 2 | 2998.00 | | 123123666 | | 2021-11-29 17:31:31 | 1 | 1 | 6 |
| 3678103231529989 | http://localhost/static/img/nav/max.jpg | Max | 4GB+64GB 20G | 1 | 1499.00 | | 123123666 | | 2021-11-30 16:10:03 | 1 | 1 | 6 |
| 3678347308893189 | http://localhost/static/img/nav/mi5.jpg | 5 | | 1 | 1999.00 | | 123123666 | | 2021-11-30 17:12:07 | 1 | 2 | 4 |
+------------------+-----------------------------------------+-----------+-----------------+------------+------------------+----------+-----------+---------+---------------------+--------+-----------+----------+
5 rows in set (0.00 sec)
mysql> use mall;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from `order`;
+------------------+-----------------------------------------+-----------+-----------------+------------+------------------+----------+-----------+---------+---------------------+--------+-----------+----------+
| id | imgUrl | goodsInfo | goodsParams | goodsCount | singleGoodsMoney | realname | phone | address | created | userid | productid | statusid |
+------------------+-----------------------------------------+-----------+-----------------+------------+------------------+----------+-----------+---------+---------------------+--------+-----------+----------+
| 3655575498130437 | http://localhost/static/img/nav/max.jpg | Max | 4GB+64GB 20G | 2 | 2998.00 | | 123123666 | | 2021-11-26 16:40:57 | 1 | 1 | 2 |
| 3655575610852357 | http://localhost/static/img/nav/max.jpg | Max | 4GB+64GB 20G | 2 | 2998.00 | | 123123666 | | 2021-11-26 16:40:59 | 1 | 1 | 6 |
| 3672761237177349 | http://localhost/static/img/nav/max.jpg | Max | 4GB+64GB 20G | 2 | 2998.00 | | 123123666 | | 2021-11-29 17:31:31 | 1 | 1 | 6 |
| 3678103231529989 | http://localhost/static/img/nav/max.jpg | Max | 4GB+64GB 20G | 1 | 1499.00 | | 123123666 | | 2021-11-30 16:10:03 | 1 | 1 | 6 |
| 3678347308893189 | http://localhost/static/img/nav/mi5.jpg | 5 | | 1 | 1999.00 | | 123123666 | | 2021-11-30 17:12:07 | 1 | 2 | 4 |
+------------------+-----------------------------------------+-----------+-----------------+------------+------------------+----------+-----------+---------+---------------------+--------+-----------+----------+
5 rows in set (0.00 sec)
也可以用Navicat去连接这两个数据库。如果Navicat出现连接不了docker的mysql,则可以:
方法一:关闭防火墙(测试环境用,生产环境不可以用)
sudo systemctl stop firewalld
方法二:开放防火墙对应端口,比如master数据库的3307和slave数据库的3308(生产环境用这个)
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.184.132
Master_User: slave
Master_Port: 3307
Connect_Retry: 30
Master_Log_File: order-mysql-bin.000001
Read_Master_Log_Pos: 3752
Relay_Log_File: 2c4136668536-relay-bin.000002
Relay_Log_Pos: 326
Relay_Master_Log_File: order-mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: No
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 1007
Last_Error: Error 'Can't create database 'mall'; database exists' on query. Default database: 'mall'. Query: 'create database mall'
1:把主数据库和从数据库变成一模一样,也就是把多余的数据库和表删除掉,变成默认的mysql状态。(切记生产环境下要做好数据备份!!!)
2:结束同步:
stop slave;
3:再次开启同步:
start slave;
4:搞定!
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.184.132
Master_User: slave
Master_Port: 3307
Connect_Retry: 30
Master_Log_File: order-mysql-bin.000001
Read_Master_Log_Pos: 3752
Relay_Log_File: 2c4136668536-relay-bin.000003
Relay_Log_Pos: 326
Relay_Master_Log_File: order-mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
过程
缺点:
图解:
先虚拟一个哈希环,记录我们机器的ip的hash对应到哈希环中:
将对象的关键字key进行hash,顺时针寻找我们的机器,如果机器还在线就插入:
过程
优点:
缺点:
docker run -d \
--name redis-node-1 \
--net host \
--privileged=true \
-v /data/redis/share/redis-node-1:/data \
redis:latest \
--cluster-enabled yes \
--appendonly yes \
--port 6381
docker run -d \
--name redis-node-2 \
--net host \
--privileged=true \
-v /data/redis/share/redis-node-2:/data \
redis:latest \
--cluster-enabled yes \
--appendonly yes \
--port 6382
docker run -d \
--name redis-node-3 \
--net host \
--privileged=true \
-v /data/redis/share/redis-node-3:/data \
redis:latest \
--cluster-enabled yes \
--appendonly yes \
--port 6383
docker run -d \
--name redis-node-4 \
--net host \
--privileged=true \
-v /data/redis/share/redis-node-4:/data \
redis:latest \
--cluster-enabled yes \
--appendonly yes \
--port 6384
docker run -d \
--name redis-node-5 \
--net host \
--privileged=true \
-v /data/redis/share/redis-node-5:/data \
redis:latest \
--cluster-enabled yes \
--appendonly yes \
--port 6385
docker run -d \
--name redis-node-6 \
--net host \
--privileged=true \
-v /data/redis/share/redis-node-6:/data \
redis:latest \
--cluster-enabled yes \
--appendonly yes \
--port 6386
docker run -d \
--name redis-node-7 \
--net host \
--privileged=true \
-v /data/redis/share/redis-node-7:/data \
redis:latest \
--cluster-enabled yes \
--appendonly yes \
--port 6387
docker run -d \
--name redis-node-8 \
--net host \
--privileged=true \
-v /data/redis/share/redis-node-8:/data \
redis:latest \
--cluster-enabled yes \
--appendonly yes \
--port 6388
docker run -d \
--name redis-node-9 \
--net host \
--privileged=true \
-v /data/redis/share/redis-node-9:/data \
redis:latest \
--cluster-enabled yes \
--appendonly yes \
--port 6389
[root@aubin ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
73caff0968f1 redis:latest "docker-entrypoint.s…" 4 seconds ago Up 4 seconds redis-node-9
c8c5bd1034b4 redis:latest "docker-entrypoint.s…" 5 seconds ago Up 5 seconds redis-node-8
c7cf3d764f65 redis:latest "docker-entrypoint.s…" 6 seconds ago Up 5 seconds redis-node-7
98dcf5fd80d7 redis:latest "docker-entrypoint.s…" 6 seconds ago Up 5 seconds redis-node-6
7035e4a73a83 redis:latest "docker-entrypoint.s…" 6 seconds ago Up 5 seconds redis-node-5
7ae839c95a0c redis:latest "docker-entrypoint.s…" 6 seconds ago Up 5 seconds redis-node-4
87f841d136b9 redis:latest "docker-entrypoint.s…" 6 seconds ago Up 6 seconds redis-node-3
98e605469e0e redis:latest "docker-entrypoint.s…" 6 seconds ago Up 6 seconds redis-node-2
69eec71b0835 redis:latest "docker-entrypoint.s…" 7 seconds ago Up 6 seconds redis-node-1
docker exec -it redis-node-2 /bin/bash
redis-cli --cluster create 192.168.184.132:6381 192.168.184.132:6382 192.168.184.132:6383 192.168.184.132:6384 192.168.184.132:6385 192.168.184.132:6386 192.168.184.132:6387 192.168.184.132:6388 192.168.184.132:6389 --cluster-replicas 2
>>> Performing hash slots allocation on 9 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 192.168.184.132:6385 to 192.168.184.132:6381
Adding replica 192.168.184.132:6386 to 192.168.184.132:6381
Adding replica 192.168.184.132:6387 to 192.168.184.132:6382
Adding replica 192.168.184.132:6388 to 192.168.184.132:6382
Adding replica 192.168.184.132:6389 to 192.168.184.132:6383
Adding replica 192.168.184.132:6384 to 192.168.184.132:6383
>>> Trying to optimize slaves allocation for anti-affinity
[WARNING] Some slaves are in the same host as their master
M: 888158ad30d9a173175b115974b9d1cc5b39736e 192.168.184.132:6381
slots:[0-5460] (5461 slots) master
M: 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 192.168.184.132:6382
slots:[5461-10922] (5462 slots) master
M: af28288480e3398b18402e4475c9ae52c39ea776 192.168.184.132:6383
slots:[10923-16383] (5461 slots) master
S: a11993ddc7a726e3ad476858fb53bdc97d4834b8 192.168.184.132:6384
replicates 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e
S: c9d7f4ed642fa2fde013f2b060476b542b9af76e 192.168.184.132:6385
replicates af28288480e3398b18402e4475c9ae52c39ea776
S: 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 192.168.184.132:6386
replicates 888158ad30d9a173175b115974b9d1cc5b39736e
S: 5b20d04646f7f38eb57266b81749e565825ab6e5 192.168.184.132:6387
replicates 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e
S: 92d06bfb428a1358149c209c336152cae3304c66 192.168.184.132:6388
replicates af28288480e3398b18402e4475c9ae52c39ea776
S: 9ef7a5bb156de64a969688eade8535399983dd00 192.168.184.132:6389
replicates 888158ad30d9a173175b115974b9d1cc5b39736e
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.184.132:6381)
M: 888158ad30d9a173175b115974b9d1cc5b39736e 192.168.184.132:6381
slots:[0-5460] (5461 slots) master
2 additional replica(s)
S: 9ef7a5bb156de64a969688eade8535399983dd00 192.168.184.132:6389
slots: (0 slots) slave
replicates 888158ad30d9a173175b115974b9d1cc5b39736e
S: 92d06bfb428a1358149c209c336152cae3304c66 192.168.184.132:6388
slots: (0 slots) slave
replicates af28288480e3398b18402e4475c9ae52c39ea776
S: c9d7f4ed642fa2fde013f2b060476b542b9af76e 192.168.184.132:6385
slots: (0 slots) slave
replicates af28288480e3398b18402e4475c9ae52c39ea776
M: 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 192.168.184.132:6382
slots:[5461-10922] (5462 slots) master
2 additional replica(s)
S: a11993ddc7a726e3ad476858fb53bdc97d4834b8 192.168.184.132:6384
slots: (0 slots) slave
replicates 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e
M: af28288480e3398b18402e4475c9ae52c39ea776 192.168.184.132:6383
slots:[10923-16383] (5461 slots) master
2 additional replica(s)
S: 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 192.168.184.132:6386
slots: (0 slots) slave
replicates 888158ad30d9a173175b115974b9d1cc5b39736e
S: 5b20d04646f7f38eb57266b81749e565825ab6e5 192.168.184.132:6387
slots: (0 slots) slave
replicates 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
redis-cli -p 6381 -c
192.168.184.132:6381> set k1 v1
-> Redirected to slot [12706] located at 192.168.184.132:6383
OK
192.168.184.132:6383> set k2 v2
-> Redirected to slot [449] located at 192.168.184.132:6381
OK
192.168.184.132:6381> set k3 v3
OK
192.168.184.132:6381> get k1
-> Redirected to slot [12706] located at 192.168.184.132:6383
"v1"
192.168.184.132:6383> get k2
-> Redirected to slot [449] located at 192.168.184.132:6381
"v2"
192.168.184.132:6381> get k3
"v3"
redis-cli -p 6381 -c
192.168.184.132:6381> cluster nodes
9ef7a5bb156de64a969688eade8535399983dd00 192.168.184.132:6389@16389 slave 888158ad30d9a173175b115974b9d1cc5b39736e 0 1651761707000 1 connected
888158ad30d9a173175b115974b9d1cc5b39736e 192.168.184.132:6381@16381 myself,master - 0 1651761703000 1 connected 0-5460
92d06bfb428a1358149c209c336152cae3304c66 192.168.184.132:6388@16388 slave af28288480e3398b18402e4475c9ae52c39ea776 0 1651761706000 3 connected
c9d7f4ed642fa2fde013f2b060476b542b9af76e 192.168.184.132:6385@16385 slave af28288480e3398b18402e4475c9ae52c39ea776 0 1651761708298 3 connected
1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 192.168.184.132:6382@16382 master - 0 1651761704000 2 connected 5461-10922
a11993ddc7a726e3ad476858fb53bdc97d4834b8 192.168.184.132:6384@16384 slave 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 0 1651761708000 2 connected
af28288480e3398b18402e4475c9ae52c39ea776 192.168.184.132:6383@16383 master - 0 1651761708000 3 connected 10923-16383
29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 192.168.184.132:6386@16386 slave 888158ad30d9a173175b115974b9d1cc5b39736e 0 1651761710336 1 connected
5b20d04646f7f38eb57266b81749e565825ab6e5 192.168.184.132:6387@16387 slave 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 0 1651761709314 2 connected
root@aubin:/data# redis-cli --cluster check 192.168.184.132:6381
192.168.184.132:6381 (888158ad...) -> 2 keys | 5461 slots | 2 slaves.
192.168.184.132:6382 (1ff5a2a1...) -> 0 keys | 5462 slots | 2 slaves.
192.168.184.132:6383 (af282884...) -> 1 keys | 5461 slots | 2 slaves.
[OK] 3 keys in 3 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.184.132:6381)
M: 888158ad30d9a173175b115974b9d1cc5b39736e 192.168.184.132:6381
slots:[0-5460] (5461 slots) master
2 additional replica(s)
S: 9ef7a5bb156de64a969688eade8535399983dd00 192.168.184.132:6389
slots: (0 slots) slave
replicates 888158ad30d9a173175b115974b9d1cc5b39736e
S: 92d06bfb428a1358149c209c336152cae3304c66 192.168.184.132:6388
slots: (0 slots) slave
replicates af28288480e3398b18402e4475c9ae52c39ea776
S: c9d7f4ed642fa2fde013f2b060476b542b9af76e 192.168.184.132:6385
slots: (0 slots) slave
replicates af28288480e3398b18402e4475c9ae52c39ea776
M: 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 192.168.184.132:6382
slots:[5461-10922] (5462 slots) master
2 additional replica(s)
S: a11993ddc7a726e3ad476858fb53bdc97d4834b8 192.168.184.132:6384
slots: (0 slots) slave
replicates 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e
M: af28288480e3398b18402e4475c9ae52c39ea776 192.168.184.132:6383
slots:[10923-16383] (5461 slots) master
2 additional replica(s)
S: 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 192.168.184.132:6386
slots: (0 slots) slave
replicates 888158ad30d9a173175b115974b9d1cc5b39736e
S: 5b20d04646f7f38eb57266b81749e565825ab6e5 192.168.184.132:6387
slots: (0 slots) slave
replicates 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
127.0.0.1:6382> CLUSTER NODES
29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 192.168.184.132:6386@16386 slave 888158ad30d9a173175b115974b9d1cc5b39736e 0 1651766520602 1 connected
a11993ddc7a726e3ad476858fb53bdc97d4834b8 192.168.184.132:6384@16384 slave 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 0 1651766520000 2 connected
c9d7f4ed642fa2fde013f2b060476b542b9af76e 192.168.184.132:6385@16385 slave af28288480e3398b18402e4475c9ae52c39ea776 0 1651766521621 3 connected
9ef7a5bb156de64a969688eade8535399983dd00 192.168.184.132:6389@16389 slave 888158ad30d9a173175b115974b9d1cc5b39736e 0 1651766516521 1 connected
92d06bfb428a1358149c209c336152cae3304c66 192.168.184.132:6388@16388 slave af28288480e3398b18402e4475c9ae52c39ea776 0 1651766522638 3 connected
5b20d04646f7f38eb57266b81749e565825ab6e5 192.168.184.132:6387@16387 slave 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 0 1651766519000 2 connected
af28288480e3398b18402e4475c9ae52c39ea776 192.168.184.132:6383@16383 master - 0 1651766521000 3 connected 10923-16383
1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 192.168.184.132:6382@16382 myself,master - 0 1651766519000 2 connected 5461-10922
888158ad30d9a173175b115974b9d1cc5b39736e 192.168.184.132:6381@16381 master - 0 1651766518571 1 connected 0-5460
可以看出6381的从节点是:6389、6386
把6381的容器实例给stop掉。
docker stop redis-node-1
192.168.184.132:6383> CLUSTER NODES
c9d7f4ed642fa2fde013f2b060476b542b9af76e 192.168.184.132:6385@16385 slave af28288480e3398b18402e4475c9ae52c39ea776 0 1651767445299 3 connected
9ef7a5bb156de64a969688eade8535399983dd00 192.168.184.132:6389@16389 slave 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 0 1651767443000 10 connected
888158ad30d9a173175b115974b9d1cc5b39736e 192.168.184.132:6381@16381 master,fail - 1651767320800 1651767314000 1 disconnected
1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 192.168.184.132:6382@16382 master - 0 1651767444000 2 connected 5461-10922
29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 192.168.184.132:6386@16386 master - 0 1651767444000 10 connected 0-5460
92d06bfb428a1358149c209c336152cae3304c66 192.168.184.132:6388@16388 slave af28288480e3398b18402e4475c9ae52c39ea776 0 1651767443000 3 connected
af28288480e3398b18402e4475c9ae52c39ea776 192.168.184.132:6383@16383 myself,master - 0 1651767443000 3 connected 10923-16383
5b20d04646f7f38eb57266b81749e565825ab6e5 192.168.184.132:6387@16387 slave 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 0 1651767444284 2 connected
a11993ddc7a726e3ad476858fb53bdc97d4834b8 192.168.184.132:6384@16384 slave 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 0 1651767446319 2 connected
我们可以看到以前6381的从节点6386变成了Master节点。说明已经进行主从切换了。
docker start redis-node-1
192.168.184.132:6383> CLUSTER NODES
c9d7f4ed642fa2fde013f2b060476b542b9af76e 192.168.184.132:6385@16385 slave af28288480e3398b18402e4475c9ae52c39ea776 0 1651767586000 3 connected
9ef7a5bb156de64a969688eade8535399983dd00 192.168.184.132:6389@16389 slave 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 0 1651767586183 10 connected
888158ad30d9a173175b115974b9d1cc5b39736e 192.168.184.132:6381@16381 slave 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 0 1651767582247 10 connected
1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 192.168.184.132:6382@16382 master - 0 1651767586000 2 connected 5461-10922
29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 192.168.184.132:6386@16386 master - 0 1651767588204 10 connected 0-5460
92d06bfb428a1358149c209c336152cae3304c66 192.168.184.132:6388@16388 slave af28288480e3398b18402e4475c9ae52c39ea776 0 1651767586000 3 connected
af28288480e3398b18402e4475c9ae52c39ea776 192.168.184.132:6383@16383 myself,master - 0 1651767587000 3 connected 10923-16383
5b20d04646f7f38eb57266b81749e565825ab6e5 192.168.184.132:6387@16387 slave 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 0 1651767585000 2 connected
a11993ddc7a726e3ad476858fb53bdc97d4834b8 192.168.184.132:6384@16384 slave 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 0 1651767587192 2 connected
我们可以看到6381变成了从节点(slave),主节点(Master)是6386。
docker run -d \
--name redis-node-10 \
--net host \
--privileged=true \
-v /data/redis/share/redis-node-10:/data \
redis:latest \
--cluster-enabled yes \
--appendonly yes \
--port 6390
docker run -d \
--name redis-node-11 \
--net host \
--privileged=true \
-v /data/redis/share/redis-node-11:/data \
redis:latest \
--cluster-enabled yes \
--appendonly yes \
--port 6391
docker run -d \
--name redis-node-12 \
--net host \
--privileged=true \
-v /data/redis/share/redis-node-12:/data \
redis:latest \
--cluster-enabled yes \
--appendonly yes \
--port 6392
[root@aubin ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2d51b83798fc redis:latest "docker-entrypoint.s…" 7 seconds ago Up 6 seconds redis-node-12
7155d53bda8f redis:latest "docker-entrypoint.s…" 8 seconds ago Up 7 seconds redis-node-11
80f3006ff904 redis:latest "docker-entrypoint.s…" 8 seconds ago Up 7 seconds redis-node-10
79af920ed704 redis:latest "docker-entrypoint.s…" 13 seconds ago Up 12 seconds redis-node-9
8476f6db25f1 redis:latest "docker-entrypoint.s…" 14 seconds ago Up 13 seconds redis-node-8
dbcee539c3d4 redis:latest "docker-entrypoint.s…" 14 seconds ago Up 13 seconds redis-node-7
3883016c4225 redis:latest "docker-entrypoint.s…" 14 seconds ago Up 13 seconds redis-node-6
073b551c8366 redis:latest "docker-entrypoint.s…" 14 seconds ago Up 14 seconds redis-node-5
0114f11f42ae redis:latest "docker-entrypoint.s…" 14 seconds ago Up 14 seconds redis-node-4
bd9b8fd9aa8b redis:latest "docker-entrypoint.s…" 15 seconds ago Up 14 seconds redis-node-3
f1e90ded9cb3 redis:latest "docker-entrypoint.s…" 15 seconds ago Up 14 seconds redis-node-2
f9c61333faae redis:latest "docker-entrypoint.s…" 15 seconds ago Up 15 seconds redis-node-1
docker exec -it redis-node-10 /bin/bash
redis-cli --cluster add-node 192.168.184.132:6390 192.168.184.132:6383
root@aubin:/data# redis-cli --cluster check 192.168.184.132:6383
192.168.184.132:6383 (af282884...) -> 2 keys | 5461 slots | 2 slaves.
192.168.184.132:6382 (1ff5a2a1...) -> 0 keys | 5462 slots | 2 slaves.
192.168.184.132:6386 (29a79c9f...) -> 3 keys | 5461 slots | 2 slaves.
192.168.184.132:6390 (a25da2e5...) -> 0 keys | 0 slots | 0 slaves.
[OK] 5 keys in 4 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.184.132:6383)
M: af28288480e3398b18402e4475c9ae52c39ea776 192.168.184.132:6383
slots:[10923-16383] (5461 slots) master
2 additional replica(s)
S: a11993ddc7a726e3ad476858fb53bdc97d4834b8 192.168.184.132:6384
slots: (0 slots) slave
replicates 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e
S: 888158ad30d9a173175b115974b9d1cc5b39736e 192.168.184.132:6381
slots: (0 slots) slave
replicates 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2
S: 5b20d04646f7f38eb57266b81749e565825ab6e5 192.168.184.132:6387
slots: (0 slots) slave
replicates 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e
S: c9d7f4ed642fa2fde013f2b060476b542b9af76e 192.168.184.132:6385
slots: (0 slots) slave
replicates af28288480e3398b18402e4475c9ae52c39ea776
S: 92d06bfb428a1358149c209c336152cae3304c66 192.168.184.132:6388
slots: (0 slots) slave
replicates af28288480e3398b18402e4475c9ae52c39ea776
M: 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 192.168.184.132:6382
slots:[5461-10922] (5462 slots) master
2 additional replica(s)
M: 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 192.168.184.132:6386
slots:[0-5460] (5461 slots) master
2 additional replica(s)
S: 9ef7a5bb156de64a969688eade8535399983dd00 192.168.184.132:6389
slots: (0 slots) slave
replicates 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2
M: a25da2e5be0487b3109b23e807b2d4c9c23e5a1a 192.168.184.132:6390
slots: (0 slots) master
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
发现6390已经成功加入到集群,并且是Master节点,但是没有被分配槽位,slots为0。需要分配槽位才有用
redis-cli --cluster reshard 192.168.184.132:6386
提示:How many slots do you want to move (from 1 to 16384)?
因为我们是4个Master节点,所以是16384/4=4096,所以输入:4096
再输入新加入的6390Master节点的容器id,输入:a25da2e5be0487b3109b23e807b2d4c9c23e5a1a
再输入:all ,回车
输入:yes
检查一下集群:
root@aubin:/data# redis-cli --cluster check 192.168.184.132:6390
192.168.184.132:6390 (a25da2e5...) -> 1 keys | 4096 slots | 1 slaves.
192.168.184.132:6386 (29a79c9f...) -> 2 keys | 4096 slots | 2 slaves.
192.168.184.132:6382 (1ff5a2a1...) -> 0 keys | 4096 slots | 1 slaves.
192.168.184.132:6383 (af282884...) -> 2 keys | 4096 slots | 2 slaves.
[OK] 5 keys in 4 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.184.132:6390)
M: a25da2e5be0487b3109b23e807b2d4c9c23e5a1a 192.168.184.132:6390
slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master
1 additional replica(s)
M: 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 192.168.184.132:6386
slots:[1365-5460] (4096 slots) master
2 additional replica(s)
S: 92d06bfb428a1358149c209c336152cae3304c66 192.168.184.132:6388
slots: (0 slots) slave
replicates af28288480e3398b18402e4475c9ae52c39ea776
M: 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 192.168.184.132:6382
slots:[6827-10922] (4096 slots) master
1 additional replica(s)
M: af28288480e3398b18402e4475c9ae52c39ea776 192.168.184.132:6383
slots:[12288-16383] (4096 slots) master
2 additional replica(s)
S: c9d7f4ed642fa2fde013f2b060476b542b9af76e 192.168.184.132:6385
slots: (0 slots) slave
replicates af28288480e3398b18402e4475c9ae52c39ea776
S: 5b20d04646f7f38eb57266b81749e565825ab6e5 192.168.184.132:6387
slots: (0 slots) slave
replicates a25da2e5be0487b3109b23e807b2d4c9c23e5a1a
S: 888158ad30d9a173175b115974b9d1cc5b39736e 192.168.184.132:6381
slots: (0 slots) slave
replicates 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2
S: a11993ddc7a726e3ad476858fb53bdc97d4834b8 192.168.184.132:6384
slots: (0 slots) slave
replicates 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e
S: 9ef7a5bb156de64a969688eade8535399983dd00 192.168.184.132:6389
slots: (0 slots) slave
replicates 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
搞定,扩容成功。
添加6390的从节点(6391和6392)
xxxxx1和xxxxx2替换成:6390(也就是想加入的Master节点)的id
redis-cli --cluster add-node 192.168.184.132:6391 192.168.184.132:6390 --cluster-slave --cluster-master-id xxxxx1
#比如添加6391
redis-cli --cluster add-node 192.168.184.132:6391 192.168.184.132:6390 --cluster-slave --cluster-master-id a25da2e5be0487b3109b23e807b2d4c9c23e5a1a
-----------------------------
redis-cli --cluster add-node 192.168.184.132:6392 192.168.184.132:6390 --cluster-slave --cluster-master-id xxxxx2
#比如添加6392
redis-cli --cluster add-node 192.168.184.132:6392 192.168.184.132:6390 --cluster-slave --cluster-master-id a25da2e5be0487b3109b23e807b2d4c9c23e5a1a
root@aubin:/data# redis-cli --cluster check 192.168.184.132:6390
192.168.184.132:6390 (a25da2e5...) -> 1 keys | 4096 slots | 3 slaves.
192.168.184.132:6386 (29a79c9f...) -> 2 keys | 4096 slots | 2 slaves.
192.168.184.132:6382 (1ff5a2a1...) -> 0 keys | 4096 slots | 1 slaves.
192.168.184.132:6383 (af282884...) -> 2 keys | 4096 slots | 2 slaves.
[OK] 5 keys in 4 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.184.132:6390)
M: a25da2e5be0487b3109b23e807b2d4c9c23e5a1a 192.168.184.132:6390
slots:[0-1364],[5461-6826],[10923-12287] (4096 slots) master
3 additional replica(s)
S: 5f34c1cd5a35e1195522695143941d044f1cdb96 192.168.184.132:6392
slots: (0 slots) slave
replicates a25da2e5be0487b3109b23e807b2d4c9c23e5a1a
M: 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 192.168.184.132:6386
slots:[1365-5460] (4096 slots) master
2 additional replica(s)
S: a86979e7ff21ca39bad8da1ce63c551f2598c779 192.168.184.132:6391
slots: (0 slots) slave
replicates a25da2e5be0487b3109b23e807b2d4c9c23e5a1a
S: 92d06bfb428a1358149c209c336152cae3304c66 192.168.184.132:6388
slots: (0 slots) slave
replicates af28288480e3398b18402e4475c9ae52c39ea776
M: 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 192.168.184.132:6382
slots:[6827-10922] (4096 slots) master
1 additional replica(s)
M: af28288480e3398b18402e4475c9ae52c39ea776 192.168.184.132:6383
slots:[12288-16383] (4096 slots) master
2 additional replica(s)
S: c9d7f4ed642fa2fde013f2b060476b542b9af76e 192.168.184.132:6385
slots: (0 slots) slave
replicates af28288480e3398b18402e4475c9ae52c39ea776
S: 5b20d04646f7f38eb57266b81749e565825ab6e5 192.168.184.132:6387
slots: (0 slots) slave
replicates a25da2e5be0487b3109b23e807b2d4c9c23e5a1a
S: 888158ad30d9a173175b115974b9d1cc5b39736e 192.168.184.132:6381
slots: (0 slots) slave
replicates 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2
S: a11993ddc7a726e3ad476858fb53bdc97d4834b8 192.168.184.132:6384
slots: (0 slots) slave
replicates 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e
S: 9ef7a5bb156de64a969688eade8535399983dd00 192.168.184.132:6389
slots: (0 slots) slave
replicates 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
目的是移除6390(Master)和6391、6392(Slave)。
删除从节点6391。xxx1替换成:6391的容器id
redis-cli --cluster del-node 192.168.184.132:6391 xxx1
#比如删除从节点6391
root@aubin:/data# redis-cli --cluster del-node 192.168.184.132:6391 a86979e7ff21ca39bad8da1ce63c551f2598c779
>>> Removing node a86979e7ff21ca39bad8da1ce63c551f2598c779 from cluster 192.168.184.132:6391
>>> Sending CLUSTER FORGET messages to the cluster...
>>> Sending CLUSTER RESET SOFT to the deleted node.
redis-cli --cluster del-node 192.168.184.132:6392 xxx2
#比如删除从节点6392
root@aubin:/data# redis-cli --cluster del-node 192.168.184.132:6392 5f34c1cd5a35e1195522695143941d044f1cdb96
>>> Removing node 5f34c1cd5a35e1195522695143941d044f1cdb96 from cluster 192.168.184.132:6392
>>> Sending CLUSTER FORGET messages to the cluster...
>>> Sending CLUSTER RESET SOFT to the deleted node.
redis-cli --cluster reshard xxxxxx1
#比如
redis-cli --cluster reshard 192.168.184.132:6386
输入删除的槽位数:因为6390的槽位是4096个,所以输入:4096
再输入谁来接收这些残留下来的槽位的容器id,我们这里把4096个都给6383,所以输入6383的容器id:af28288480e3398b18402e4475c9ae52c39ea776(哪个Master节点都行)
再输入删除的这个Master节点的id,也就是6390的容器id:a25da2e5be0487b3109b23e807b2d4c9c23e5a1a
再输入:done
再输入:yes
此时6390的槽位已经全部给了6383,这个时候可以删除6390节点了。xxx1为6390的容器id
redis-cli --cluster del-node 192.168.184.132:6390 xxx1
#比如
redis-cli --cluster del-node 192.168.184.132:6390 a25da2e5be0487b3109b23e807b2d4c9c23e5a1a
root@aubin:/data# redis-cli --cluster check 192.168.184.132:6383
192.168.184.132:6383 (af282884...) -> 3 keys | 8192 slots | 3 slaves.
192.168.184.132:6382 (1ff5a2a1...) -> 0 keys | 4096 slots | 1 slaves.
192.168.184.132:6386 (29a79c9f...) -> 2 keys | 4096 slots | 2 slaves.
[OK] 5 keys in 3 masters.
0.00 keys per slot on average.
>>> Performing Cluster Check (using node 192.168.184.132:6383)
M: af28288480e3398b18402e4475c9ae52c39ea776 192.168.184.132:6383
slots:[0-1364],[5461-6826],[10923-16383] (8192 slots) master
3 additional replica(s)
S: a11993ddc7a726e3ad476858fb53bdc97d4834b8 192.168.184.132:6384
slots: (0 slots) slave
replicates 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e
S: 888158ad30d9a173175b115974b9d1cc5b39736e 192.168.184.132:6381
slots: (0 slots) slave
replicates 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2
S: 5b20d04646f7f38eb57266b81749e565825ab6e5 192.168.184.132:6387
slots: (0 slots) slave
replicates af28288480e3398b18402e4475c9ae52c39ea776
S: c9d7f4ed642fa2fde013f2b060476b542b9af76e 192.168.184.132:6385
slots: (0 slots) slave
replicates af28288480e3398b18402e4475c9ae52c39ea776
S: 92d06bfb428a1358149c209c336152cae3304c66 192.168.184.132:6388
slots: (0 slots) slave
replicates af28288480e3398b18402e4475c9ae52c39ea776
M: 1ff5a2a15526e3d7984b231cf7e47f8f442e4a9e 192.168.184.132:6382
slots:[6827-10922] (4096 slots) master
1 additional replica(s)
M: 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2 192.168.184.132:6386
slots:[1365-5460] (4096 slots) master
2 additional replica(s)
S: 9ef7a5bb156de64a969688eade8535399983dd00 192.168.184.132:6389
slots: (0 slots) slave
replicates 29a79c9f9a007bf80fdfc2ffaaf1cf27d29396c2
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.
❤️本章结束,我们下一章见❤️