当前位置:网站首页>Redis master-slave and sentinel master-slave switchover are built step by step
Redis master-slave and sentinel master-slave switchover are built step by step
2022-07-07 19:20:00 【Poetic elegance】
- Redis Support master-slave reuse . Data can be synchronized from the master server to any number of slaves , Synchronization uses Publishing / Subscribe mechanism .Mater Slave The pattern of , from Slave towards Master launch SYNC command .
- It can be 1 Master many Slave, It can be layered ,Slave You can connect to Slave, It can be expanded into a tree structure .
- Because there are no two computers , So you can only build two on one machine Redis Server side .
- Here we use a single machine to simulate redis Master slave server , Realize read-write separation configuration .
List of articles
- Create three directories ( Data files 、 Log files 、 The configuration file )
- Copy redis.conf to /opt/redis/conf Under the table of contents
- modify redis-common.conf Public profile
- Comment out bind 127.0.0.1
- Turn off protection mode , It is amended as follows no
- Comment public configuration port
- Change to background start
- Note process number record file
- Comment on the public configuration data file 、 Modify data file path
- Add authentication from server to master server
- Add access authentication
- Comment public configuration append file
- add to 3 A private profile of a service
- function 3 individual redis process
- see redis Server master-slave status
- Sentinel configuration
- modify sentinel-common.conf Sentinel public profile
- Modify configuration information
- Note sentinel listening process port number
- Local area network IP, Otherwise, remote connection will not be possible
- Set up master and slaves Password
- Turn off protection mode , It is amended as follows no
- Change to background start 
- add to 3 A private configuration file for sentinels
- Start the test
- See if the sentry is finished
Create three directories ( Data files 、 Log files 、 The configuration file )

Copy redis.conf to /opt/redis/conf Under the table of contents

modify redis-common.conf Public profile
Comment out bind 127.0.0.1

Turn off protection mode , It is amended as follows no

Comment public configuration port

Change to background start

Note process number record file

Comment on the public configuration data file 、 Modify data file path
By default ,Redis Save the database snapshot in a file named dump.rdb In the binary file of . Of course , This can be modified redis.conf Configuration file to define data storage conditions , It is stipulated in “ N At least... In seconds M A change ” When this condition is met , Save the data set automatically once . You can also call save or bgsave , Let go by hand Redis Save the dataset dbfilename and dir Use a combination of ,dbfilename look for dir Path generation data file 
Add authentication from server to master server

Add access authentication

Comment public configuration append file

add to 3 A private profile of a service
touch perhaps vi Can create a blank file
touch Create a blank file directly , vi Create and enter edit mode , :wq Create success , Otherwise, do not create 
redis-6379.conf
# Reference public configuration
include /opt/redis/conf/redis-common.conf
# Process number record file
pidfile /var/run/redis-6379.pid
# Process port number
port 6379
# Log files
logfile "/opt/redis/log/redis-6379.log"
# Data record file
dbfilename dump-6379.rdb
# Add file name
appendfilename "appendonly-6379.aof"
# The following configuration does not need to be in 6379 Internal configuration
# The backup server is subordinate to 6379 Recommended configuration with lan IP
slaveof 192.168.10.100 6379
redis-6380.conf
# Reference public configuration
include /opt/redis/conf/redis-common.conf
# Process number record file
pidfile /var/run/redis-6380.pid
# Process port number
port 6380
# Log files
logfile "/opt/redis/log/redis-6380.log"
# Data record file
dbfilename dump-6380.rdb
# Add file name
appendfilename "appendonly-6380.aof"
# The following configuration does not need to be in 6379 Internal configuration
# The backup server is subordinate to 6379 Recommended configuration with lan IP
slaveof 192.168.32.200 6379
redis-6381.conf
include /opt/redis/conf/redis-common.conf
# Process number record file
pidfile /var/run/redis-6381.pid
# Process port number
port 6381
# Log files
logfile "/opt/redis/log/redis-6381.log"
# Data record file
dbfilename dump-6381.rdb
# Add file name
appendfilename "appendonly-6381.aof"
# The following configuration does not need to be in 6379 Internal configuration
# The backup server is subordinate to 6379 Recommended configuration with lan IP
slaveof 192.168.32.200 6379
function 3 individual redis process

see redis Server master-slave status
redis-6379
redis-6380
redis-6381
Sentinel configuration
Master slave node redis.conf To configure
reference Read / write separation The corresponding configuration of
modify sentinel-common.conf Sentinel public profile
from redis Unzip the directory to copy sentinel.conf to /opt/redis/conf/
Change the name 
Modify configuration information
Note sentinel listening process port number

Local area network IP, Otherwise, remote connection will not be possible

Set up master and slaves Password

Turn off protection mode , It is amended as follows no

Change to background start 
add to 3 A private configuration file for sentinels
touch perhaps vi Can create a blank file
touch Create a blank file directly , vi Create and enter edit mode , :wq Create success , Otherwise, do not create 
sentinel-26379.conf
# Reference public configuration
include /opt/redis/conf/sentinel-common.conf
# Process port number
port 26379
# Process number record file
pidfile /var/run/sentinel-26379.pid
# Log files ( For the convenience of viewing the log , Comment out first , After setting up the environment, open it again )
logfile "/opt/redis/log/sentinel-26379.log"
Copy sentinel-26379.conf From the content of sentinel-26380.conf , sentinel-26381.conf And modify its content , take 26379
Replace it .
Start the test
start-up 3 individual redis service 
start-up 3 A sentinel service 
See if the sentry is finished



边栏推荐
- Business experience in virtual digital human
- ip netns 命令(备忘)
- Cadre de validation des données Apache bval réutilisé
- 2022.07.02
- In 2021, the national average salary was released. Have you reached the standard?
- 完整的电商系统
- Research and practice of super-resolution technology in the field of real-time audio and video
- unity2d的Rigidbody2D的MovePosition函数移动时人物或屏幕抖动问题解决
- 抢占周杰伦
- 2022-07-04 matlab读取视频帧并保存
猜你喜欢

Do you know all four common cache modes?

多个kubernetes集群如何实现共享同一个存储

3.关于cookie

Chief technology officer of Pasqual: analog quantum computing takes the lead in bringing quantum advantages to industry

2022.07.02

索引总结(突击版本)

SlashData开发者工具榜首等你而定!!!
![[tpm2.0 principle and Application guide] Chapter 9, 10 and 11](/img/7f/0d4d91142bc3d79ea445a8f64afba7.png)
[tpm2.0 principle and Application guide] Chapter 9, 10 and 11

App capture of charles+drony

Mathematical analysis_ Notes_ Chapter 11: Fourier series
随机推荐
3.关于cookie
In 2021, the national average salary was released. Have you reached the standard?
Creative changes brought about by the yuan universe
testing and SQA_ Dynamic white box test [easy to understand]
ES6笔记一
3. About cookies
ES6 note 1
Classification and application of enterprise MES Manufacturing Execution System
Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
解决rosdep的报错问题
Redis
Continuous test (CT) practical experience sharing
Hongmeng smart home [1.0]
Jerry's headphones with the same channel are not allowed to pair [article]
咋吃都不胖的朋友,Nature告诉你原因:是基因突变了
POJ 1182 :食物链(并查集)[通俗易懂]
高温火烧浑不怕,钟薛高想留清白在人间
Responsibility chain model - unity
String - string (Lua)
博睿数据入选《2022爱分析 · IT运维厂商全景报告》