当前位置:网站首页>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 .
边栏推荐
猜你喜欢

开发固定资产管理系统,开发固定资产管理系统用什么语音

Codeworks 5 questions per day (1700 average) - day 4

Tutorial (5.0) 10 Troubleshooting * fortiedr * Fortinet network security expert NSE 5

Py之interpret:interpret的简介、安装、案例应用之详细攻略

数据湖(十二):Spark3.1.2与Iceberg0.12.1整合

xml开发方式下AutowiredAnnotationBeanPostProcessor的注册时机

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

Juypter notebook modify the default open folder and default browser
![[error record] problems related to the installation of the shuttle environment (follow-up error handling after executing the shuttle doctor command)](/img/c1/a00425f2e1824a50644c8fbb15fe38.jpg)
[error record] problems related to the installation of the shuttle environment (follow-up error handling after executing the shuttle doctor command)
冒泡排序数组
随机推荐
《代码整洁之道》读书笔记
以太网PHY层芯片LAN8720A简介
【pytorch学习笔记】Tensor
数字滚动带动画
AcWing 340. 通信线路 题解(二分+双端队列BFS求最短路)
Windows2008r2 installing php7.4.30 requires localsystem to start the application pool, otherwise 500 error fastcgi process exits unexpectedly
golang:[]byte转string
2022.7.1-----leetcode. two hundred and forty-one
Thread application instance
Registration opportunity of autowiredannotationbeanpostprocessor under annotation development mode
MySQL
Memory management of C
教程篇(5.0) 09. RESTful API * FortiEDR * Fortinet 网络安全专家 NSE 5
函数高阶-柯里化实现
AcWing 1137. Select the best line solution (the shortest circuit)
AcWing 1125. Cattle travel problem solution (shortest path, diameter)
字典
云呐|为什么要用固定资产管理系统,怎么启用固定资产管理系统
MySQL table historical data cleaning summary
Function high order curry realization