当前位置:网站首页>Redis master-slave architecture lock failure problem (master-slave)
Redis master-slave architecture lock failure problem (master-slave)
2022-07-25 21:50:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
One 、 Get ready 1、 modify pidfile And port
2、 close RDB Persistent modify the storage location of the persistent file
3、 start-up Redis
redis-server /etc/redis.conf4、 Use client connection Redis
redis-cliTwo 、 Master slave copy ( Read / write separation ) redis The master-slave replication function of is very powerful , One master You can have multiple slave, And one slave You can have more than one slave, Go on like this , Formed a powerful multi-level server cluster architecture . You can avoid redis A single point of failure , Build a read-write separation architecture , Meet the application scenario of reading more and writing less . 1、 Master slave replication principle
①slave Initiate request and master Establishing a connection ,master After verification, the connection can be established . ②slave Send synchronization sync The order of , At this time, the main database will start a new sub process , Import data into by snapshot rdb In file , And transfer it to the slave library ③ From the library rdb The file is imported into the database , And load it into memory ④ When synchronizing later ,master Will give all orders first buffer get up , Can't write to disk , Direct to slave. remarks : If master restart , The backup data will be re dump.
2、Redis Several important aspects of replication
① One Master There can be multiple Slave; ②Redis Use asynchronous replication . from 2.8 Start ,Slave It will be cyclical ( Once a second ) To launch a Ack Confirm the copy stream (replication stream) The progress of being processed ; ③ Not only the master server can have slave servers , The slave server can also have its own slave server , Multiple slave servers can form a graphical structure ④ Copy on Master The end is non blocking , This means that even multiple Slave When performing the first synchronization ,Master You can still provide query services ; ⑤ Copy on Slave The end is also non blocking : If you are in the redis.conf Set it up ,Slave When performing the first synchronization, you can still use the old dataset to provide queries ; You can also configure to be Master And Slave When you lose contact , Give Way Slave Return an error prompt to the client ; ⑥ When Slave Delete the old data set , And reload the new version of data ,Slave Will block connection requests ( It usually happens with Master Recovery phase after disconnection and reconnection ); ⑦ Replication can be used for data redundancy only (dataredundancy), You can also improve scalability by having multiple read-only command requests processed from the server (scalability): for instance , Heavy SORT Commands can be given to affiliated nodes to run . ⑧ It can be modified by Master Terminal redis.config To avoid Master Perform persistence operation on the end (Save), from Slave End to end persistence .
3、 ... and 、 Master slave architecture
1、 Get ready 3 The configuration file ports are
6379 (Master)
6380 (Slave)
6381 (Slave)2、 Modify the original redis.conf file , Copy out 2 individual redis.conf file
mv /etc/redis.conf /etc/redis.6379.conf
cp /etc/redis.6379.conf /etc/redis.6380.conf
cp /etc/redis.6379.conf /etc/redis.6381.conf3、 modify 6380 and 6381 The configuration file vim /etc/redis.6380.conf
Replace by command 6379 by 6380
:%s/6379/6380/gAppear at the bottom
Indicates the modification is successful , wq Exit and save
4、 Modify in the same way 6381 Configuration file for 5、 start-up 3 individual redis example
redis-server /etc/redis.6379.conf
redis-server /etc/redis.6380.conf
redis-server /etc/redis.6381.conf6、 adopt ps Command view redis process
ps -ef | grep redis7、 The master-slave configuration includes 2 Methods : ① On all slave nodes redis.conf(redis.6380.conf and redis.6381.conf) Set in slaveof
② Use redis-cli The client connects to Redis In service , perform slaveof command This method will lose the master-slave replication relationship after restart
8、 View master-slave information :INFO replication ① Main database query
② Information displayed from the Library
③ Test the master-slave relationship Write data in the main library , Then read data from the Library
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/127911.html Link to the original text :https://javaforall.cn
边栏推荐
- 【leetcode天梯】链表 · 021 合并两个有序链表
- [manageengine]itsm application in retail industry
- Research on the scheme of MySQL advanced (VIII) sorting problem
- Oracle RAC RMAN backup error ora-19501 ora-15081
- mouseEvent事件——mouse坐标描述——focus事件——input事件——节流(thorttle)——mouseWheel(滚轮事件)
- 五、品达通用权限系统__pd-tools-xxs(防跨站脚本攻击)
- Vivo official website app full model UI adaptation scheme
- 2022 love analysis ― bank digitalization practice report
- 选择的能力
- zigbee开发板(nxpzigbee开发)
猜你喜欢

Optimization analysis of storage structure and IO performance of openharmony littlefs file system

Lichuang EDA -- creation of devices 01 resistance (II)

Bitcoin.com:USDD代表了真正去中心化稳定币

Special class design

Origen foundation officially launched $ogy stacking, leading a new round of ecological benefits

如何用 Redis 实现分布式锁的?

Share | intelligent fire emergency management platform solution (PDF attached)
![[hand tear STL] BitSet (bitmap), bloom filter](/img/bc/a6e3c2ccce478460a2742852eee9cf.png)
[hand tear STL] BitSet (bitmap), bloom filter

【饭谈】如何设计好一款测试平台?

919. 完全二叉树插入器 : 简单 BFS 运用题
随机推荐
五、品达通用权限系统__pd-tools-xxs(防跨站脚本攻击)
8000 word super detailed custom structure type
Performance debugging -- chrome performance
如何快速搭建图片服务器[通俗易懂]
How to choose sentinel vs. hystrix current limiting?
函数栈帧的创建和销毁
卸载npm和安装npm_使用`npm uninstall`卸载npm软件包「建议收藏」
Vivo official website app full model UI adaptation scheme
Six principles of C program design
PE格式: 分析IatHook并实现
[redis underlying parsing] string type
【面试:并发篇24:多线程:综合练习】顺序控制
【饭谈】测试平台为什么有组件化?模块化?很多看不到的地方设计的很好是种浪费么?
Pyqt5 use pyqtgraph to draw multiple y-value scatter plots
[database] index
Basic knowledge in the project
2022 latest examination questions and answers of eight members (standard staff) of Shanghai Architecture
ES6 -- Deconstruction assignment
Configuration and use of multithreading
2022最新软件测试八股文,能不能拿心仪Offer就看你背得怎样了