当前位置:网站首页>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 )
边栏推荐
- LeetCode:394. String decoding
- Ijcai2022 collection of papers (continuously updated)
- LeetCode:498. Diagonal traversal
- 【每日一题】搬运工 (DFS / DP)
- Li Kou daily question 1 (2)
- CUDA implementation of self defined convolution attention operator
- Tdengine biweekly selection of community issues | phase III
- 【shell脚本】——归档文件脚本
- Once you change the test steps, write all the code. Why not try yaml to realize data-driven?
- Cesium draw points, lines, and faces
猜你喜欢
Cesium draw points, lines, and faces
[OC foundation framework] - [set array]
Once you change the test steps, write all the code. Why not try yaml to realize data-driven?
BN折叠及其量化
postman之参数化详解
Computer graduation design PHP Zhiduo online learning platform
How to intercept the string correctly (for example, intercepting the stock in operation by applying the error information)
Export IEEE document format using latex
Advanced Computer Network Review(5)——COPE
ant-design的走马灯(Carousel)组件在TS(typescript)环境中调用prev以及next方法
随机推荐
Leetcode problem solving 2.1.1
LeetCode:236. The nearest common ancestor of binary tree
UML图记忆技巧
Improved deep embedded clustering with local structure preservation (Idec)
[three storage methods of graph] just use adjacency matrix to go out
Advanced Computer Network Review(4)——Congestion Control of MPTCP
In depth analysis and encapsulation call of requests
LeetCode:836. 矩形重叠
Show slave status \ read in G_ Master_ Log_ POS and relay_ Log_ The (size) relationship of POS
Digital people anchor 618 sign language with goods, convenient for 27.8 million people with hearing impairment
LeetCode:673. Number of longest increasing subsequences
go-redis之初始化连接
postman之参数化详解
I-BERT
LeetCode:498. 对角线遍历
Mathematical modeling 2004b question (transmission problem)
LeetCode:劍指 Offer 42. 連續子數組的最大和
Redis之性能指标、监控方式
QDialog
Redis之Bitmap