当前位置:网站首页>Master slave replication of redis
Master slave replication of redis
2022-07-22 11:47:00 【It dongdongge】
One 、 Master slave replication configuration
Case study : One master and three followers
Lord :6378
from :6376、6377
# Here is what I use docker Create a container to show you , It can be understood as a virtual machine , If you still don't understand, you can ignore it .
docker run --net host --name=myredis01 --privileged=true \
-v /data/docker/redis/redis.conf:/etc/redis/redis.conf \
-v /data/docker/redis/data:/data \
-d redis:6.2.6 \
redis-server /etc/redis/redis.conf --port 6378docker run --net host --name=myredis02 --privileged=true \
-v /data/docker/redis/redis.conf:/etc/redis/redis.conf \
-d redis:6.2.6 \
redis-server /etc/redis/redis.conf --port 6377docker run --net host --name=myredis03 --privileged=true \
-v /data/docker/redis/redis.conf:/etc/redis/redis.conf \
-d redis:6.2.6 \
redis-server /etc/redis/redis.conf --port 6376
1、 Get ready 3 platform redis Service startup
And connect , This is not a demonstration , It's easy .
2、 Enter one of them to check the server status
info replication
It can be seen that they are all main servers , Then configure the master-slave relationship
3、 Configure master and slave
Get into 6377 and 6376 Slave execution
slaveof master server ip port
4、 Several important points
1) When one of the slaves hangs up , Restart , It's not slave , Need to reconfigure , After reconfiguration , From the opportunity to immediately own all the hosts key
2) At this time, the host down After dropping , The slave will not be upgraded to the master server . After restarting the primary server , Primary server or primary server , This is different from the slave server
5、 Synchronization principle
1) After connecting to the master server , Send data synchronization message from the server to the main service
2) The master server receives a synchronization message from the slave server , Persistence of master server data ,rdb file , hold rdb The file is sent from the server , Get it from the server rdb To read --- Full amount of synchronization
3) Every time the master server writes , And data synchronization from the server --- The incremental synchronization
6、 Going to --- Sentinel mode
When sentinel mode is on , The Sentry will monitor whether the main service is down , If you hang up , From slave Choose a new one master.
stay redis Create a new file in a location of any server vim sentinel.conf, Write the following
sentinel monitor redismaster 47.95.33.138 6378 1
perform redis-sentinel /data/sentinel.conf Activate the sentry , If at this time 6378down It fell off , The remaining two of them will become master Keep working , If 6378 Restart again , Then he will become slave, Loss of eldest brother's power .
1) shortcoming : Replication delay
Because all the writing operations are first in Master On the operation , Then sync update to slave On , So from Master Synchronize to slave The machine has a certain delay , When the system is busy , The delay problem will be more serious ,slave The increase in the number of machines will make the problem more serious .
2) Select new master principle
a. redis.conf In the configuration of the replica-priority The smaller, the easier it is to be elected . Default 100
replica-priority 100
b. Select servers with high data offset , Generally speaking, it is , With the highest amount of synchronization with the previous master server
c. choice runid The smallest slave
Two 、PHP、Java Link master-slave Services
according to sentinel Get the master server link from the master server name in the configuration , You can search for details by yourself
边栏推荐
- See and use & math operations & pytoch official document summary & Notes (V)
- "Money laundering"
- OpenOffice startup and auto startup settings
- Recommended reading: how can testers get familiar with new businesses quickly?
- The difference between request forwarding and request redirection
- Classic interview questions of interface testing: what is the difference between session, cookie and token?
- 请求转发和请求重定向的区别
- How can CIOs avoid stepping on the pit in the digital transformation of B2B enterprises
- Leetcode skimming -- bit by bit record 019
- H264之帧编码——透析(I帧+P帧+B帧编码)原理与流程
猜你喜欢
PR
Translation of multiple UAV exploration of an unknown region
“洗钱”
嵌入式分享合集18
MySQL插入数据insert ignore和replace into
[solution]vscode code code auto wrap bug without completion of input
H264之帧编码——透析(I帧+P帧+B帧编码)原理与流程
News blog publishing system based on jsp+servlet+mysql
Partner cloud Dai Zhikang: how to use low code to improve R & D and it efficiency
伙伴云戴志康:如何利用低代码提升研发和IT效能
随机推荐
详解Redis的数据结构
物品万维网资源管理框架研究与应用
Meta:从移动技术发展和创新来预测元宇宙的潜在影响
多线程与高并发day09
Leetcode skimming -- drip record 020
The world's first large aerospace model came out, and Wenxin supplemented the picture of Fuchun Mountain Residence, which is the perseverance of Baidu Pratt Whitney AI
Pyinstaller打包 && 关于Enum34的问题解决 && 降低版本
Android 面试题:说一下 PendingIntent 和 Intent 的区别
lc marathon 7.21
移动端Web App 的屏幕适配方法(总结)
IP第十二天笔记
Deep analysis: could not run 'torch vision:: NMS' with arguments from the' CUDA 'backend
伙伴云戴志康:如何利用低代码提升研发和IT效能
TZC 1283: simple sort - quick sort
Framework customization series (10) -- systemui customization status bar statusbar and navigation bar tutorial
Is it just an illusion that the encryption market soared to more than $1trillion? The crypto bear market is far from bottoming out
Explain the data structure of redis in detail
全球首个航天大模型问世,文心秒补《富春山居图》,这是百度普惠AI的恒心
Search for matching files or directories under folders glob ()
PHP生成器的使用yield性能优化