Ad Widget

Collapse

Zabbix 6.2 HA with keepalived

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tsteel
    Junior Member
    • Jul 2020
    • 4

    #1

    Zabbix 6.2 HA with keepalived

    I built a Zabbix 6.2 HA environment on a RedHat platform which seems to work fine. I setup keepalived so the SA's can connect to the VIP and ensure they are on the active zabbix server.
    The issue is keepalived will always fail back to its master once the VRRP process is back online (in this case httpd) while when zabbix fails over to its standby it stays there.
    So the VIP ends up pointing to the zabbix standy server.
    Anyone have a setup like this?
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    I have not seen need for such setup...

    What are the SA-s?

    Zabbix stores its HAstatus in DB. ha manager process on both sides check that data and if active side has not updated its heartbeat, it will activate passive side...

    You can set you keepalived to check certain things via script and based on that result switch IP-s around..
    "zabbix_server -R ha_status" shows you the active one, you can utilize that in script...

    Comment

    • tsteel
      Junior Member
      • Jul 2020
      • 4

      #3
      Thanks cyber for the ha_status command. I was able to add some hooks to the keepalived config using the command you provided to ensure the VIP always pointed to the active server

      Comment

      • godsyn
        Junior Member
        • Oct 2023
        • 1

        #4
        tsteel Care to share?

        Comment

        • Rah9742
          Junior Member
          • Jan 2025
          • 2

          #5
          I got the following to work as the Keeoalived tracked script, by trying to access the Zabbix-server port via TCP. I could not get Keepalived to correctly execute a script involving "zabbix_server -R ha_status", even though when I ran it through the CLI it all worked.

          Code:
          #!/bin/bash
          
          # Use /dev/tcp to test TCP connection
          timeout 5 bash -c "echo > /dev/tcp/<HOST IP>/10051" 2>/dev/null
          
          # Check the exit code
          if [ $? -eq 0 ]; then
              echo "Port $PORT on $HOSTNAME is reachable (connection successful)."
              exit 0  # Healthy, Keepalived will not trigger failover
          else
              echo "Port $PORT on $HOSTNAME is NOT reachable (connection failed or timed out)."
              exit 1  # Unhealthy, Keepalived will trigger failover
          fi

          Comment

          Working...