当前位置:网站首页>Redis cluster creation, capacity expansion and capacity reduction
Redis cluster creation, capacity expansion and capacity reduction
2022-07-03 06:10:00 【vincentwc】
Pull the mirror image
```bash
docker pull redis:6.0.8
```
establish redis Cluster container
perform docker command
```bash
docker run -d --name redis-node-1 --net host --privileged=true -v /data/redis/share/redis-node-1:/data redis:6.0.8 --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:6.0.8 --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:6.0.8 --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:6.0.8 --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:6.0.8 --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:6.0.8 --cluster-enabled yes --appendonly yes --port 6386
```
Into the container
```bash
docker exec -ti redis-node-1 /bin/bash
```
Execute the following command
redis-cli --cluster create 10.255.237.120:6381 10.255.237.120:6382 10.255.237.120:6383 10.255.237.120:6384 10.255.237.120:6385 10.255.237.120:6386 --cluster-replicas 1
Input yes after
- At this time, the representative has been successfully created
View the cluster
stay redis-node-1 Execute the following commands in the container
redis-cli -p 6381 -c
Check it with the following command redis Cluster situation
```bash
cluster info
cluster nodes
```
redis Cluster expansion cases 【 Expansion from three masters and three slaves to four masters and four slaves 】
The implementation is as follows docker command
```bash
docker run -d --name redis-node-7 --net host --privileged=true -v /data/redis/share/redis-node-7:/data redis:6.0.8 --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:6.0.8 --cluster-enabled yes --appendonly yes --port 6388
```
Get into 6387 Instance internal
Will add 6387 node ( Empty slot number ) As master The node joins the original cluster
```bash
redis-cli --cluster add-node 10.255.237.120:6387 10.255.237.120:6381
```
Use the following command to check 6387 The node has joined , However, you can see that no slots are allocated
redis-cli --cluster check 10.255.237.120:6381
Reassign slot numbers
redis-cli --cluster reshard 10.255.237.120:6381
0-16383 Number selection of interval
16383/master Number of nodes , This selection is 4096
choice all
redis-cli --cluster check 10.255.237.120:6381
Perform discovery , The newly added master node is to evenly slot each node of the previous master node to the new master node , Instead of reallocating them all
Master node 6387 Assign slave nodes 6388
cluster-master-id by 6387 The number of
redis-cli --cluster add-node 10.255.237.120:6388 10.255.237.120:6387 --cluster-slave --cluster-master-id 135f091ecb2b7eade2d472c2589413fda8c6926b
thus , Expansion completed
Shrinkage capacity 【 Delete 6387-6388】
When you shrink , You should delete the slave first , Then delete the host
perform redis-cli --cluster check 10.255.237.120:6381 command , obtain 6388 node id, Here's the picture
The command to delete a node is as follows
redis-cli --cluster del-node 10.255.237.120:6388 50acca20c6240f83e81c1a5de2a0c17e3dbda523
Reassign the slot number to the cluster
redis-cli --cluster reshard 10.255.237.120:6381
take 6387 All slot numbers of are assigned to other nodes , Assigned here to 6382 了
As shown in the figure below 6387 The slot of is 0 了
Delete node
6387 The slots of have been allocated , Now you can delete 6387 The node
redis-cli --cluster del-node 10.255.237.120:6387 135f091ecb2b7eade2d472c2589413fda8c6926b
Check the cluster
redis-cli --cluster check 10.255.237.120:6381
thus ,redis Cluster creation , Capacity expansion , The volume reduction operation is finished
边栏推荐
- Redhat7 system root user password cracking
- Kubernetes notes (IV) kubernetes network
- Understand the first prediction stage of yolov1
- Zhiniu stock -- 03
- [teacher Zhao Yuqiang] MySQL high availability architecture: MHA
- tabbar的设置
- 智牛股项目--04
- Kubernetes notes (V) configuration management
- 深度学习,从一维特性输入到多维特征输入引发的思考
- 70 shell script interview questions and answers
猜你喜欢
[teacher Zhao Yuqiang] kubernetes' probe
Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
Oauth2.0 - explanation of simplified mode, password mode and client mode
Code generator - single table query crud - generator
Kubesphere - build MySQL master-slave replication structure
[system design] proximity service
Project summary --04
Zhiniu stock project -- 05
Kubesphere - set up redis cluster
从小数据量 MySQL 迁移数据到 TiDB
随机推荐
智牛股项目--04
Kubesphere - build MySQL master-slave replication structure
Beandefinitionregistrypostprocessor
Using the ethtool command by example
深入解析kubernetes controller-runtime
智牛股--03
Detailed explanation of findloadedclass
About the difference between count (1), count (*), and count (column name)
88. Merge two ordered arrays
pytorch 多分类中的损失函数
Kubernetes notes (VI) kubernetes storage
深度学习,从一维特性输入到多维特征输入引发的思考
Es remote cluster configuration and cross cluster search
Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
Project summary --04
BeanDefinitionRegistryPostProcessor
使用 Abp.Zero 搭建第三方登录模块(一):原理篇
When PHP uses env to obtain file parameters, it gets strings
Kubesphere - build Nacos cluster
MySQL带二进制的库表导出导入