In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces whether Redis Cluster will lose data in the end, the content is very detailed, interested friends can use for reference, I hope it can be helpful to you.
Will Redis Cluster lose data?
Redis Cluster does not guarantee strong consistency, and in some special scenarios, the client may lose data even if it receives a write acknowledgement.
Scenario 1: asynchronous replication
Client writes to master B
Master B replies to OK
Master B synchronizes to slave B1 B2 B3
B replied to client without waiting for the confirmation of B1 B2 B3. If master goes down before slave synchronization is completed, one of the slave will be selected as master, and the data written by client will be lost.
The wait command enhances data security in this scenario.
Wait blocks the current client until the previous write operation is successfully synchronized by a specified number of slave.
Wait can improve the security of data, but it does not guarantee strong consistency.
Because even if this synchronous replication method is used, there is a special case: a slave that does not complete synchronization is elected as master.
Scenario 2: network Partition
6 nodes A, B, C, A1, B1, C1, 3 master,3 slave, and one client,Z1.
After the network partition occurs, two zones, A, C, A1, B1, C1 and BZ1, are formed.
At this time, Z1 can still write to B, if the partition is restored in a short time, then no problem, the whole cluster continues to work normally, but if the time is long, B1 will become the master,Z1 of the partition and the data written to B will be lost.
Maximum window (maximum time window) reduces data loss and controls the total number of Z1 writes to B:
After a certain period of time, the majority side of the partition will be elected and the slave becomes master, and the master on the minority side of the partition will refuse to accept write requests.
This amount of time is very important, which is called node expiration time.
After a master reaches its expiration time, it is considered to be faulty. If it enters the error state and stops receiving write requests, it can be replaced by slave.
Redis Cluster does not guarantee strong consistency, and there are scenarios where data is lost:
Asynchronous replication
Before master writes successfully, but before slave synchronization completes, master goes down, slave becomes master, and data is lost.
The wait command can be replicated synchronously, but there is no guarantee that the data will not be lost and will affect performance.
Network partition
The master after the partition continues to receive write requests, and after the partition is restored, the master may become slave, and the previously written data will be lost.
You can set the node expiration time to reduce the number of writes received by master during the partition and reduce the loss of data loss.
About whether Redis Cluster will lose data or not, I hope the above content can be helpful to everyone and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.