当前位置:网站首页>Project practice, redis cluster technology learning (VII)
Project practice, redis cluster technology learning (VII)
2022-07-02 10:04:00 【User 1289394】
Redis.4 Cluster scaling
Redis.4.1 Stretching principle
Redis Cluster provides flexible node expansion and contraction scheme . Without affecting the external services of the cluster
Next , You can add nodes to the cluster to expand capacity, or you can downsize some nodes offline , Pictured
Redis The cluster can realize flexible online and offline control of nodes . The principle can be abstracted as the flexible movement of slots and corresponding data between different nodes . First, let's look at the cluster slot we built before and the corresponding relationship between data and nodes , As shown in the figure
The three master nodes maintain their own slots and corresponding data , If you want to join 1 When a node realizes cluster expansion , The data slot needs to be related to the new node through the command , Pictured
Each node in the figure migrates part of the slot and data to a new node 6385, Each node is responsible for fewer slots and data than before, so as to achieve the purpose of cluster expansion . Here, we deliberately ignore the details of slot and data migration between nodes , The purpose is to let readers focus on the upper slot and node allocation , Understand the upper principle of horizontal scaling of clusters : Cluster scaling = The movement of slots and data between nodes , Next, we will introduce the details of cluster expansion and contraction .
10.4.2 Expand clusters
Capacity expansion is the most common requirement of distributed storage ,Redis Cluster capacity expansion can be divided into the following steps :
1) Prepare new nodes .
2) To join the cluster .
3) Migration slots and data .
1. Prepare new nodes
New nodes need to be prepared in advance and run in cluster mode , The new node is recommended to be configured according to the nodes in the cluster
bring into correspondence with , Easy to manage and unify . After the configuration is ready, start the two nodes with the following commands :
redis-server conf/redis-6385.conf
redis-server conf/redis-6386.conf
The new node after startup runs as an orphan node , No other node communicates with it , The cluster structure is shown in the figure
Shown .
2. To join the cluster
The new node still adopts cluster meet Command to join an existing cluster . Execute on any node in the cluster
cluster meet Order to let 6385 and 6386 Nodes join , The order is as follows :
127.0.0.1:6379> cluster meet 127.0.0.1 6385
127.0.0.1:6379> cluster meet 127.0.0.1 6386
After the new node is added, the cluster structure is shown in the figure .
The old and new nodes in the cluster have changed over a period of time ping/pong After message communication , All nodes will send
Create new nodes and save their state locally . For example, we are in 6380 Execution on node cluster
nodes The command can see the new node information :
127.0.0.1:6380>cluster ndoes
1a205dd8b2819a00dd1e8b6be40a8e2abe77b756 127.0.0.1:6385 master - 0
1469347800759
7 connected
475528b1bcf8e74d227104a6cf1bf70f00c24aae 127.0.0.1:6386 master - 0
1469347798743
8 connected
...
At the beginning, new nodes are all primary nodes , But because there is no responsible slot , So I can't accept any
How to read and write . For the subsequent operations of new nodes, we generally have two options :
· Expand its migration slot and data .
· The slave node as the other master node is responsible for the failover .
redis-trib.rb The tool also implements the command to add new nodes to an existing cluster , It also realizes direct addition
Add support for slave nodes , The order is as follows :
redis-trib.rb add-node 127.0.0.1:6385 127.0.0.1:6379
redis-trib.rb add-node 127.0.0.1:6386 127.0.0.1:6379
(Redis5.0 After the version, also put redis-trib.rb The order was changed to redis-cli )
边栏推荐
- Read Day6 30 minutes before going to bed every day_ Day6_ Date_ Calendar_ LocalDate_ TimeStamp_ LocalTime
- QT QLabel样式设置
- Junit5 supports suite methods
- cmake的命令-官方文档
- Memories of a chat
- Image recognition - data annotation
- Typora installation package sharing
- About the college entrance examination
- Navicat remote connection MySQL reports an error 1045 - access denied for user 'root' @ '222.173.220.236' (using password: yes)
- This monitoring system makes workers tremble: turnover intention and fishing can be monitored. After the dispute, the product page has 404
猜你喜欢
QT QLabel样式设置
Mysql索引
Alibaba cloud ack introduction
Tools used for Yolo object recognition and data generation
Web security and defense
Read Day6 30 minutes before going to bed every day_ Day6_ Date_ Calendar_ LocalDate_ TimeStamp_ LocalTime
Alibaba cloud SMS service
2837xd 代码生成——StateFlow(4)
虚幻——动画蓝图、状态机制作人物走跑跳动作
图像识别-数据增广
随机推荐
Required request body is missing: (cross domain problem)
【虚幻】按键开门蓝图笔记
Matlab generates DSP program -- official routine learning (6)
A model can do two things: image annotation and image reading Q & A. VQA accuracy is close to human level | demo can be played
【虚幻】武器插槽:拾取武器
Tee command usage example
It is the most difficult to teach AI to play iron fist frame by frame. Now arcade game lovers have something
Junit4 runs MVN test test suite upgrade scheme
【虚幻】过场动画笔记
BugkuCTF-web24(解题思路及步骤)
[illusory] automatic door blueprint notes
Inverter Simulink model -- processor in the loop test (PIL)
2837xd 代码生成——StateFlow(2)
2837xd code generation - stateflow (3)
Mixed development of uni app -- Taking wechat applet as an example
2837xd 代码生成——StateFlow(3)
[ue5] blueprint making simple mine tutorial
2837xd code generation module learning (3) -- IIC, ECAN, SCI, watchdog, ECAP modules
Junit5 支持suite的方法
QT信号槽总结-connect函数错误用法