当前位置:网站首页>集群中命令的执行过程
集群中命令的执行过程
2022-06-26 14:38:00 【华为云】
redis集群中命令的执行过程
如果客户端向群集中的节点发送关键命令,则只需将具有密钥的槽位分配给当前节点即可进行处理,如果不在当前节点上,则向客户端返回MOVED命令。 此命令将客户端重定向到正确的节点,然后再次发送命令。 在集群模式下,MOVED命令将隐藏
包含数据库密钥的插槽的计算
CRC 16 (密钥) % 16384计算密钥密钥所属的插槽。 其中,CRC16 ) key语句用于计算密钥key的CRC16校验和。 群集密钥槽密钥可以查看将此密钥分配给哪个插槽
节点与插槽的关联存储
节点如何确定这个插槽是否是自己负责的?显然是通过集群状态结构体的slots数组,如果该槽位所指示的集群节点是集群状态的myself属性值,则由该节点负责,否则基于所指示的集群节点
键与插槽的关联存储
集群中数据库键值对的保存只能使用0号数据库。 除了将键值对保存在数据库中外,节点还通过clusterState中的slots_to_keys跳转表来保存键与插槽之间的直接关系。 每个节点的score是插槽号,成员是数据库的键。 每当节点向数据库添加键值对时,都会从跳转表中添加密钥与槽位的关联,而删除键值对时,也会从跳转表中删除密钥与槽位的关联。 此跳转表中的记录允许批量操作插槽中的所有数据库键。
总结
这就是集群中命令的执行过程,客户端发送命令,如果有关槽位的命令在当前节点就执行,不在当前节点就返回move命令,然后重定向到负责这个槽位的节点,计算数据库key的槽位是根据key的crc16的值与16384取模,16384是redis所有的槽位,集群的slots数组的元素执行当前节点说明槽位是由这个节点负责的。
️ 感谢大家
如果你觉得这篇内容对你挺有有帮助的话:
- 欢迎关注我️,点赞,评论,转发
- 关注
盼盼小课堂,定期为你推送好文,还有群聊不定期抽奖活动,可以畅所欲言,与大神们一起交流,一起学习。 - 有不当之处欢迎批评指正。
边栏推荐
- Mark: unity3d cannot select resources in the inspector, that is, project locking
- MySQL master-slave replication and read-write separation
- 启动Redis报错:Could not create Server TCP listening socket *:6379: bind: Address already in use–解决办法
- R语言使用ggplot2可视化泊松回归模型(Poisson Regression)的结果、可视化不同参量组合下的计数结果
- R语言epiDisplay包的tableStack函数制作统计汇总表格(分组的描述性统计、假设检验等)、不设置by参数计算基础描述性统计信息、指定对于大多数样本负相关的变量进行反序
- Understand the difference and use between jsonarray and jsonobject
- Is it safe to open an online stock account? Somebody give me an answer
- Common evaluation indexes of classification model -- confusion matrix and ROC curve
- 详解C语言编程题:任意三条边能否构成三角形,输出该三角形面积并判断其类型
- Informatics Olympiad 1405: sum and product of prime numbers (thinking problem)
猜你喜欢

VMware partial settings

How to personalize VIM editor format (DIY)

Leaflet loading ArcGIS for server map layers

2022年最新贵州建筑八大员(机械员)模拟考试题库及答案

Electron

feil_uVission4左侧工目录消失

人的顶级能量从哪里获取?

'coach, I want to play basketball!'—— AI Learning Series booklet for system students

Common evaluation indexes of classification model -- confusion matrix and ROC curve

GDAL multiband synthesis tool
随机推荐
Understand the difference and use between jsonarray and jsonobject
transformers DataCollatorWithPadding类
Extended hooks
Introduction to basic knowledge of C language (Daquan) [suggestions collection]
Summary of decimal point of amount and price at work and pit
Informatics Olympiad 1405: sum and product of prime numbers (thinking problem)
K gold Chef (two conditions, two points and difference)
TCP拥塞控制详解 | 1. 概述
Authoritative announcement on the recruitment of teachers in Yan'an University in 2022
ArcGIS batch export layer script
710. random numbers in the blacklist
Matplotlib common operations
赠书 | 《认知控制》:我们的大脑如何完成任务?
oracle11g数据库导入导出方法教程[通俗易懂]
Question bank and answers of the latest Guizhou construction eight (Mechanics) simulated examination in 2022
R语言使用epiDisplay包的aggregate函数将数值变量基于因子变量拆分为不同的子集,计算每个子集的汇总统计信息、使用aggregate.data.frame函数计算分组汇总统计信息
国信证券的排名如何?办理股票开户安全吗?
Atcoder bit operation & Conclusion + formula derivation
信息学奥赛一本通 1405:质数的和与积 (思维题)
The engine "node" is inconsistent with this module