当前位置:网站首页>cluster addslots建立集群
cluster addslots建立集群
2022-06-26 14:38:00 【华为云】
cluster addslots建立集群
redis群集有16384个时隙位,使用CLUSTER MEET命令构建群集时未分配时隙位。 可以通过发送CLUSTER ADDSLOTS命令将时隙位分配给当前节点集群节点的slots属性用于记录节点负责哪个槽位。
数据结构
slots是一个二进制位数组,如果数组索引的二进制位值为1,则表示当前节点负责此插槽,否则不负责插槽。 numslots属性存储节点负责的槽位数,这两个属性记录当前节点负责的槽位,并由当前节点通过消息发送到群集中的其他节点。 收到slots数组的节点将数组信息保存在相应节点的clusterNode结构中。
此外,clusterState结构的slots数组也保存了插槽的分配情况。 slots数组有16384个元素,指向元素的指针为空,指示未分配时隙位,而指向一个群集节点结构的指针指示已分配给该时隙位所在的节点。
为什么插槽分配的信息会保存在集群节点的slots数组中,也保存在集群状态的slots数组中?
由于集群节点记录了插槽的分配,但没有记录插槽具体分配给哪个节点,因此请遍历集群状态的nodes词典的集群节点结构,查看slots数组
命令使用
CLUSTER ADDSLOTS命令来完成命令将槽位指定给节点,将集群状态的slots数组中槽位的索引指向当前节点的clusterNode结构,并指定集群节点的slots数组
redis就是通过CLUSTER ADDSLOTS命令来完成槽位的分配的
> CLUSTER ADDSLOTS 1 2 3OK这就是通过CLUSTER ADDSLOTS命令来对槽位进行分配,将1 2 3三个槽分配给收到这个命令的服务器。
当槽位被划分好后再进行分配就会报错,就像上边的命令,如果执行成功了再执行一次就会出现错误。
总结
好了,今天cluster addslots命令写分析到这里,如果哪里写的不对还请多多指教。
️ 感谢大家
如果你觉得这篇内容对你挺有有帮助的话:
- 欢迎关注我️,点赞,评论,转发
- 关注
盼盼小课堂,定期为你推送好文,还有群聊不定期抽奖活动,可以畅所欲言,与大神们一起交流,一起学习。
边栏推荐
猜你喜欢

MySQL master-slave replication and read-write separation

teamviewer显示设备数量上限解决方法

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

Combat readiness mathematical modeling 31 data interpolation and curve fitting 3

Leaflet loading ArcGIS for server map layers

TCP拥塞控制详解 | 1. 概述

Use abp Zero builds a third-party login module (II): server development

Mark一下 Unity3d在Inspector中选中不了资源即Project锁定问题

Unity uses skybox panoramic shader to make panorama preview. There is a gap. Solution

One copy ten, CVPR oral was accused of plagiarizing a lot, and it was exposed on the last day of the conference!
随机推荐
Login authentication service
【使用yarn运行报错】The engine “node“ is incompatible with this module.
网上股票开户安不安全?谁给回答一下
Mathematical modeling of war preparation 30 regression analysis 2
Mark: unity3d cannot select resources in the inspector, that is, project locking
扩展-Hooks
This is the graceful file system mounting method, which is effective through personal testing
15 bs对象.节点名称.节点名称.string 获取嵌套节点内容
fileinput. js php,fileinput
Atcoder bit operation & Conclusion + formula derivation
Naacl2022: (code practice) good visual guidance promotes better feature extraction, multimodal named entity recognition (with source code download)
一个快速切换一个底层实现的思路分享
备战数学建模32-相关性分析2
Deploy the flask environment using the pagoda panel
Use abp Zero builds a third-party login module (I): Principles
Complimentary Book Cognitive Control: how does our brain accomplish tasks?
Leaflet loading ArcGIS for server map layers
Electron
NVIDIA SMI error
How to mount cloud disks in ECS