KeepAlived Multi Instance

Catatan aja sih..

config keepalived dua instance untuk fail-over dan dibalik state nya..

Master Config :

vrrp_script haproxy {
        script "killall -0 haproxy"
        interval 2
        weight 2
}

vrrp_script sentinel {
        script "/etc/keepalived/scripts/redis_check.sh"
        interval 2
        weight 2
}

vrrp_instance HAP_1 {
        state BACKUP
        interface eth0
        virtual_router_id 11
        priority 100
        advert_int 1
        authentication {
                auth_type PASS
                auth_pass abcdefg # use 8 chars & something better
        }
 virtual_ipaddress {
                10.42.200.210
        }
 track_script {
                haproxy
        }
}

vrrp_instance SNT_1 {
        state MASTER
        interface eth0
        virtual_router_id 21
        priority 101
        advert_int 1
        authentication {
                auth_type PASS
                auth_pass abcdefg # use 8 chars & something better
        }
 virtual_ipaddress {
                10.42.200.211
        }
 track_script {
                sentinel
        }
}


Backup Config :

vrrp_script haproxy {
        script "killall -0 haproxy"
        interval 2
        weight 2
}

vrrp_script sentinel {
        script "/etc/keepalived/scripts/redis_check.sh"
        interval 2
        weight 2
}

vrrp_instance HAP_1 {
        state MASTER
        interface eth0
        virtual_router_id 11
        priority 101
        advert_int 1
        authentication {
                auth_type PASS
                auth_pass abcdefg # use 8 chars & something better
        }
 virtual_ipaddress {
                10.42.200.210
        }
 track_script {
                haproxy
        }
}

vrrp_instance SNT_1 {
        state BACKUP
        interface eth0
        virtual_router_id 21
        priority 100
        advert_int 1
        authentication {
                auth_type PASS
                auth_pass abcdefg # use 8 chars & something better
        }
 virtual_ipaddress {
                10.42.200.211
        }
 track_script {
                sentinel
        }
}

check script redis..
#!/bin/bash
### https://tech.itabas.com/2016/09/29/web/use-keepalived-switching-master-slave-solution/
### /etc/keepalived/scripts/redis_check.sh
###
ALIVE=`redis-cli -p 16379 PING`
if [ "$ALIVE" == "PONG" ]; then
  echo $ALIVE
  exit 0
else
  echo $ALIVE
  exit 1
fi

:: Semoga Bermanfaat ::
Category: , ,
Reaksi: 

0 komentar:

Post a Comment