Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to prevent brain fissure in keepalived

Shulou Source: shulou.com Published: 2022-06-01 03:19:03 09月14日 Update

How to prevent keepalived brain fissure problem, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.

(1) third-party arbitration can be adopted. Because the state of the main and standby machines in the keepalived system is related to each other. If there is a network problem in the communication between the active and standby machines, there will be a brain fissure, and there will be a dual-master situation in the keepalived system, resulting in resource competition.

(2) generally, arbitration can be introduced to solve this problem, that is, each node must judge its own state. The simplest method of operation is to add the check configuration to the configuration file of the active and standby keepalived, and the server periodically ping the gateway. If the ping is not available, it thinks there is a problem with it.

(3) the easiest way is to implement it with vrrp_script and track_script provided by keepalived. As follows:

# vim / etc/keepalived/keepalived.conf

.

Vrrp_script check_local {

Script "/ root/check_gateway.sh"

Interval 5

}

.

Track_script {

Check_local

}

Content of the script:

# cat / root/check_gateway.sh

#! / bin/sh

VIP=$1

GATEWAY=192.168.1.1

/ sbin/arping-I em1-c 5-s $VIP $GATEWAY & > / dev/null

Check_gateway.sh is our arbitration logic. If we find that ping is not connected to the gateway, we will shut down keepalived.

(4) Detection idea: normally, the VIP address of keepalived is on the master node, and if the VIP is found in the slave node, the alarm message will be set. The script (on the slave node) is as follows:

Vim split-brainc_check.sh

#! / bin/bash

# check the script for brain fissure and deploy it on the standby node

LB01_VIP=192.168.1.229

LB01_IP=192.168.1.129

LB02_IP=192.168.1.130

While true

Do

Ping-c 2-W 3 $LB01_VIP & > / dev/null

If [$?-eq 0-a `ip add | grep "$LB01_VIP" | wc-l`-eq 1]; then

Echo "ha is brain."

Else

Echo "ha is ok"

Fi

Sleep 5

Done

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Tags: Nodes questions scripts arbitrations systems content situations methods machines states gateways help configuration clarity between messages cycles periodicity addresses each other Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Information Redmi Apple MariaDB