当前位置:网站首页>Docker builds redis3 master-slave cluster and expands the capacity
Docker builds redis3 master-slave cluster and expands the capacity
2022-06-23 02:34:00 【buiu】
3 Lord 3 from Redis Cluster expansion and contraction
When using master-slave, it is necessary to avoid that the master and slave are on the same physical machine , Otherwise, when a master-slave pair hangs up , Corresponding data is unavailable
One . structure
1. establish 6 individual Redis Container instance docker run -d --name redis-node-1 --net host --privileged=true -v /opt/redis/share/redis-node-1:/data redis --cluster-enabled yes --appendonly yes --port 6381 docker run -d --name redis-node-2 --net host --privileged=true -v /opt/redis/share/redis-node-2:/data redis --cluster-enabled yes --appendonly yes --port 6382 docker run -d --name redis-node-3 --net host --privileged=true -v /opt/redis/share/redis-node-3:/data redis --cluster-enabled yes --appendonly yes --port 6383 docker run -d --name redis-node-4 --net host --privileged=true -v /opt/redis/share/redis-node-4:/data redis --cluster-enabled yes --appendonly yes --port 6384 docker run -d --name redis-node-5 --net host --privileged=true -v /opt/redis/share/redis-node-5:/data redis --cluster-enabled yes --appendonly yes --port 6385 docker run -d --name redis-node-6 --net host --privileged=true -v /opt/redis/share/redis-node-6:/data redis --cluster-enabled yes --appendonly yes --port 6386 # Parameters, --net host = Using the host ip And port , Is the default option 2. Build clusters redis-cli --cluster create 10.122.1.86:6381 10.122.1.86:6382 10.122.1.86:6383 10.122.1.86:6384 10.122.1.86:6385 10.122.1.86:6386 --cluster-replicas 1 # One by one yes 3. View the cluster status (redis Internal execution ) cluster info cluster nodes # The corresponding relationship between master and slave can be determined M S 1 6 2 4 3 5 redis-cli --cluster check 10.122.1.86:6381 ( In container execution ) 4. Connect to the cluster docker exec -it redis-node-1 /bin/bash redis-cli -p 6381 -c 5. Fault tolerant migration , If someone master Dang , Is there a slave Host docker stop redis-node-2 # Host execution # check state cluster nodes # Find out master,fail, Wait for a short time again check cluster nodes # You will find that it belongs to master2 Of slave4 Host , become master
Two . Capacity expansion
demand : Add master-slave , master6387, Its slave by 6388
1. Boot instance docker run -d --name redis-node-7 --net host --privileged=true -v /opt/redis/share/redis-node-7:/data redis --cluster-enabled yes --appendonly yes --port 6387 docker run -d --name redis-node-8 --net host --privileged=true -v /opt/redis/share/redis-node-8:/data redis --cluster-enabled yes --appendonly yes --port 6388 2. take 6387 Node as master To join the cluster docker exec -it redis-node-7 /bin/bash redis-cli --cluster add-node 10.122.1.86:6387 10.122.1.86:6381 redis-cli --cluster check 10.122.1.86:6381 Find out 6387 Already as new master 3. Reassign slot numbers How many slots do you want to move (from 1 to 16384)? 4096 What is the receiving node ID? c6822e309e97b70122ec8219334b28457bbd6845 Source node #1: all Do you want to proceed with the proposed reshard plan (yes/no)? yes redis-cli --cluster check 10.122.1.86:6381 # Find out 6387 Nodes have 4096 Slots ( The original 3 Each node is evenly distributed ) 1. take 6388 As 6387 Of slave Add to cluster redis-cli --cluster add-node 10.122.1.86:6388 10.122.1.86:6387 --cluster-slave --cluster-master-id c6822e309e97b70122ec8219334b28457bbd6845 redis-cli -p 6381 -c cluster nodes # Confirm cluster status
3、 ... and . Shrinkage capacity
demand : Delete master-slave 6387 and 6388
1. Delete slave 6388 redis-cli --cluster del-node 10.122.1.86:6388 1da4941694c45812027fc74e687d7de17ad798eb 2. Reallocate slots 2.1 programme 1: take 6387 The slot of is assigned to 6382 redis-cli --cluster reshard 10.122.1.86:6382 How many slots do you want to move (from 1 to 16384)? 4096 What is the receiving node ID? 4314fd868093beea918b8aabacca74f3800855e4 Source node #1: c6822e309e97b70122ec8219334b28457bbd6845 Source node #2: done Do you want to proceed with the proposed reshard plan (yes/no)? yes redis-cli --cluster check 10.122.1.86:6381 # Find out 6387 There are no slots , and 6382 Yes 8192 Slots 1. Delete host 6387 redis-cli --cluster del-node 10.122.1.86:6387 c6822e309e97b70122ec8219334b28457bbd6845 2. confirm redis-cli --cluster check 10.122.1.86:6381
边栏推荐
- JS case: support canvas electronic signature function on PC and mobile
- 1.3-1.4 web page data capture
- Apache Druid's engineering practice in shopee
- Detailed explanation of various networking modes of video monitoring platform
- Vs code remote SSH configuration
- Solution to the problem of easycvr switching MySQL database traffic statistics cannot be displayed
- Performance test -- 14 detailed explanation of performance test report and precautions
- 5g spectrum
- How to design API return codes (error codes)?
- Log a log4j2 vulnerability handling
猜你喜欢

Analog Electronic Technology

II Data preprocessing

Reptile lesson 1

Soft exam information system project manager_ Information system comprehensive testing and management - Senior Information System Project Manager of soft test 027

Docker installs mysql5.7 and mounts the configuration file

Performance testing -- Interpretation and practice of 16 enterprise level project framework

My good brother gave me a difficult problem: retry mechanism

Pychart installation instructions

Unity official case nightmare shooter development summary < I > realization of the role's attack function

Mongodb aggregate query implements multi table associated query, type conversion, and returns specified parameters.
随机推荐
How to locate memory leaks
The commercial s2b2b e-commerce platform of aquatic industry improves the competitiveness of enterprises and creates a strong engine for industrial development
JS advanced part
8. greed
Easygbs adds websocket message push, which can quickly locate video playback faults
JS request path console reports an error failed to launch 'xxx' because the scheme does not have a registered handler
Ugui empty button implementation
Goframe framework (RK boot): fast implementation of CSRF verification
For Xiaobai who just learned to crawl, you can understand it after reading it
Spark broadcast variables and accumulators (cases attached)
pd. read_ CSV and np Differences between loadtext
You must know the type and method of urllib
Deep learning environment configuration (III) pytorch GPU under Anaconda
Understand GB, gbdt and xgboost step by step
Wechat applet camera compressed image is Base64
Buuctf misc-[bjdctf2020] Nani
How to store, manage and view family photos in an orderly manner?
What is a smart farm?
Digital integrated circuit design process
Deep learning environment configuration (I) installation of CUDA and cudnn