当前位置:网站首页>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



边栏推荐
- [HDU] 5248 sequence transformation (greedy + dichotomy) [recommended collection]
- 虚拟数字人里的生意经
- 多个kubernetes集群如何实现共享同一个存储
- State mode - Unity (finite state machine)
- Desci: is decentralized science the new trend of Web3.0?
- Tips and tricks of image segmentation summarized from 39 Kabul competitions
- Big Ben (Lua)
- 初识缓存以及ehcache初体验「建议收藏」
- String - string (Lua)
- Creative changes brought about by the yuan universe
猜你喜欢

cmd命令进入MySQL时报服务名或者命令错误(傻瓜式教学)

Wechat web debugging 8.0.19 replace the X5 kernel with xweb, so the X5 debugging method can no longer be used. Now there is a solution
![[tpm2.0 principle and Application guide] Chapter 16, 17 and 18](/img/7a/b16549590e6445d9199c8000d47d36.png)
[tpm2.0 principle and Application guide] Chapter 16, 17 and 18

Basic operation of chain binary tree (implemented in C language)

Responsibility chain model - unity

648. 单词替换

杰理之相同声道的耳机不允许配对【篇】

超分辨率技术在实时音视频领域的研究与实践

Desci: is decentralized science the new trend of Web3.0?

抢占周杰伦
随机推荐
鸿蒙智能家居【1.0】
杰理之关于 TWS 配对方式配置【篇】
链式二叉树的基本操作(C语言实现)
Where does brain hole come from? New research from the University of California: creative people's neural connections will "take shortcuts"
How many are there (Lua)
国内首次!这家中国企业的语言AI实力被公认全球No.2!仅次于谷歌
Cadre de validation des données Apache bval réutilisé
DeSci:去中心化科学是Web3.0的新趋势?
Desci: is decentralized science the new trend of Web3.0?
Classification and application of enterprise MES Manufacturing Execution System
Command mode - unity
微服务远程Debug,Nocalhost + Rainbond微服务开发第二弹
ES6笔记一
POJ 2392 Space Elevator
Learn open62541 -- [67] add custom enum and display name
數據驗證框架 Apache BVal 再使用
Big Ben (Lua)
POJ 2392 Space Elevator
6. About JWT
杰理之相同声道的耳机不允许配对【篇】