We'll be working on the Servers that are surrounded by the continous lines in this drawing:
Keepalived is a useful tool to share a single Virtual IP (VIP) between multiple nodes without dealing with pacemaker, corosync and fencing. Keepalived is also fairly lightweight and easy to configure, so a good fit four this setup.
Start by installing keepalived:
[archy@helper01 ~]$ sudo dnf -4y --refresh install keepalived
[archy@helper02 ~]$ sudo dnf -4y --refresh install keepalived
After the packages are done installing, configure keepalived on the first helper node:
[archy@helper01 ~]$ sudo vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
admins@archyslife.lab
}
notification_email_from root@helper01.okd.archyslife.lab
smtp_server 127.0.0.1
smtp_connect_timeout 30
script_user root root
}
vrrp_script chk_haproxy {
script '/usr/bin/pidof haproxy'
interval 2
}
vrrp_instance VI_1 {
state MASTER
interface enp1s0
priority 100
virtual_router_id 51
unicast_src_ip 172.31.10.173
unicast_peer {
}
authentication {
auth_type PASS
auth_pass 8-character-secret-here
}
track_script {
chk_haproxy
}
virtual_ipaddress {
172.31.10.240
}
}
Restart keepalived on the first node to check if the keepalived configuration works as expected. If the check returns with rc 0, the node will be considered eligible for the virtual ip address (172.31.10.240)
[archy@helper01 ~]$ sudo systemctl enable --now keepalived.service
Check for IP Addresses:
[archy@helper01 ~]$ ip -s -c -h -4 addr show enp1s0
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
inet 172.31.10.173/24 brd 172.31.10.255 scope global dynamic noprefixroute enp1s0
valid_lft 223503sec preferred_lft 223503sec
inet 172.31.10.240/32 scope global enp1s0
valid_lft forever preferred_lft forever
RX: bytes packets errors dropped missed mcast
33.5G 44.9M 0 1 0 0
TX: bytes packets errors dropped carrier collsns
33.4G 44.5M 0 0 0 0
Okay, so the IP has been successfully assigned. The Configuration is correct and we can configure the next helper node.Keepalived has already been installed in a previous step so we'll start with the configuration here:
[archy@helper02 ~]$ sudo vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
admins@archyslife.lab
}
notification_email_from root@helper02.okd.archyslife.lab
smtp_server 127.0.0.1
smtp_connect_timeout 30
script_user root root
}
vrrp_script chk_haproxy {
script '/usr/bin/pidof haproxy'
interval 2
}
vrrp_instance VI_1 {
state BACKUP
interface enp1s0
priority 100
virtual_router_id 51
unicast_src_ip 172.31.10.178
unicast_peer {
}
authentication {
auth_type PASS
auth_pass 8-character-secret-here
}
track_script {
chk_haproxy
}
virtual_ipaddress {
172.31.10.240
}
}
Restart and enable keepalived.service to ensure it starts at next boot and the configuration is correct:
[archy@helper02 ~]$ sudo systemctl enable --now keepalived.service
For additional information, the logs of keepalived can be checked using 'journalctl -b -u keepalived.service'. However, this should be all there is to set up for keepalived in that scenario.
Feel free to comment and / or suggest a topic.
Comments
Post a Comment