当前位置:网站首页>Redis master-slave replication & sentinel mode
Redis master-slave replication & sentinel mode
2022-07-21 01:57:00 【S_ ng】
1.1 What is master-slave replication
After the master database data is updated, according to the configuration and strategy , Auto sync to slave Library ( Backup machine ) Of master/slaver Mechanism ,master( Main library ) Write first ,slave( Slave Library ) Mainly reading .
1.2 The role of master-slave replication
Read / write separation : master Write first ,slave Mainly reading .
disaster recovery : because slaves The data of master Copy of , Whether it's master still slaves Data can be effectively recovered after downtime .
1.3 Environmental preparation
1.3.1 Copy three copies redis Configuration file for
They can be named redis-6379.conf 、redis-6380.conf、redis-6381.conf
cd /usr/local/bin/tlconfig
cp redis.conf redis-6379.conf
cp redis.conf redis-6380.conf
cp redis.conf redis-6381.conf
1.3.2 Set up guards
daemonize yes
1.3.3 Set port
Three configuration files set ports respectively
port 6379,port 6380 and port 6381 We put 6379 As the master ,6380 and 6381 As from
Set up pid
pid The file paths are configured as
pidfile /var/run/redis_6379.pid,
pidfile /var/run/redis_6380.pid
pidfile /var/run/redis_6381.pid
Set up log
log The names are configured as
logfile "6379.log",
logfile "6380.log"
logfile "6381.log"
Set up db
db The file names are configured as
dbfilename dump6379.rdb
dbfilename dump6380.rdb
dbfilename dump6381.rdb
1.4 start-up
Separate use redis-6379.conf、redis-6380.conf、redis-6381.conf To start three services
redis-server tlconfig/redis-6379.conf
redis-server tlconfig/redis-6380.conf
redis-server tlconfig/redis-6381.conf
1.5 Client connection
Use three command line windows to connect redis service .
1.6 Master slave replication mode
Three common moves :
One master and two subordinates
It's passed down from generation to generation
Going to
2.1 What is sentinel mode
A group of sentinel Can monitor multiple master
The automatic version of anti guest oriented , It can be seen from the anti guest focus , When the main library goes down , You need to manually reselect the new master, And modify it again slave The main library of points to . Sentinel mode can monitor the main library in the background in case of failure , Then automatically select a new master database from the slave database according to the vote , And other slave libraries take the new master library as master.
The difference between it and anti guest oriented is that it is old master After reconnection , old master Will also become new master Of slave.
sentinel monitor Name of monitored database ( Customize ) Monitored database ip Address Port number of monitored database Number of votes , Indicates that when the monitored database fails , Automatically vote from the Library , When the slave database reaches the specified number of votes, it becomes the new master database of other slave databases .
2.2 Environment building
2.2.1 newly build sentinel.conf
newly build sentinel.conf file , The name must not be wrong
cd /usr/local/bin
touch sentinel.conf
2.2.2 To configure sentinel.conf
sentinel monitor 145-79 192.168.2.145 6379 1
sentinel auth-pass 145-79 root
2.2.3 start-up
start-up 6379,6380,6381
79 Respectively 80 and 81 Main library ( One master and two subordinates )
The new window uses redis-sentinel sentinel.conf With sentinel Way to start redis Monitoring service
use shutdown demonstration 79 After downtime , It can be seen from the log that , The background is voting to select a new master library from the slave libraries .
边栏推荐
- Force deduction question brushing record 1---704 Binary search
- ICLR 2022 | gnnaskernel: a general framework that can improve the expression ability of any GNN
- 371 pages of 200000 words 2021 smart city informatization comprehensive construction plan
- 超分领域常见的损失函数
- V4L2学习笔记
- 2022 Hangzhou future science and technology city digital economy talent programming competition 02 Black and white chess game_____ sliding window
- SparkCore算子及案例,220719,
- 编译+链接和预处理
- 【琐琐碎碎小知识】 关于部分Unity编辑器在创建瓦片地图时缺乏Tiles选项
- 【obs】Transform: fit to screen
猜你喜欢
Ampere Altra Max 提供可持续的高分辨率 H.265 编码
Highest evaluation: the development career path you want to follow, your determination and action are thorough, sincere and absolutely true
Exch2010:重建整个 DAG
【AD学习记录】为什么原理图和PCB都在同一个文件夹下面了却,无法生成PCB?
高通和MTK针对国家wifi channel 客制化修改方法
【腾讯位置组件】 微信公众号h5 调用腾讯地图组件
Understanding and applying continuous integration Tekton
95 pages intelligent factory digitalization, intelligent planning, solutions and construction scheme 2022
如何选择数据应用开发语言和环境
通过例子学C标准库<assert.h>
随机推荐
MATLAB:将figure图打印成pdf格式
【upload靶场12-16】截断、图片马
【obs】Transform: fit to screen
Unity shader implements the image with rounded corners and edge borders
【R语言文本挖掘】:情感分析与词云图绘制
C——变量的作用域与存储类
Clion creates the first C project
Ampere Altra Max provides sustainable high-resolution h.265 coding
Multimodal model clip4clip takes you to realize mutual search between text and video
【腾讯位置组件】 微信公众号h5 调用腾讯地图组件
Matlab summary of differential equation solving methods
C语言实现二叉树线索化
.Net Core快速开发平台,强大工作流引擎,多系统快速配置
"Weilai Cup" 2022 Niuke summer multi school training camp 1 I chiitoitsu (probability DP)
MySQL 事务管理
[after reading] relevant blogs of NiO
过滤器和拦截器区别
Win:使用 netsh 命令配置 Port Forwarding
[leetcode] sword finger offer 53 - ii Missing numbers from 0 to n-1
[LeetCode]剑指 Offer 58 - II. 左旋转字符串