当前位置:网站首页>Docker installs 3 master and 3 slave redis clusters
Docker installs 3 master and 3 slave redis clusters
2022-07-24 11:02:00 【Scattered_ step】
1. Turn off firewall + start-up docker Background services
systemctl start docker
2. newly build 6 individual docker Containers redis example
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

The command is explained step by step :
docker run: Create and run docker Container instance
--name redis-node-6 : Container name
--net host : Using the host IP And port , Default
--privileged=true : Get host root User permissions
-v /data/redis/share/redis-node-6:/data : The container volume , Host address :docker Internal address
redis:6.0.8 : redis Image and version number
--cluster-enabled yes : Turn on redis colony
--appendonly yes : Turn on persistence
--port 6386: redis Port number
Into the container redis-node-1 And for 6 Build cluster relationships on machines :
Into the container :
docker exec -it redis-node-1 /bin/bash
Build a master-slave relationship :
# Be careful , Get into docker After the container, you can execute the command , And pay attention to your truth IP Address
redis-cli --cluster create 192.168.111.147:6381 192.168.111.147:6382 192.168.111.147:6383 192.168.111.147:6384 192.168.111.147:6385 192.168.111.147:6386 --cluster-replicas 1
--cluster-replicas 1 For each master Create a slave node



everything OK Words ,3 Lord 3 From here on out
Link to 6381 As an entry point , View the cluster status :
Link to 6381 As an entry point , View node status :

cluster info
cluster nodes
Master slave failover migration case :
Data read / write storage :
1. start-up 6 Cluster composed of machines and through exec Get into
2. Yes 6381 Add two key
3. Prevent route failure and add parameters -c And add two key
4. View cluster information :
redis-cli --cluster check 192.168.111.147:6381

Failover migration :
Lord 6381 And slave switching , Stop the host first 6381
6381 The main engine stopped , The corresponding real slave computer
6381 As 1 The slave assigned by host No. 1 shall be subject to the actual situation , Specifically, the number of machines is the number
View the cluster information again :
6381 It's down. ,6385 The superior has become a new master.
The slave attached under each case shall be subject to the actual situation , Specifically, the number of machines is the number
Restore the previous 3 Lord 3 from :
First start 6381:
docker start redis-node-1

Stop again 6385:
docker stop redis-node-5

To rev. 6385:
docker start redis-node-5

The distribution of master-slave machines shall be subject to the actual situation :
View the cluster status :
redis-cli --cluster check own IP:6381

Master slave capacity expansion cases :
newly build 6387、6388 Two nodes + Start after creating a new one + See if 8 node
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
docker ps
Get into 6387 Inside the container instance :
docker exec -it redis-node-7 /bin/bash
Will add 6387 node ( Empty slot number ) As master The node joins the original cluster :
Will add 6387 As master Nodes join the cluster
redis-cli --cluster add-node Actually IP Address :6387 Actually IP Address :6381
6387 Is going to be master New node
6381 Is the leader in the original cluster node , amount to 6387 Bye-bye 6381 So as to find organizations to join the cluster


Check the cluster condition 1 Time :
redis-cli --cluster check real ip Address :6381


Reassign slot numbers :
Reassign slot numbers
command :redis-cli --cluster reshard IP Address : Port number
redis-cli --cluster reshard 192.168.111.147:6381


Check the cluster condition 2 Time :
redis-cli --cluster check real ip Address :6381


Slot number assignment description :
Why? 6387 yes 3 A new interval , It used to be continuous ?
Reallocation costs are too high , So before 3 Each family sets aside a part , from 6381/6382/6383 Separate out the three old nodes 1364 A pit for the new node 6387
Master node 6387 Assign slave nodes 6388:
command :redis-cli --cluster add-node ip: new slave port ip: new master port --cluster-slave --cluster-master-id New host node ID
redis-cli --cluster add-node 192.168.111.147:6388 192.168.111.147:6387 --cluster-slave --cluster-master-id e4781f644d4a4e4d4b4d107157b9ba8144631451------- This is 6387 The number of , According to your actual situation


Check the cluster condition 3 Time :
redis-cli --cluster check 192.168.111.147:6382


Master-slave volume reduction case :
1. Purpose :6387 and 6388 Offline
2. Check the cluster 1 get 6388 The node of ID
redis-cli --cluster check 192.168.111.147:6382

3. take 6388 Delete
From the cluster 4 No. slave node 6388 Delete
command :redis-cli --cluster del-node ip: Slave port Slave 6388 node ID
redis-cli --cluster del-node 192.168.111.147:6388 5d149074b7e57b802287d1797a874ed7a1a284a8

redis-cli --cluster check 192.168.111.147:6382

4. take 6387 Empty the slot number , Redistribution , In this example, all the slot numbers cleared are given to 6381
redis-cli --cluster reshard 192.168.111.147:6381



5. Check the cluster for the second time
redis-cli --cluster check 192.168.111.147:6381
4096 All slots are pointed to 6381, It became 8192 Slots , It's equivalent to giving everything to 6381 了 , Otherwise, enter 3 Time , One pot

6. take 6387 Delete
command :redis-cli --cluster del-node ip: port 6387 node ID
redis-cli --cluster del-node 192.168.111.147:6387 e4781f644d4a4e4d4b4d107157b9ba8144631451

7. Check the cluster for the third time
redis-cli --cluster check 192.168.111.147:6381

边栏推荐
- Simply use MySQL index
- Collation of important MySQL configuration parameters
- 自动推理的逻辑06--谓词演算
- Real time weather API
- [FPGA]: IP core - multiplier
- Distributed lock implementation scheme (glory collection version)
- cookie sessionStorage localStorage 区别
- Signal processing: < three > DFT and FFT
- pip更新命令
- 零基础学习CANoe Panel(9)—— 组合框(ComboBox)
猜你喜欢

Conversion between hexadecimal string and byte array

Hongmeng's first note

Cookie sessionstorage localstorage differences

零基础学习CANoe Panel(5)——改变变量的值,控件图像也改变,这是怎么回事?

零基础学习CANoe Panel(8)—— 数据/文本编辑控件(Hex/Text Editor )

Distributed lock implementation scheme (glory collection version)

零基础学习CANoe Panel(6)—— 开关/显示控件(Switch/Indicator)

QT create application tray and related functions
![[class, abstraction and inheritance]](/img/eb/4c8d0c86b1320015b2ccb0289f4f00.png)
[class, abstraction and inheritance]

变频器的四大组成部分和工作原理
随机推荐
cookie sessionStorage localStorage 区别
Summary of const type data
[dish of learning notes dog learning C] initial level of structure
Artifact ffmpeg - operation video, extremely comfortable
UVM——双向通信
TwinCAT3各版本下载路径
[FPGA]: use of MicroBlaze
Distributed lock implementation scheme (glory collection version)
零基础学习CANoe Panel(3)—— 静态控件(Static Text , Group Box ,Picture Box)
Redistribution distributed lock types
SQL optimization skills and precautions
Qt程序最小化托盘后,再弹出个msgbox,点击确定后程序退出问题解决
实时天气API
【微服务】Eureka+Ribbon实现注册中心与负载均衡
零基础学习CANoe Panel(9)—— 组合框(ComboBox)
LoRa无线技术与LoRaWAN网关模块的区别
Five application scenarios of Bluetooth module
[interview: Basics 04: insert order]
Tidb query SQL report runtime error: index out of range [-1] error
零基础学习CANoe Panel(6)—— 开关/显示控件(Switch/Indicator)