弹性学:分裂脑 [英] ELASTICSEARCH: split brain

查看:136
本文介绍了弹性学:分裂脑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们有两个ElasticSearch服务器A和B,都可以成为主控。假设A是主人。假设minimum_master_nodes属性也设置为1。



如果服务器A(主机)因某些原因而崩溃,则B成为主机。当A重新启动并再次运行并加入群集时,将再次加入主站吗?我不明白为什么这个大脑可能会发生。如果B成为主,然后A重新加入群集,为什么A成为主人,如果B成为主人?

解决方案

在任何时候,集群中只有一个主节点。如果A离开或崩溃,B成为主人。当A恢复时,它将简单地作为新的主节点加入集群,并且将等到节点B崩溃才能成为新的主节点。



如果A和B之间的网络短暂地中断,可能会发生分裂的大脑情况。当这种情况发生时,A和B是完全活着的,认为它们在集群中是独一无二的,所以由于A不再看B,A会选择自己作为主人。在这一点上,你的群集中有两个主人,那就是分裂的大脑情况。



为了防止这种情况,你应该有一个奇数的主节点并确保 minimum_master_nodes 设置为2(主符合资格的节点数/ 2 + 1)。在这种情况下,如果至少有两个符合主要条件的节点存在并且可以相互通信以达到法定人数,则只能选择一个新的主人。



运行带有两个主节点的节点的群集正在呼吁出现问题,因为如果设置 minimum_master_nodes:1 ,那么您可能会遇到上述分裂的大脑情况。如果您设置 minimum_master_nodes:2 ,则如果某个节点离开或关闭,则集群将变为红色并且不可操作。这就是为什么你应该总是运行一个奇数(大于一个明显的原因)的主要合格的节点。



这是一篇伟大的文章,有更多关于分裂脑的细节情况: http: //blog.trifork.com/2013/10/24/how-to-avoid-the-split-brain-problem-in-elasticsearch/


Suppose we have two ElasticSearch servers A and B, both can become master. Assume also that A is master. Assume also that the minimum_master_nodes attribute is set to 1 as well.

If server A (the master) crashes for some reason, B becomes master. When A is up and running again, and joins the cluster, will it join again as master? I do not understand why this split brain could occur. If B becomes master, and then A rejoins the cluster, why would A become a master as well if B became the master?

解决方案

At any time, there will only be one single master node in the cluster. If A leaves or crashes, B becomes the master. When A gets back up, it will simply join the cluster as a new master-eligible node and will wait until the node B crashes in order to become the new master.

The split brain situation can occur if the network between A and B breaks for a short moment. When that occurs, A and B are perfectly alive and think they are alone in the cluster, so since A doesn't see B anymore, A will elect itself as the master. At that point, you have two masters in your cluster, that's the split brain situation.

In order to prevent this, you should have an odd number of master-eligible nodes and make sure that minimum_master_nodes is set to 2 (number of master-eligible nodes / 2 + 1). When that's the case, it will only be possible to elect a new master if at least two master-eligible nodes are present and can communicate to each other in order to reach a quorum.

Running a cluster with two master-eligible nodes is calling for troubles, because if you set minimum_master_nodes: 1 you can end up in the split brain situation I described above. If you set minimum_master_nodes: 2, then if one node leaves or goes down, the cluster gets red and non-operational. That's why you should always run an odd number (bigger than one for obvious reasons) of master-eligible nodes.

Here's a great article with many more details on the split brain situation: http://blog.trifork.com/2013/10/24/how-to-avoid-the-split-brain-problem-in-elasticsearch/

这篇关于弹性学:分裂脑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆