Skip to content

The Complete Guide to Keepalived Deployment: VIP Failover, Active-Standby Switching, and Health Check Scripts ​

Keepalived VIP failover diagram

In the previous four chapters, we completed the architecture design, principle learning, health check service development, and Nginx configuration. Now everything is ready; all that is missing is the final component—Keepalived.

This chapter will formally deploy Keepalived, configure VRRP master-backup failover, and make the VIP truly "drift." By the end of this chapter, you will have a complete high-availability entry point: automatic VIP failover + Nginx reverse proxy + health check service.

I. The Role of Keepalived in This Architecture ​

Let's review the complete architecture:

Keepalived assumes two key responsibilities in this architecture:

ResponsibilitiesDescription
VIP ManagementUse the VRRP protocol to maintain VIP ownership among three machines.
FailoverWhen a Master node failure is detected, automatically fail over the VIP to the standby node.

💡 In Part 4, we configured Nginx's Passive inspection(removing the faulty Master service), whereas Keepalived is responsible for VIP drift(Ingress IP switches to the standby machine). Together, the two form a complete fault protection chain.

II. Environment Preparation: Install Keepalived ​

Before starting the configuration, you need to, on the three machines (192.168.0.201,192.168.0.202,192.168.0.203) respectively complete the installation of Keepalived on each.

2.1 Install Keepalived ​

bash
# Update package index
sudo apt update

# Install Keepalived
sudo apt install -y keepalived

# Check the version to confirm the installation was successful.
keepalived -v
# Output: Keepalived v2.2.7 (03/15,2022)

2.2 Verify Keepalived Installation ​

bash
# Check whether Keepalived is installed successfully
which keepalived
# /usr/sbin/keepalived

# View Keepalived version details
keepalived -v

2.3 Confirm the configuration file location ​

bash
# Keepalived's default configuration file path
ls -la /etc/keepalived/
# By default, there is only one keepalived.conf example file (which may be empty).

💡Section objectives: All three machines have completed the Keepalived installation, ready for the subsequent VRRP configuration.

III. Keepalived Basic Configuration ​

3.1 Configuration differences among the three machines ​

As with Nginx, the Keepalived configurations on the three machines are largely the same, with the core difference being:

Configuration Itemnode1(192.168.0.201)node2(192.168.0.202)node3(192.168.0.203)
stateMASTERBACKUPBACKUP
priority1009080
router_idKEEPALIVED_NODE1KEEPALIVED_NODE2KEEPALIVED_NODE3

Create configuration files on the three machines respectively:

bash
sudo vim /etc/keepalived/keepalived.conf
bash
# /etc/keepalived/keepalived.conf

global_defs {
    router_id KEEPALIVED_NODE1      # Node identifier, different for each machine
    script_user root
    enable_script_security
}

vrrp_instance VI_1 {
    state MASTER                    # Initial role: Main
    interface eth0                  # The network interface to listen on (adjust according to actual conditions)
    virtual_router_id 51            # VRID; must be consistent within the same cluster.
    priority 100                    # Priority: primary is higher than backup
    advert_int 1                    # Heartbeat interval: 1 second

    authentication {
        auth_type PASS
        auth_pass 1234              # 简单认证,防止恶意加入
    }

    virtual_ipaddress {
        192.168.0.200/24 dev eth0 label eth0:vip
    }
}
bash
# /etc/keepalived/keepalived.conf

global_defs {
    router_id KEEPALIVED_NODE2
    script_user root
    enable_script_security
}

vrrp_instance VI_1 {
    state BACKUP                    # Initial character: Bei
    interface eth0
    virtual_router_id 51
    priority 90                     # Priority lower than main
    advert_int 1

    authentication {
        auth_type PASS
        auth_pass 1234
    }

    virtual_ipaddress {
        192.168.0.200/24 dev eth0 label eth0:vip
    }
}
bash
# /etc/keepalived/keepalived.conf

global_defs {
    router_id KEEPALIVED_NODE3
    script_user root
    enable_script_security
}

vrrp_instance VI_1 {
    state BACKUP
    interface eth0
    virtual_router_id 51
    priority 80                     # Lowest priority
    advert_int 1

    authentication {
        auth_type PASS
        auth_pass 1234
    }

    virtual_ipaddress {
        192.168.0.200/24 dev eth0 label eth0:vip
    }
}

3.2 Detailed Explanation of Configuration Parameters ​

ParameterExplanationThis configuration value
router_idNode identifier, unique within the clusterKEEPALIVED_NODE1/2/3
stateInitial character,MASTER or BACKUPMaster:MASTER, Note:BACKUP
interfaceThe monitored NIC, the interface for sending VRRP heartbeatseth0(Adjust according to the actual network card)
virtual_router_idVirtual router ID (1-255), must be consistent within the same cluster51
priorityPriority (1-255), the higher the value, the more likely it is to become Master.Master:100, Note:90/80
advert_intHeartbeat announcement interval (seconds)1
auth_passAuthentication password must be consistent within the same cluster.1234
virtual_ipaddressVirtual IP address and network interface alias192.168.0.200/24 dev eth0 label eth0:vip

3.3 Check the network adapter name ​

In configuration interface Beforehand, first confirm the actual name of the machine's network card:

bash
# View network interface names
ip addr show

# or
ip link show

# Common NIC names:
# - eth0 (traditional naming)
# - ens3, ens4 (virtualized environment)
# - enp0s3, enp0s8 (VirtualBox)
# - eno1, eno2 (physical machine)

If the network adapter name is not eth0, need to take the [item] in the configuration interface eth0 and dev eth0 Replace with the actual network interface name.

4. Start Keepalived ​

4.1 Starting the Service ​

Execute the following separately on the three machines:

bash
# Start Keepalived
sudo systemctl start keepalived

# Check service status
sudo systemctl status keepalived

# Set to start on boot
sudo systemctl enable keepalived

4.2 Verify whether the VIP has been allocated ​

at Master node (192.168.0.201) View on:

bash
# Check whether the VIP is bound
ip addr show eth0 | grep 192.168.0.200

# Expected output:
# inet 192.168.0.200/24 scope global eth0:vip

at Backup node (192.168.0.202) View on:

bash
ip addr show eth0 | grep 192.168.0.200

# Expected output: empty (VIP is not on the standby node)

4.3 Verify VIP Accessibility ​

bash
# Ping the VIP from any machine
ping -c 3 192.168.0.200

# Expected: ping succeeds

# Access the health check service via VIP
curl http://192.168.0.200/health | jq .

# Expected: return node1's service information

✅At this point, VIP can already be accessed normally. Client access 192.168.0.200 and you can reach node1.

V. Integrate Health Check Script ​

In a production environment, we not only want Keepalived to detect whether the machine is alive, but also to detect Nginx and Master Service Whether it is working properly. If the Nginx or Master service goes down, Keepalived should proactively lower the priority of the current node so that the VIP drifts to other healthy nodes.

5.1 Create a health check script ​

Create the same script on three machines:

bash
# 1. Check Master service
cat > /usr/local/bin/check_master.sh << 'EOF'
#!/bin/bash
# Check whether the Master service is healthy.

MASTER_HEALTH_URL="http://127.0.0.1:8080/health"

if curl -f -s -o /dev/null -w "%{http_code}" "$MASTER_HEALTH_URL" | grep -q "200"; then
    exit 0
else
    exit 1
fi
EOF

# 2. 检查 Nginx 是否存活
cat > /usr/local/bin/check_nginx.sh << 'EOF'
#!/bin/bash
# Check whether the Nginx process is running

if pgrep -x "nginx" > /dev/null; then
    exit 0
else
    exit 1
fi
EOF

# 3. Add execute permission
chmod +x /usr/local/bin/check_master.sh
chmod +x /usr/local/bin/check_nginx.sh

5.2 Update Keepalived Configuration ​

Update on three machines /etc/keepalived/keepalived.conf, Add a health check script:

bash
sudo vim /etc/keepalived/keepalived.conf

The complete configuration is as follows (the differences among the three machines are only in state,priority,router_id):

nginx
# /etc/keepalived/keepalived.conf (taking node1 as an example)

global_defs {
    router_id KEEPALIVED_NODE1
    script_user root
    enable_script_security
}

# Health check script definition
vrrp_script check_master { 
    script "/usr/local/bin/check_master.sh"
    interval 3          # Check every 3 seconds 
    weight -30          # When the check fails, decrease priority by 20 
    fall 2              # Two consecutive failures are determined as failure 
    rise 2              # Judged as recovery after 2 consecutive successes 
} 
vrrp_script check_nginx { 
    script "/usr/local/bin/check_nginx.sh"
    interval 2
    weight -30 
    fall 2
    rise 2
} 

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 100
    advert_int 1

    authentication {
        auth_type PASS
        auth_pass 1234
    }

    virtual_ipaddress {
        192.168.0.200/24 dev eth0 label eth0:vip
    }

    # Associate health check script
    track_script { 
        check_master 
        check_nginx 
    } 
}

5.3 Detailed Explanation of Script Parameters ​

ParameterEffectThis configuration value
intervalCheck interval (seconds)2 or 3
weightThe value by which the priority is reduced when the check fails-30
fallAfter how many consecutive failures is it judged as a failure?2
riseAfter how many consecutive successes is it judged as recovered?2

Working principle:

  • Under normal circumstances, the priority of the Master node is 100

  • If the Master service goes down (check_master failed), priority lowered to 70(100 - 30)

  • If Nginx also went down (check_nginx failed), priority lowered to 70(100 - 30)

  • If both scripts fail at the same time, the priority is reduced to 40(100 - 30 - 30)

  • When the priority is lower than that of the Backup node (90), the VIP automatically drifts.

⚠️Why weight use -30 rather than -20 or -10?

Because node1's priority is 100, node2 is 90. To make node1's priority clearly lower than node2, at least needs to be reduced to 89 The following:

  • weight -10: drop to 90, at the same level as node2,Will not trigger switching

  • weight -20: drop to 80, clearly lower than 90,Can trigger switching

  • weight -30: drop to 70,safer, even if both scripts fail at the same time, it is low enough

We found in actual verification that -10 will not trigger a switch, so use it uniformly -30 Ensure reliability.

5.4 Reload Configuration ​

bash
# Test configuration syntax
sudo keepalived -t -f /etc/keepalived/keepalived.conf

# Reload configuration
sudo systemctl reload keepalived

# Check service status
sudo systemctl status keepalived

6. Verify VIP Drift ​

This is the most exciting part—simulating a fault and letting the VIP truly float.

Before starting, first open a terminal window to monitor the Keepalived logs in real time:

bash
sudo journalctl -u keepalived -f

Then open another terminal to execute the fault simulation command.

6.1 Confirm the current Master ​

Before starting the fault simulation, first confirm which node the VIP is currently on:

bash
ip addr show eth0 | grep 192.168.0.200
# Expected: inet 192.168.0.200/24 scope global eth0:vip
bash
ip addr show eth0 | grep 192.168.0.200
# Expected: (empty)

As can be seen, VIP is currently at node1 Up.

6.2 Scenario 1: Master Service Failure ​

Operation steps:

At node1 Stop the gateway service on [the host] to simulate a business service failure:

bash
# Execute on node1
sudo systemctl stop gateway

Log output:

In the log terminal, you will see the following output:

Jun 21 15:01:47 node1 Keepalived_vrrp[937]: Script `check_master` now returning 1
Jun 21 15:01:50 node1 Keepalived_vrrp[937]: VRRP_Script(check_master) failed (exited with status 1)
Jun 21 15:01:50 node1 Keepalived_vrrp[937]: (VI_1) Changing effective priority from 100 to 70
Jun 21 15:01:53 node1 Keepalived_vrrp[937]: (VI_1) Master received advert from 192.168.0.202 with higher priority 90, ours 70
Jun 21 15:01:53 node1 Keepalived_vrrp[937]: (VI_1) Entering BACKUP STATE

Log interpretation:

TimeLog contentmeaning
15:01:47Script check_master now returning 1The health check script detected an abnormality in the gateway service.
15:01:50VRRP_Script(check_master) failedFailed 2 consecutive times; confirm script failure.
15:01:50Changing effective priority from 100 to 70node1 priority drops from 100 to 70
15:01:53received advert from 192.168.0.202 with higher priority 90node1 received an advertisement from node2 with priority 90, which is higher than its own.
15:01:53Entering BACKUP STATEnode1 voluntarily relinquishes the Master role

Verify drift results:

bash
# Check on node2.
ip addr show eth0 | grep 192.168.0.200
# Expected: inet 192.168.0.200/24 scope global eth0:vip
bash
# Reachable via VIP verification service
curl -s http://192.168.0.200/health | jq .hostname
# Expected: "node2"

Recovery and switchback:

bash
# Restore the service on node1
sudo systemctl start gateway

You will see in the log:

Jun 21 15:04:44 node1 Keepalived_vrrp[937]: Script `check_master` now returning 0
Jun 21 15:04:47 node1 Keepalived_vrrp[937]: VRRP_Script(check_master) succeeded
Jun 21 15:04:47 node1 Keepalived_vrrp[937]: (VI_1) Changing effective priority from 70 to 100
Jun 21 15:04:47 node1 Keepalived_vrrp[937]: (VI_1) received lower priority (90) advert from 192.168.0.202 - discarding
Jun 21 15:04:48 node1 Keepalived_vrrp[937]: (VI_1) received lower priority (90) advert from 192.168.0.202 - discarding
Jun 21 15:04:49 node1 Keepalived_vrrp[937]: (VI_1) received lower priority (90) advert from 192.168.0.202 - discarding
Jun 21 15:04:50 node1 Keepalived_vrrp[937]: (VI_1) Entering MASTER STATE

About 3-6 seconds after recovery, the VIP returns to node1.

6.3 Scenario 2: Nginx Failure ​

Operating steps:

At node1 Upon stopping the Nginx service, simulate a proxy layer failure:

bash
# Execute on node1
sudo systemctl stop nginx

Log output:

Jun 21 14:54:52 node1 Keepalived_vrrp[1022]: Script `check_nginx` now returning 1
Jun 21 14:54:54 node1 Keepalived_vrrp[1022]: VRRP_Script(check_nginx) failed (exited with status 1)
Jun 21 14:54:54 node1 Keepalived_vrrp[1022]: (VI_1) Changing effective priority from 100 to 70
Jun 21 14:54:57 node1 Keepalived_vrrp[1022]: (VI_1) Master received advert from 192.168.0.202 with higher priority 90, ours 70
Jun 21 14:54:57 node1 Keepalived_vrrp[1022]: (VI_1) Entering BACKUP STATE

Log interpretation:

timeLog contentMeaning
14:54:52Script check_nginx now returning 1The health check script detected an Nginx anomaly.
14:54:54VRRP_Script(check_nginx) failedFailed 2 times consecutively; confirm script failure.
14:54:54Changing effective priority from 100 to 70node1 priority decreased from 100 to 70
14:54:57received advert from 192.168.0.202 with higher priority 90node2 priority 90 is higher than the current 70, triggering a switchover
14:54:57Entering BACKUP STATEnode1 relinquishes the Master role

Verify drift results:

bash
# Check on node2.
ip addr show eth0 | grep 192.168.0.200
# Expected: inet 192.168.0.200/24 scope global eth0:vip

Recovery and failback:

bash
# Restore Nginx on node1
sudo systemctl start nginx
# VIP will automatically return to node1

You will see the following in the log:

Jun 21 14:55:46 node1 Keepalived_vrrp[1022]: Script `check_nginx` now returning 0
Jun 21 14:55:48 node1 Keepalived_vrrp[1022]: VRRP_Script(check_nginx) succeeded
Jun 21 14:55:48 node1 Keepalived_vrrp[1022]: (VI_1) Changing effective priority from 70 to 100
Jun 21 14:55:48 node1 Keepalived_vrrp[1022]: (VI_1) received lower priority (90) advert from 192.168.0.202 - discarding
Jun 21 14:55:49 node1 Keepalived_vrrp[1022]: (VI_1) received lower priority (90) advert from 192.168.0.202 - discarding
Jun 21 14:55:50 node1 Keepalived_vrrp[1022]: (VI_1) received lower priority (90) advert from 192.168.0.202 - discarding
Jun 21 14:55:51 node1 Keepalived_vrrp[1022]: (VI_1) Entering MASTER STATE

6.4 Scenario 3: Complete machine downtime ​

操作步骤:

at node1 Execute shutdown on [the device] to simulate a complete machine failure:

bash
# Execute on node1 (testing only!)
sudo shutdown -h now

⚠️Note: Before shutting down, please ensure that no other important services are running on node1.

Expected results:

After node1 is shut down, the Keepalived heartbeat is interrupted, and node2 takes over the VIP after about 3–6 seconds.

Verify drift results:

bash
# Check on node2.
ip addr show eth0 | grep 192.168.0.200
# Expected: inet 192.168.0.200/24 scope global eth0:vip

6.5 Summary of Verification Conclusions ​

Failure scenarioTrigger commandLog keywordsVIP Drift TargetRecovery time
Master service failuresystemctl stop gatewaycheck_master failed→Changing priority 100→70→ " Hmm The message ends with " → " maybe arrow? Need determine if there is text to translate. It appears after instructions there is a space then arrow symbol? Actually user content: "You are an expert technical translator. Translate the following text into en. IMPORTANT: Translate ALL Chinese characters to English. If the text contains Chinese, you MUST translate it. If the text is already in en, output it EXACTLY as it is. Output ONLY the translated text, no quotes, no explanations.

→ " Wait there is an arrow " → " at end. Could be text to translate is arrow? Or placeholder? The "following text" might be empty. We need output ONLY translated text. If no text, output nothing? But maybe they expect translate "→" to English? Arrow isn't Chinese; already en? It's symbol. If text is "→", output exactly as it is because already not Chinese? Hmm.

Need parse: The user message includes at the very end: " → " likely an arrow character. They might be asking translate the following text into en, but following text is " → "? Actually there is a blank line then " → ". That could be the text to translate: an arrow with spaces. It contains no Chinese. If text already in en, output EXACTLY as it is. So output " → "? But output only translated text, no quotes. Need preserve spaces? Could output arrow. However the arrow isn't English but symbol. The instruction says if text contains Chinese, translate; if already in en, output exactly. The text to translate is maybe "→" which is not English. But no Chinese. Should output exactly "→" maybe with leading space? Need not include explanations. The final answer should be just arrow? Let's consider.

The system says expert technical translator. The user message includes instructions and then " → " after newline. It might be an accidental artifact? We need respond with translated text. Since there's no Chinese, maybe output the same. The safest is output "→" exactly? But if include leading space? The source had " → " with leading space and maybe trailing? In message: "no explanations. → " There is newline then space arrow? Actually "Output ONLY the translated text, no quotes, no explanations. → " It shows " → " after newline. That is likely text to translate, an arrow. Output only translated text. If text is already en, output exactly as it is. But arrow not en. Could output "→". No quotes. Need final only. Use no explanation.

Need decide whether to output empty or arrow. Since final answer must contain something. I'll output the arrow symbol, maybe with a leading space? The instruction says output only translated text, no quotes. I can output "→". If exact as it is, include leading space? Probably not important. But "Output ONLY the translated text" - if text is arrow, output arrow. Final: →. Ensure no quotes.→Entering BACKUP | node2 | ~3-6 seconds | | Nginx failure | systemctl stop nginx | check_nginx failed→Changing priority 100→70→Entering BACKUP | node2 | ~3-6 seconds | | Whole-machine downtime | shutdown -h now | (Heartbeat interrupted) | node2 | ~3-6 seconds | | Service Restored | systemctl start gateway | check_master succeeded→

? Wait there is something: "Translate the following text into en. ... Output ONLY the translated text... [then] → " There's an arrow at end. Maybe the text to translate is empty? They wrote " → " after instructions. Could be the following text is " → "? They want translate to en; arrow isn't English or Chinese, already symbol. Output exactly " → "? Need parse.

The user message content: "You are an expert technical translator. Translate the following text into en. IMPORTANT: Translate ALL Chinese characters to English. If the text contains Chinese, you MUST translate it. If the text is already in en, output it EXACTLY as it is. Output ONLY the translated text, no quotes, no explanations. → "

There is an arrow separated by space. It might be the text to translate is "→" (arrow). Since no Chinese, and already symbol. Output ONLY translated text. Should output "→" perhaps without extra spaces? The instruction says if already en output exactly as is. It's not en but symbol. "Translated text" for arrow is arrow. Need output exactly? likely "→". We must not explain. Final only.→Changing priority 70→100→Entering MASTER | node1 | ~10-15 seconds |

✅At this point, we have a complete high-availability entry point:

  • Ingress High Availability: VIP 192.168.0.200 Auto Drift

  • Proxy high availability: Nginx multi-node + passive checks

  • Business high availability: multi-node Master service + health check

VII. Common O&M Commands ​

7.1 View Keepalived logs ​

bash
# View Keepalived logs in real time
sudo journalctl -u keepalived -f

# View the last 50 lines of logs
sudo journalctl -u keepalived -n 50

# Check the Keepalived records in the system log
sudo tail -f /var/log/syslog | grep keepalived

During failover, you will see similar information in the logs:

# Master node logs:
Keepalived_vrrp[12345]: VRRP_Instance(VI_1) Received lower prio advert, forcing new election

# Backup node logs:
Keepalived_vrrp[12345]: VRRP_Instance(VI_1) Transition to MASTER STATE
Keepalived_vrrp[12345]: VRRP_Instance(VI_1) Entering MASTER STATE
Keepalived_vrrp[12345]: VRRP_Instance(VI_1) setting VIP 192.168.0.200

7.2 View VIP Attribution ​

bash
# Check which machine the VIP is currently on
ip addr show eth0 | grep 192.168.0.200

# Or use a more detailed command
ip addr show label eth0:vip

7.3 Check Keepalived Process Status ​

bash
# Check the Keepalived process
ps aux | grep keepalived

# View the Keepalived main process PID
sudo cat /var/run/keepalived.pid

7.4 Manually Trigger VIP Switchover ​

bash
# Demote the current Master to Backup (for testing)
sudo systemctl stop keepalived

# Check whether other nodes have taken over the VIP
# After restarting Keepalived, it will preempt again (if the priority is higher).
sudo systemctl start keepalived

VIII. Common Problems and Solutions ​

Q1: After starting Keepalived, the VIP does not appear? ​

Possible reasons:

  • The network adapter name is incorrect.

  • Configuration file syntax error

  • of the three machines virtual_router_id or auth_pass inconsistent

Solution:

bash
# 1. View Keepalived logs
sudo journalctl -u keepalived -f

# 2. Check the network card name
ip addr show

# 3. Test configuration file syntax
sudo keepalived -t -f /etc/keepalived/keepalived.conf

# 4. Check whether the firewall allows VRRP multicast
sudo iptables -L -n | grep 224.0.0.18

Q2: Frequent VIP drift (jitter)? ​

Possible reasons:

  • Network unstable, heartbeat packet loss

  • The health check script runs too frequently or is too heavyweight.

  • of the three machines advert_int inconsistent

Solution:

  • Ensure the three machines'advert_int Consistent

  • Appropriately increase fall and rise value of (e.g.fall 3,rise 3)

  • Check whether the network is stable

Q3: Health check script did not take effect? ​

Possible reasons:

  • track_script Block missing or misplaced

  • The script does not have execute permission.

  • script_user Not configured

Solution:

First, confirm whether there are any warnings in the log:

bash
sudo journalctl -u keepalived | grep "not used"

If you see Warning - script check_master is not used, explanation track_script Not configured correctly.

Ensure the configuration structure is correct:

bash
# ✅ Correct: track_script is inside the vrrp_instance block
vrrp_instance VI_1 {
    state MASTER
    # ... Other configuration ...

    track_script {
        check_master
        check_nginx
    }
}

# ❌ Error: track_script is outside the vrrp_instance block
track_script {
    check_master
}

Check script permissions:

bash
sudo chmod +x /usr/local/bin/check_master.sh
sudo chmod +x /usr/local/bin/check_nginx.sh

Q4:weight What setting is appropriate? ​

weight The core principle is:Any single failure is enough to make the Master's priority clearly lower than all Backup nodes.

nodepriorityrequired weightDescription
node1100> 10100 - weight < 90 → weight > 10
node290--
node380--

Recommended configuration: Use -30, leaving sufficient margin so that normal switchover can still occur even if both scripts fail at the same time.

Q5: What should I do if the network interface names on the three machines are different? ​

Usually, on servers in the same batch, the network interface names are the same. If they are inconsistent, adjustments need to be made individually for each machine.interface and dev Parameters.

bash
# Confirm the network interface name separately on each machine.
ip addr show

# Then modify the interface and dev in the configuration file respectively.
interface eth0
virtual_ipaddress {
    192.168.0.200/24 dev eth0 label eth0:vip
}

IX. Summary ​

This chapter completes the deployment of Keepalived and VIP failover configuration. Key points:

  • Environment Preparation: Install Keepalived on three machines

  • Basic configuration:state+priority+virtual_ipaddress

  • Health check script: Check whether the Master service and Nginx are alive

  • Script integration: through track_script Associated health check

  • Fault verification: Three scenarios to verify VIP automatic drift

So far, we have fully built a production-grade high-availability entry point:

Product A → VIP (192.168.0.200) → Keepalived-managed drift → Nginx reverse proxy → Master cluster

In the next chapter, we will conduct a complete walkthrough of four major failure scenarios and provide an automated validation script.

💡 This article is Part 5 of the Distributed High-Availability Ingress Architecture in Practice Series.

最后更新2026/11/07 14:16
如果你觉得这篇文章有帮助,或者想聊聊技术、工作,欢迎通过下面方式联系我:
contact fishfinal