双机脑裂(split-brain)解决办法

来源:互联网 发布:网络海外代购发展趋势 编辑:程序博客网 时间:2024/05/21 09:59
一、 What does "split-brain" mean?

"Split brain" is a condition whereby two or more computers or groups of computers lose contact with one another but still act as if the cluster were intact. This is like having two governments trying to rule the same country. If multiple computers are allowed to write to the same file system without knowledge of what the other nodes are doing, it will quickly lead to data corruption and other serious problems.

二、解决办法

        小提一下冗余心跳,但是该方式治标不治本,只能减少脑裂发生的概率。

1、踢出集群

        (1)Quorum Algorithm

        Quorum Algorithm(选举算法):集群内各节点通过心跳收集彼此的健康状况,收集到一个心跳就获得一票,假设集群内3个节点(A、B、C),节点A获得B和自己一票,节点B获得自己和A一票,而节点C只有自己,则节点C被踢出集群。

        (2)Quorum Device

        Quorum Algorithm有个缺陷:集群内如果只有2个节点,那就悲剧了。因此,需要引入第3个设备来解决此问题,此时,Quorum Device粉墨登场。

        Quorum Device(Quorum Disk):这个设备也占一票,这一票由先到请求者获得,这样就能顺利的踢出另一个节点。

2、IO隔离

        做了上面的操作后,很多人就开始稳坐钓鱼台了,实际,悲剧还在深海。节点虽然被踢出,但是仍然有可能处于active状态,这样,这家伙还能操作共享文件资源,危机依然挥之不去。银弹来了,IO隔离(IO Fencing)可以阻止”灰太狼来羊村“。

        IO Fencing主要有两种方式,分别如下:

        (1)硬件方式

                (A)SCSI Reserve/Release设备

                正常节点能够使用SCSI Reserve/Release命令锁住存储设备,不正常节点发现存储设备被锁后,就用suicide(自杀)的方式来了结自己以使自己恢复正常,纯爷们儿。

                (B)STONITH(Shoot The Other Node In The Head)

                当一个节点发生故障时,另一个节点如果检测到了,就会通过串口来控制故障节点的电源开关以暂时断电然后又上电来重启故障节点。手好黑啊,好在还没彻底落井下石。

        (2)软件方式

        ORACLE RAC就是典型代表,直接重启故障节点以保证故障节点不能继续访问共享数据。具体可参考ORACLE,也可以参考这里。

转载于网络!


0 0
原创粉丝点击