Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the methods of MongoDBReplicaSets configuration and what are the problems in the configuration process?

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Today, I will talk to you about the methods of MongoDBReplicaSets configuration and what are the problems in the configuration process. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

We know that MongoDB does not provide stand-alone data security, but instead provides a highly available solution for ReplicaSets. The case mentioned in the official document is a three-node ReplicaSets, so that a new Primary is automatically selected to provide write operations after any one of the nodes goes down. The following editor will explain the methods of MongoDBReplicaSets configuration? what are the problems with MongoDBReplicaSets configuration?

What are the methods of MongoDBReplicaSets configuration

Configuration method

The ReplicaSets of two nodes, one election becomes Primary and the other becomes Secondary.

What are the problems with MongoDBReplicaSets configuration

problem

What happens to Primary if Secondary goes down at this time? Primary will immediately become Secondary! There is no Primary in the cluster at this time! Why did this happen?

Reason

This is related to MongoDB's Primary election strategy. Imagine that if the situation is not Secondary downtime, but network disconnection, then both nodes will choose themselves as Primary, because they can connect to only one node. In this case, complex consistency problems need to be dealt with after the network is restored. And the longer the disconnection, the more complex the time. So the strategy chosen by MongoDB is that if there is only one node in the cluster, then do not select yourself as Primary.

Solution method

So the right thing to do is to add more than two nodes, or add arbiter. Of course, the best and most convenient way is to add arbiter,aribiter nodes only to participate in the election, so there will be almost no pressure, so you can start arbiter nodes on various idle machines, which will not only avoid the situation mentioned above that Primary cannot be elected, but also make the selection proceed more quickly. (because if there are three data nodes and one node is down, the other two nodes are likely to elect themselves as Primary, which takes a long time to get the election results.)

After reading the above, do you have any further understanding of the methods of MongoDBReplicaSets configuration and what are the problems in the configuration process? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report