当前位置:网站首页>Execution of commands in the cluster
Execution of commands in the cluster
2022-06-26 15:00:00 【Hua Weiyun】
redis The execution of commands in the cluster
If the client sends key commands to the nodes in the cluster , Then you only need to assign the slot with the key to the current node for processing , If it is not on the current node , Return... To the client MOVED command . This command redirects the client to the correct node , Then send the command again . In cluster mode ,MOVED The command will hide
Calculation of the slot containing the database key
CRC 16 ( secret key ) % 16384 Calculate the slot to which the key belongs . among ,CRC16 ) key Statement is used to calculate the key key Of CRC16 The checksum . The cluster key slot key lets you see which slot this key is assigned to
Storage associated with the node and slot
How does the node determine whether the slot is in its own responsibility ? Obviously through the cluster state structure slots Array , If the cluster node indicated by the slot is in cluster status myself Property value , This node is responsible for , Otherwise, based on the indicated cluster node
Key and slot associated storage
The only way to save database key value pairs in a cluster is to use 0 The database . In addition to saving key value pairs in the database , Node also passes clusterState Medium slots_to_keys Jump table to save the direct relationship between key and slot . For each node score Is the slot number , Members are the keys of the database . Whenever a node adds a key value pair to the database , The key and slot Association will be added from the jump table , When deleting key value pairs , The key and slot Association will also be deleted from the jump table . The records in this jump table allow batch operation of all database keys in the slot .
summary
This is the execution process of commands in the cluster , Client sends command , If the command about the slot is executed at the current node , Return if it is not at the current node move command , Then redirect to the node responsible for this slot , Calculation database key The slot position of is based on key Of crc16 The value of is equal to 16384 modulus ,16384 yes redis All slots , Clustered slots The element of the array executes the current node, indicating that the slot is in the charge of this node .
️ Thank you for your
If you think this is helpful for you :
- Welcome to follow me ️, give the thumbs-up , Comment on , forward
- Focus on
Panpan small class
, Push good articles for you regularly , There are also group chat and irregular lottery activities , You can say what you want , Communicate with the great gods , Learning together . - If there is anything inappropriate, you are welcome to criticize and correct .
边栏推荐
- Use abp Zero builds a third-party login module (II): server development
- The R language cartools package divides data, the scale function scales data, and the KNN function of the class package constructs a k-nearest neighbor classifier
- Summary of decimal point of amount and price at work and pit
- Flex & bison start
- Redis事务与watch指令
- A remove the underline from the label
- View触摸分析
- R language uses GLM function to build Poisson logarithm linear regression model, processes three-dimensional contingency table data to build saturation model, uses step function to realize stepwise re
- 这才是优美的文件系统挂载方式,亲测有效
- 网上找客户经理办理股票开户安全吗??
猜你喜欢
设计人员拿到的工程坐标系等高线CAD图如何加载进图新地球
The JVM outputs GC logs, causing the JVM to get stuck. I am stupid
teamviewer显示设备数量上限解决方法
文献1
[solo π] ADB connects multiple mobile phones
【soloπ】adb连接单个多个手机
Solution to the upper limit of TeamViewer display devices
feil_uVission4左侧工目录消失
'coach, I want to play basketball!'—— AI Learning Series booklet for system students
Minister of investment of Indonesia: Hon Hai is considering establishing electric bus system and urban Internet of things in its new capital
随机推荐
【云原生】 ”人人皆可“ 编程的无代码 iVX 编辑器
Unity uses skybox panoramic shader to make panorama preview. There is a gap. Solution
The JVM outputs GC logs, causing the JVM to get stuck. I am stupid
挖财注册开户安全吗,有没有什么风险?
Datasets dataset class (2)
Detailed explanation of C language programming problem: can any three sides form a triangle, output the area of the triangle and judge its type
Combat readiness mathematical modeling 31 data interpolation and curve fitting 3
手机股票注册开户安全吗,有没有什么风险?
R语言caTools包进行数据划分、scale函数进行数据缩放、class包的knn函数构建K近邻分类器
券商经理给的开户链接安全吗?找谁可以开户啊?
Minister of investment of Indonesia: Hon Hai is considering establishing electric bus system and urban Internet of things in its new capital
【soloπ】adb连接单个多个手机
The annual salary of 500000 is one line, and the annual salary of 1million is another line
VMware partial settings
信息学奥赛一本通 1405:质数的和与积 (思维题)
程序分析与优化 - 8 寄存器分配
Flex & bison start
TCP拥塞控制详解 | 1. 概述
权威发布 | 延安大学2022年教师岗位招聘公告
重磅白皮书发布,华为持续引领未来智慧园区建设新模式