当前位置:网站首页>Set up sentinel mode. Reids and redis leave the sentinel cluster from the node
Set up sentinel mode. Reids and redis leave the sentinel cluster from the node
2022-07-02 19:34:00 【Charmaine Xia】
Install stand alone reids Detailed tutorial :https://blog.csdn.net/CharmaineXia/article/details/125297843?spm=1001.2014.3001.5502
Build a master-slave mode cluster redis:https://blog.csdn.net/CharmaineXia/article/details/125298465
0. Introduction to sentinel mode
In order to prevent master-slave mode reids After the primary node goes down , The entire cluster cannot be used , The sentry is watching redis Master node , If the primary node goes down , The Sentry will be redis Choose one of the nodes as the master node .
A sentry also has its own risk of downtime , So usually, multiple sentinels will be opened , The Sentinels communicate with each other , After the primary node goes down , The Sentinels will pass “ Voting mechanism ” Select from the nodes redis Master node .
Sentinel mode includes the advantages of master-slave mode , It also increases stability .
Sentinel mode is based on master-slave mode , Set up the master-slave mode before setting up the sentry .
Sentinels should also build clusters , One master and two slaves share 3 individual reids process 、3 A sentinel process .
All three servers are configured with sentry files , And activate the sentry , First configure the sentry configuration file of a server , Then copy the configuration file to other servers .
1. Set profile path ( You don't have to )
① Create a new directory , Native sentinel.conf Make a backup , Start the configuration file with only the following path .
mkdir /home/admin/redis/redis-5.0.7/redisSentinel
② Copy the configuration file
cp -r mkdir /home/admin/redis/redis-5.0.7/sentinel.conf /home/admin/redis/redis-5.0.7/redisSentinel
2. Modify the sentry profile
① Modify the configuration file
vi /home/admin/redis/redis-5.0.7/redisSentinel/sentinel.conf
## modify 1: Give Way sentinel The service runs in the background
daemonize yes
## modify 2: Add log file path
logfile “/home/admin/redis/redis-5.0.7/sentinel.log”
## modify 3: increase redis Master node information and the legal number of elections (2 It means only 2 Sentinel nodes simultaneously think master Node aging , It is really invalid )
hold sentinel monitor mymaster 127.0.0.1 6379 2 Change to
sentinel monitor mymaster 192.168.60.83 6379 2
② If the configuration file is copied , You also need to note the Sentinel's myid, Start the sentinel and generate a new myid.
Otherwise the sentinel myid identical , There is no communication between the Sentinels .
③ View the modified configuration file
cat sentinel.conf |grep -v “#”|grep -v “^$”
3. Operation sentry
① Start three redis service ( Start the host first , Rear start slave )
cd /usr/local/bin/
./redis-server /home/admin/redis/redis-5.0.7/theRedisConf/redis.conf
② Start three sentinel Services ( Start the host first , Rear start slave )
cd /usr/local/bin/
./redis-sentinel /home/admin/redis/redis-5.0.7/redisSentinel/sentinel.conf
4. Check the sentry's configuration file after all starts
cat /home/admin/redis/redis-5.0.7/redisSentinel/sentinel.conf |grep -v “#”|grep -v “^$”
5. Verify whether the sentry is started successfully
① Connect the sentry :
redis-cli -p 26379 Or enter src perform ./redis-cli -p 26379
② Query the current node status :
info sentinel
127.0.0.1:26379> info sentinel
# Sentinel
sentinel_masters:1
sentinel_tilt:0
sentinel_running_scripts:0
sentinel_scripts_queue_length:0
sentinel_simulate_failure_flags:0
master0:name=mymaster,status=ok,address=192.168.60.83:6379,slaves=2,sentinels=3
③ View master status
sentinel master mymaster
④ View the slave node status
sentinel slaves mymaster
⑤ Check the status of all sentinels
sentinel sentinels mymaster
6、 ... and 、 The test of separating the slave node from the sentinel cluster :
Premise : Sentinel mode (3 individual redis:60.83( Master node )、60.84、60.85, as well as 3 A sentinel )
redis Execute... From node “SLAVEOF NO ONE” command , This will cause the secondary server to turn off replication , And from the slave server back to the master server , The data set from the original synchronization will not be discarded .
test 1: Launch three sentinels ,60.85 Execute the command to change the master node , The query information becomes the main node immediately , There is no slave node itself . Check at the same time 60.83 It is still the master node ,60.85 It is still its slave node . Check in less than a minute 60.85 Change back 60.83 The slave node ( The following figure for 60.83 Information about ).
Conclusion : The sentry's configuration file records redis Of master and slave nodes IP, Once the sentry finds a slave node “ Independent ” 了 , Will pull this from the node redis In the cluster . test 1 Failed to detach from the master node .
test 2: Shut down all sentinels ,60.85 Execute the command to change the master node , The query information becomes the main node immediately , There is no slave node itself . Check at the same time 60.83 It is still the master node ,60.85 It is no longer its slave node . Check in a minute 60.85 No change back 60.83 The slave node .

restart 60.85 After service , see 60.83,60.85 Become 60.83 The slave node , see 60.85 Is shown as 60.83 Slave of .

Conclusion : because 60.85 In the configuration file of 60.83 Set as primary node , restart 60.85 Will return to 60.83 The slave node .
The final conclusion : The order is immediate , The settings in the configuration file take effect every time the service is started , When executed “SLAVEOF NO ONE” Will only temporarily let redis The slave machine leaves the cluster ( Without opening the sentry ). Want to make redis Slave 60.85 Permanently from sentinel mode redis Break away from the cluster , Need to be closed redis Slave 60.85 And all sentinels , And then delete redis Slave 60.85 In the configuration file redis host 60.83 Of IP Information 、 All sentinel profiles are about redis Slave 60.85 Of IP Information , The last restart edis60.85 And all sentinels .
边栏推荐
- AcWing 1137. Select the best line solution (the shortest circuit)
- 守望先锋世界观架构 ——(一款好的游戏是怎么来的)
- In pytorch function__ call__ And forward functions
- 453-atoi函数的实现
- Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径
- 教程篇(5.0) 09. RESTful API * FortiEDR * Fortinet 网络安全专家 NSE 5
- Getting started with typescript
- Juypter notebook modify the default open folder and default browser
- 数字滚动带动画
- 搭建哨兵模式reids、redis从节点脱离哨兵集群
猜你喜欢

Tutoriel (5.0) 10. Dépannage * fortiedr * fortinet Network Security expert NSE 5

mysql函数

Educational Codeforces Round 129 (Rated for Div. 2) 补题题解

Watchful pioneer world outlook Architecture - (how does a good game come from)

Reading notes of "the way to clean structure" (Part 2)

搭建主从模式集群redis

Advanced performance test series "24. Execute SQL script through JDBC"

Registration opportunity of autowiredannotationbeanpostprocessor under annotation development mode

机器学习笔记 - 时间序列预测研究:法国香槟的月销量

教程篇(5.0) 10. 故障排除 * FortiEDR * Fortinet 网络安全专家 NSE 5
随机推荐
Which video recording software is better for the computer
Bubble sort array
AcWing 181. 回转游戏 题解(搜索—IDA*搜索)
Is there any security guarantee for the ranking of stock and securities companies
PHP非对称加密方法私钥及公钥加密解密的方法
注解开发方式下AutowiredAnnotationBeanPostProcessor的注册时机
为什么要做企业固定资产管理系统,企业如何加强固定资产管理
Web2.0 giants have deployed VC, and tiger Dao VC may become a shortcut to Web3
MySQL高级(进阶)SQL语句
以太网PHY层芯片LAN8720A简介
教程篇(5.0) 09. RESTful API * FortiEDR * Fortinet 网络安全专家 NSE 5
According to the atlas of data security products and services issued by the China Academy of information technology, meichuang technology has achieved full coverage of four major sectors
2022 compilation principle final examination recall Edition
451-memcpy、memmove、memset的实现
AcWing 1125. Cattle travel problem solution (shortest path, diameter)
Machine learning notes - time series prediction research: monthly sales of French champagne
AcWing 1129. 热浪 题解(最短路—spfa)
Use cheat engine to modify money, life and stars in Kingdom rush
Web2.0 giants have deployed VC, and tiger Dao VC may become a shortcut to Web3
电脑使用哪个录制视频软件比较好