当前位置:网站首页>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
边栏推荐
- Sentinel vs Hystrix 限流对比,到底怎么选?
- How to choose sentinel vs. hystrix current limiting?
- 2022 latest examination questions and answers of eight members (standard staff) of Shanghai Architecture
- 2022-07-18: what is the output of the following go language code? A:Groutine; B:Main; C:Goroutine; D:GoroutineMain。 package m
- [hand tear STL] BitSet (bitmap), bloom filter
- Automatic assembly and fuse degradation of feign
- Pyg tutorial (8): calculate a more efficient sparse matrix form
- Simple use of protobuf
- [database] index
- How to implement distributed locks with redis?
猜你喜欢

【饭谈】那些看似为公司着想,实际却让人无法理解的事(二:面试时的软素质“眼缘”)
![[hand torn STL] unordered_ set、unordered_ Map (encapsulated with hash table)](/img/33/08f7b72ce99e07821a1f4b6e594e13.png)
[hand torn STL] unordered_ set、unordered_ Map (encapsulated with hash table)

How to solve the problem of high concurrency and large traffic with PHP

Create EDA - why should I learn EDA

【leetcode天梯】链表 · 021 合并两个有序链表

开源的RSS订阅器FreshRSS

Pyg tutorial (8): calculate a more efficient sparse matrix form

Oracle RAC RMAN backup error ora-19501 ora-15081

Research: more than 70% of doctors are still prescribing unsafe antibiotic drugs

Redis usage details
随机推荐
How to solve the problem of high concurrency and large traffic with PHP
如何用 Redis 实现分布式锁的?
Apache Shenyu admin authentication bypass vulnerability (cve-2021-37580) analysis and protection measures
[leetcode ladder] linked list · 876 find the middle node of the linked list
如何快速搭建图片服务器[通俗易懂]
pyqt5使用pyqtgraph绘制多个Y值散点图
5、 Pinda general permission system__ PD tools XXS (anti cross site script attack)
919. Complete binary tree inserter: simple BFS application problem
[MAIXPY]kpu: load error:2005, ERR_READ_FILE: read file failed问题解决
大厂面试官:千万级数据量的表,如何进行快速查询?
少儿编程 电子学会图形化编程等级考试Scratch一级真题解析(判断题)2022年6月
【leetcode天梯】链表 · 021 合并两个有序链表
es6--解构赋值
动画曲线天天用,你能自己整一个吗?看完这篇你就会了!
Job interviews are always a second kill? After reading the seckill system notes secretly stored by JD T8, I have given my knees
Bitcoin.com:usdd represents a truly decentralized stable currency
Guys, how can Flink SQL submit tasks in per job mode?
2022最新软件测试八股文,能不能拿心仪Offer就看你背得怎样了
Does the open source agreement have legal effect?
Ijcai2022 meeting! Microsoft and other tutorials on domain generalization