当前位置:网站首页>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 .
边栏推荐
- SIFT特征点提取「建议收藏」
- 注解开发方式下AutowiredAnnotationBeanPostProcessor的注册时机
- Chic Lang: completely solve the problem of markdown pictures - no need to upload pictures - no need to network - there is no lack of pictures forwarded to others
- Educational Codeforces Round 129 (Rated for Div. 2) 补题题解
- 数据降维——因子分析
- GMapping代码解析[通俗易懂]
- 守望先锋世界观架构 ——(一款好的游戏是怎么来的)
- Gamefi链游系统开发(NFT链游开发功能)丨NFT链游系统开发(Gamefi链游开发源码)
- Binary operation
- 《重构:改善既有代码的设计》读书笔记(下)
猜你喜欢
《重构:改善既有代码的设计》读书笔记(下)
AcWing 340. 通信线路 题解(二分+双端队列BFS求最短路)
数据湖(十二):Spark3.1.2与Iceberg0.12.1整合
Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径
搭建主从模式集群redis
线程应用实例
zabbix5客户端安装和配置
Advanced performance test series "24. Execute SQL script through JDBC"
机器学习笔记 - 时间序列预测研究:法国香槟的月销量
Develop fixed asset management system, what voice is used to develop fixed asset management system
随机推荐
Microservice technology - distributed global ID in high concurrency
453-atoi函数的实现
MySQL table historical data cleaning summary
MySQL表历史数据清理总结
Web2.0 giants have deployed VC, and tiger Dao VC may become a shortcut to Web3
PHP asymmetric encryption method private key and public key encryption and decryption method
Golang concurrent programming goroutine, channel, sync
AcWing 1131. Saving Private Ryan (the shortest way)
Preprocessing and preprocessing macros
嵌入式(PLD) 系列,EPF10K50RC240-3N 可编程逻辑器件
Develop fixed asset management system, what voice is used to develop fixed asset management system
Yunna | why use the fixed asset management system and how to enable it
2022.7.1-----leetcode.241
AcWing 1127. 香甜的黄油 题解(最短路—spfa)
Web2.0的巨头纷纷布局VC,Tiger DAO VC或成抵达Web3捷径
Markdown基础语法
Npoi export Excel2007
《代碼整潔之道》讀書筆記
Use cheat engine to modify money, life and stars in Kingdom rush
Educational Codeforces Round 129 (Rated for Div. 2) 补题题解