当前位置:网站首页>Redis cluster
Redis cluster
2022-07-06 09:12:00 【I hope it's not too late to wake up】
principle
be-all redis Nodes interconnect with each other (PING-PONG Mechanism )(ping For similar requests ,pong Just like the response ), Internally, binary protocols are used to optimize transmission speed and bandwidth .
Node fail It only takes effect when more than half of the nodes in the cluster are detected to have failed .
The client and redis Node is directly connected , You don't need the middle proxy layer . The client does not need to connect to all the nodes of the cluster , Connect to any of the available nodes in the cluster
redis-cluster Map all the physical nodes to [0-16383]slot On ,cluster Responsible for maintaining node<->slot( Slot )<->value
Redis There's a built-in... In the cluster 16384 Hash slot , When need is in Redis Place one in the cluster key-value when ,redis First pair key Use crc16 The algorithm works out a result , Then get the result right 16384 Mod , So each of them key They all have a number in 0-16383 The Hashi trough between ,redis The hash slot will be mapped to different nodes approximately equally according to the number of nodes .redis The benefits of clustering : Distribute the data on different nodes , Reduce the throughput of a single node , So as to improve the performance of a single node .
Vote
- The voting process is all in the cluster master Participate in (slave It's a backup , Not working , Only when the host is down , The slave of the host will be enabled ), If more than half master Node and master Node communication timeout (cluster-node-timeout), Think of the current master Node down .
- When is the entire cluster unavailable (cluster_state:fail)?
- If the cluster is arbitrary master Hang up , And the current master No, slave. Cluster into fail state , It can also be understood as a cluster slot mapping [0-16383] Enter when not finished fail state .
ps : redis-3.0.0.rc1 Join in cluster-require-full-coverage Parameters , Off by default , Failed to open the cluster compatibility section . - If more than half of the clusters master Hang up , Whether or not slave Cluster into fail state .
ps: When the cluster is not available , All operations on the cluster are not available , received ((error) CLUSTERDOWN The cluster is down) error
- If the cluster is arbitrary master Hang up , And the current master No, slave. Cluster into fail state , It can also be understood as a cluster slot mapping [0-16383] Enter when not finished fail state .
build redis colony
Cluster setup environment preparation
# install gcc Environmental Science (redis Use c Language development )
yum -y install gcc gcc-c++
# install ruby Environmental Science (redis Cluster dependency ruby)
yum -y install ruby rubygems
gem install redis-3.0.3.gem( This needs to be downloaded by yourself )( amount to redis and ruby The interface of )
# 1. Create a cluster Directory cluster-redis
# 2. stay cluster-redis establish 8 A catalog : The directory name is :7001-7008
# 3. Copy redis Stand alone service bin Directory to 7001 Catalog
# 4. modify redis service (bin Catalog )
# Modify port as 7001( Consistent with the directory name )
# Enable cluster configuration :cluster-enable yes
# Empty redis service aof,rdb Persistent files , Keep cluster nodes clean
# Copy 7001 A single machine with a modified directory redis service --- To other 7 A catalog
# Modify other 7 Ports of directories ( The port and directory name are the same )
边栏推荐
- CUDA实现focal_loss
- MongoDB 的安装和基本操作
- [MySQL] limit implements paging
- 【剑指offer】序列化二叉树
- 七层网络体系结构
- Parameterization of postman
- SimCLR:NLP中的对比学习
- Redis之五大基础数据结构深入、应用场景
- Opencv+dlib realizes "matching" glasses for Mona Lisa
- Booking of tourism products in Gansu quadrupled: "green horse" became popular, and one room of B & B around Gansu museum was hard to find
猜你喜欢
SimCLR:NLP中的对比学习
Selenium+pytest automated test framework practice (Part 2)
Advanced Computer Network Review(5)——COPE
Different data-driven code executes the same test scenario
IJCAI2022论文合集(持续更新中)
MySQL uninstallation and installation methods
Redis之Geospatial
[oc foundation framework] - < copy object copy >
自定义卷积注意力算子的CUDA实现
BN折叠及其量化
随机推荐
Leetcode: Sword finger offer 42 Maximum sum of continuous subarrays
不同的数据驱动代码执行相同的测试场景
What is MySQL? What is the learning path of MySQL
BN折叠及其量化
UML圖記憶技巧
多元聚类分析
Selenium+Pytest自动化测试框架实战(下)
CSP student queue
Redis之性能指标、监控方式
Using C language to complete a simple calculator (function pointer array and callback function)
In depth analysis and encapsulation call of requests
LeetCode:34. Find the first and last positions of elements in a sorted array
LeetCode:387. The first unique character in the string
[daily question] Porter (DFS / DP)
[three storage methods of graph] just use adjacency matrix to go out
在QWidget上实现窗口阻塞
Leetcode: Sword finger offer 48 The longest substring without repeated characters
Different data-driven code executes the same test scenario
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
[oc foundation framework] - < copy object copy >