当前位置:网站首页>Set up redis highly available cluster environment
Set up redis highly available cluster environment
2022-06-11 09:21:00 【Asurplus、】
First, set up a stand-alone version Redis Environmental Science , Please refer to my blog :Centos7 Build in Redis Environmental Science
1、 preparation
When it's set up , In the catalog /usr/local/redis/ Next , newly build myredis Catalog
mkdir myredis
Get into myredis Directory , newly build 6 A folder , Use the port to name , for example :
mkdir redis7000
…
mkdir redis7005
So now we have 6 A folder
2、 Basic configuration information
We from /usr/local/redis/bin/ Under the table of contents , Copy a configuration file , Modify the configuration
# port
port 7000
# Daemon mode starts
daemonize yes
# Externally connectable , Cloud server , Just write on the intranet
# bind 127.0.0.1
# Externally owned IP Address access
protected-mode no
# Process documents , Differentiate by port number
pidfile /var/run/redis_7000.pid
logfile “/usr/local/redis/myredis/redis7000/redis.log”
# Persistent file storage location
dir /usr/local/redis/myredis/redis7000/
3、 Cluster configuration information
# Start in a cluster
cluster-enabled yes
# Cluster configuration information file
cluster-config-file nodes-7000.conf
# Timeout time
cluster-node-timeout 15000
cluster-replica-validity-factor 10
cluster-migration-barrier 1
preservation , sign out
4、 Copy profile
We have changed it 7000 Configuration file of port instance , We use commands , Mass replacement
sed 's/7000/7001/g' redis7000/redis.conf > redis7001/redis.conf
…
sed 's/7000/7005/g' redis7000/redis.conf > redis7005/redis.conf
That's right. redis7001 I got a share in it redis.conf file , The port inside is from 7000 replaced 7001, Repeat the command
5、 Boot instance
/usr/local/redis/bin/redis-server /usr/local/redis/myredis/redis7000/redis.conf
…
/usr/local/redis/bin/redis-server /usr/local/redis/myredis/redis7005/redis.conf
…
start-up 6 An example , see redis Operation of the
ps -ef | grep redis

It can be seen that , All instances are started in a cluster mode
6、 Create clusters
/usr/local/redis/bin/redis-cli --cluster create 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005 --cluster-replicas 1
- –cluster-replicas 1 Indicates the master-slave ratio 1:1, In this way, we get a cluster environment with three masters and three slaves
7、 Sign in Redis
/usr/local/redis/bin/redis-cli -h 127.0.0.1 -p 7000
View node information
cluster nodes

You can see Node information of three masters and three slaves
8、 Add a node
- 1、 Add master
/usr/local/redis/bin/redis-cli --cluster add-node 127.0.0.1:7006 127.0.0.1:7000
- add-node: Add a node
- 127.0.0.1:7006: Added node ip:port
- 127.0.0.1:7000: Any node of the cluster already exists ip:port
- 2、 Add slave node
/usr/local/redis/bin/redis-cli --cluster add-node 127.0.0.1:7007 127.0.0.1:7000 --cluster-slave --cluster-master-id nodeId
- add-node: Add a node
- 127.0.0.1:7007: Added node ip:port
- 127.0.0.1:7000: Any node of the cluster already exists ip:port
- –cluster-slave: Add as slave node
- –cluster-master-id: Master node id
9、 Capacity expansion
Our cluster has the concept of slots , left-off key After passing the algorithm , Determine which node it will eventually be stored in , The total slots are 16384 individual , from 0 - 16383.
/usr/local/redis/bin/redis-cli --cluster reshard 127.0.0.1:7000
- reshard: Assign slots
- 127.0.0.1:7000: Any node of the cluster already exists ip:port
Input : Allocate the size of the slot , This depends on the actual situation
Input : The distribution of nodeId
Input : From which master Nodes are allocated , There are three options :all( All , Average distribution )、nodeId( Of a specific node id)、done( The final allocation is completed )
Input :yes
10、 Shrinkage capacity
/usr/local/redis/bin/redis-cli --cluster reshard --cluster-from outNodeId--cluster-slots quantity inNode ip:port
- outNodeId: Migrated nodes id
- quantity: The amount moved out
- inNode ip:port: Immigrated ip:port
Input : Received nodeId
Input :yes
11、 Delete node
/usr/local/redis/bin/redis-cli --cluster del-node 127.0.0.1:7000 nodeId
- 127.0.0.1:7000: Any node of the cluster already exists ip:port
- nodeId: Of the node to be deleted id
Be careful : The slave node should be deleted first , Delete the master node again
If you find deficiencies in reading , Welcome to leave a message !!!
边栏推荐
- Typescript -- preliminary study of variable declaration
- 实现边充边OTG的PD芯片GA670-10
- 844. compare strings with backspace
- Strength and appearance Coexist -- an exclusive interview with Liu Yu, a member of Apache pulsar PMC
- 机器学习笔记 - Kaggle大师Janio Martinez Bachmann的故事
- 山东大学项目实训(四)—— 微信小程序扫描web端二维码实现web端登录
- 机器学习笔记 - 使用TensorFlow的Spatial Transformer网络
- Machine learning notes - spatial transformer network using tensorflow
- 企业决议时,哪个部分应该主导ERP项目?
- [ERP system] how much do you know about the professional and technical evaluation?
猜你喜欢

Type-C蓝牙音箱单口可充可OTG方案

机器学习笔记 - 深度学习技巧备忘清单

Exclusive interview with PMC member Liu Yu: female leadership in Apache pulsar community

Output image is bigger (1228800b) than maximum frame size specified in properties (1048576b)

Day41 process pool and thread pool

Some learning records I=

Blinn Phong reflection model

OpenCV CEO教你用OAK(五):基于OAK-D和DepthAI的反欺骗人脸识别系统

MSF adds back door to normal program

Pulsar job Plaza | Tencent, Huawei cloud, shrimp skin, Zhong'an insurance, streamnational and other hot jobs
随机推荐
2130. maximum twin sum of linked list
[share] how do enterprises carry out implementation planning?
Fabric. JS dynamically set font size
Development of PCBA circuit board for small oxygen generator
Console you don't know
Exclusive interview with PMC member Liu Yu: female leadership in Apache pulsar community
Talk about how to customize data desensitization
【方案开发】红外体温计测温仪方案
Use of MSF evaluation module
Opencv CEO teaches you to use oak (IV): create complex pipelines
工厂出产流程中的这些问题,应该怎么处理?
Install jupyter in the specified environment
Machine learning notes - spatial transformer network using tensorflow
小型制氧机解决方案PCBA电路板开发
Type-C docking station adaptive power supply patent protection case
CUMT学习日记——ucosII理论解析—任哲版教材
基于SIC32F911RET6设计的腕式血压计方案
Kubelet error getting node help
Thread theory
Bowen dry goods | Apache inlong uses Apache pulsar to create data warehousing