查看“Redis Cluster”的源代码
←
Redis Cluster
跳到导航
跳到搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看和复制此页面的源代码。
=== 图解 === ==== 1 ==== [[文件:Redis Cluster.png|无|缩略图|530x530像素]] 每个节点主数据不同,是数据的子集 利用多台服务器构建集群提高超大规模数据处理能力 同时提供高可用支持 ==== 2 ==== [[文件:Redis Cluster 分配机制.png|无|缩略图|477x477像素]] Redis Cluster 集群采用 Hash Slot(哈希槽)分配 Redis 集群预分好 16384 个槽,初始化集群时平均规划给每一台 Redis Master === 为什么是 16384? === 在 Redis 集群中槽分配的元数据会不间断的在 Redis 集群中分发,以保证所有节点都知晓槽的分配情况 16384=16k,在发送心跳包时使用 char 进行 bitmap 压缩后是 2k(2*8(8 bit) * 1024(1k)=16K) 通常我们不会部署超过10000个 Redis 主节点,因此16384就够用了 === 配置 === ==== cluster-master-0.conf ==== <syntaxhighlight lang="console"> bind 127.0.0.1 port 6379 cluster-enabled yes cluster-config-file nodes-6379.conf cluster-node-timeout 15000 cluster-announce-port 6379 cluster-announce-bus-port 16379 </syntaxhighlight> ==== cluster-master-1.conf ==== <syntaxhighlight lang="console"> bind 127.0.0.1 port 6380 cluster-enabled yes cluster-config-file nodes-6380.conf cluster-node-timeout 15000 cluster-announce-port 6380 cluster-announce-bus-port 16380 </syntaxhighlight> ==== cluster-master-2.conf ==== <syntaxhighlight lang="console"> bind 127.0.0.1 port 6381 cluster-enabled yes cluster-config-file nodes-6381.conf cluster-node-timeout 15000 cluster-announce-port 6381 cluster-announce-bus-port 16381 </syntaxhighlight> ==== cluster-slave-0.conf ==== <syntaxhighlight lang="console"> bind 127.0.0.1 port 6479 cluster-enabled yes cluster-config-file nodes-6479.conf cluster-node-timeout 15000 cluster-announce-port 6479 cluster-announce-bus-port 16479 </syntaxhighlight> ==== cluster-slave-1.conf ==== <syntaxhighlight lang="console"> bind 127.0.0.1 port 6480 cluster-enabled yes cluster-config-file nodes-6480.conf cluster-node-timeout 15000 cluster-announce-port 6480 cluster-announce-bus-port 16480 </syntaxhighlight> ==== cluster-slave-2.conf ==== ==== 注意 ==== * 集群配置中不允许出现 replicaof 的配置项,否则就会报<syntaxhighlight lang="powershell"> F:\下载目录\Redis-x64-5.0.14.1>.\redis-server.exe .\config\cluster\redis-cluster0.conf [31444] 20 Feb 10:59:14.659 # *** FATAL CONFIG FILE ERROR *** [31444] 20 Feb 10:59:14.659 # Reading the configuration file, at line 1345 [31444] 20 Feb 10:59:14.660 # >>> 'replicaof 127.0.0.1 6380' [31444] 20 Feb 10:59:14.660 # replicaof directive not allowed in cluster mode </syntaxhighlight> === 启动 === ==== master-0 ==== <syntaxhighlight lang="powershell"> F:\下载目录\Redis-x64-5.0.14.1>.\redis-server.exe .\config\cluster\cluster-master-0.conf [21000] 20 Feb 11:05:53.729 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo [21000] 20 Feb 11:05:53.729 # Redis version=5.0.14.1, bits=64, commit=ec77f72d, modified=0, pid=21000, just started [21000] 20 Feb 11:05:53.729 # Configuration loaded [21000] 20 Feb 11:05:53.732 * No cluster configuration found, I'm 74168c6581ab94338a85097768ae4cb376ef3c75 …… [21000] 20 Feb 11:05:53.927 # I have keys for unassigned slot 9231. Taking responsibility for it. [21000] 20 Feb 11:05:53.928 # I have keys for unassigned slot 15118. Taking responsibility for it. [21000] 20 Feb 11:05:53.928 # I have keys for unassigned slot 15901. Taking responsibility for it. [21000] 20 Feb 11:05:53.928 # I have keys for unassigned slot 16066. Taking responsibility for it. [21000] 20 Feb 11:05:53.977 * Ready to accept connections </syntaxhighlight> === 参考 === [https://www.bilibili.com/video/BV1F44y1C7N8/ https://www.bilibili.com/video/BV1F44y1C7N8]
返回至
Redis Cluster
。
导航菜单
个人工具
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
Spring Boot 2 零基础入门
Spring Cloud
Spring Boot
设计模式之禅
VUE
Vuex
Maven
算法
技能树
Wireshark
IntelliJ IDEA
ElasticSearch
VirtualBox
软考
正则表达式
程序员精讲
软件设计师精讲
初级程序员 历年真题
C
SQL
Java
FFmpeg
Redis
Kafka
MySQL
Spring
Docker
JMeter
Apache
Linux
Windows
Git
ZooKeeper
设计模式
Python
MyBatis
软件
数学
PHP
IntelliJ IDEA
CS基础知识
网络
项目
未分类
MediaWiki
镜像
问题
健身
国债
英语
烹饪
常见术语
MediaWiki帮助
工具
链入页面
相关更改
特殊页面
页面信息