当前位置:网站首页>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
边栏推荐
- Yum is too slow to bear? That's because you didn't do it
- Kubernetes notes (VII) kuberetes scheduling
- phpstudy设置项目可以由局域网的其他电脑可以访问
- 1. Sum of two numbers
- [teacher Zhao Yuqiang] index in mongodb (Part 1)
- Understand the first prediction stage of yolov1
- Solve the problem that Anaconda environment cannot be accessed in PowerShell
- In depth analysis of kubernetes controller runtime
- [Zhao Yuqiang] deploy kubernetes cluster with binary package
- [teacher Zhao Yuqiang] MySQL flashback
猜你喜欢
![[teacher Zhao Yuqiang] RDB persistence of redis](/img/cc/5509b62756dddc6e5d4facbc6a7c5f.jpg)
[teacher Zhao Yuqiang] RDB persistence of redis

多线程与高并发(7)——从ReentrantLock到AQS源码(两万字大章,一篇理解AQS)

Kubernetes notes (VII) kuberetes scheduling

Kubesphere - Multi tenant management

JDBC connection database steps

Migrate data from Mysql to tidb from a small amount of data

Fluentd facile à utiliser avec le marché des plug - ins rainbond pour une collecte de journaux plus rapide

pytorch 多分类中的损失函数

Project summary --2 (basic use of jsup)

Project summary --04
随机推荐
Pytorch dataloader implements minibatch (incomplete)
1. Somme des deux nombres
Method of converting GPS coordinates to Baidu map coordinates
[teacher Zhao Yuqiang] redis's slow query log
Intel's new GPU patent shows that its graphics card products will use MCM Packaging Technology
Kubesphere - build MySQL master-slave replication structure
Simple handwritten ORM framework
Clickhouse learning notes (I): Clickhouse installation, data type, table engine, SQL operation
Txt document download save as solution
Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
Kubernetes notes (III) controller
Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
What's the difference between using the Service Worker Cache API and regular browser cache?
[teacher Zhao Yuqiang] use the catalog database of Oracle
Es remote cluster configuration and cross cluster search
. Net program configuration file operation (INI, CFG, config)
智牛股--03
Migrate data from Mysql to tidb from a small amount of data
GPS坐标转百度地图坐标的方法
技术管理进阶——你了解成长的全貌吗?