Docu review done: Wed 31 Jul 2024 02:34:40 PM CEST

keepalived

Table of Content

Template

  • peempt_delay: this means that the server will not be master after a reboot for the defined time (sec)
  • grap_master_delay: this speeds up the fail over and raises or lowes the ping time (default 5)
  • track_script: track script influences the priority, if the checked is success full it returns the wight which summs up on the prio

so than the real prio is prio+weigth.

e.g.:

  • Node1 has priority 101, application runs with weight 2, means Node1 has real priority 103
  • Node2 has priority 100, application runs with weight 2, means Node2 has real priority 102.
  • Node 1 will be master. If the application will be disabled on Node1 (priority lowers because of weight 2 to 101)
  • Node 2 will become the new one. If now the application will be disbaled on Node2, Node1 will be the master again
global_defs {
    router_id <hostname>
}

vrrp_script chk_<application> {
    script "killall -0 <application>"  # cheaper than pidof
    interval 2                 # check every 2 seconds
    weight 2                 # add 2 points of prio if OK
}

# instance for LVSlan to use as gateway
vrrp_instance <Internal keepalived interface name> {
    interface <NIC>
    state <BACKUP/MASTER - if nopreemtp than only BACKUP>
    nopreempt
    virtual_router_id <INT virtual router id>
    priority <PRIO-INT value>
    advert_int 1
    peempt_delay 300
    garp_master_delay 1
    track_script {
        chk_<application>
    }

    authentication {
        auth_type PASS
        auth_pass <PWD - length 8>
    }
    virtual_ipaddress {
        <VIP>
    }
}

Sample configs master template

global_defs {
    router_id <hostname>
    notification_email {
        <destination@mail.com>
    }
    notification_email_from <keepalived@localdomainofserver.com>
    smtp_server localhost
    smtp_connect_timeout 30
    lvs_id LVS01
}

vrrp_script chk_<application> {
    script "killall -0 <application>"  # cheaper than pidof
    interval 2                 # check every 2 seconds
    weight 2                 # add 2 points of prio if OK
}

# instance for LVSlan to use as gateway
vrrp_instance <Internal keepalived interface name> {
    interface <NIC>
    lvs_sync_daemon_interface <NIC>
    state MASTER
    virtual_router_id <INT virtual router>
    priority <PRIO-INT vlaue>
    advert_int 1
    smtp_alert
    peempt_delay 300
    garp_master_delay 1
    track_script {
        chk_<application>
    }

    authentication {
        auth_type PASS
        auth_pass <PWD - length 8>
    }
    virtual_ipaddress {
        <VIM>
    }
}

Sample configs slave template

global_defs {
    router_id <hostname>
    notification_email {
        <destination@mail.com>
    }
    notification_email_from <keepalived@localdomainofserver.com>
    smtp_server localhost
    smtp_connect_timeout 30
    lvs_id LVS01
}

vrrp_script chk_<application> {
    script "killall -0 <application>"  # cheaper than pidof
    interval 2                 # check every 2 seconds
    weight 2                 # add 2 points of prio if OK
}

# instance for LVSlan to use as gateway
vrrp_instance <Internal keepalived interface name> {
    interface <NIC>
    lvs_sync_daemon_interface <NIC>
    state BACKUP
    virtual_router_id <INT virtual router>
    priority <PRIO-INT vlaue>
    advert_int 1
    smtp_alert
    peempt_delay 300
    garp_master_delay 1
    track_script {
        chk_<application>
    }

    authentication {
        auth_type PASS
        auth_pass <PWD - length 8>
    }
    virtual_ipaddress {
        <VIM>
    }
}