Keepalived : Monitor processes2024/07/23 |
Monitoring processes with Keepalived. This example is based on the environment like follows. VIP:10.0.0.30 +----------------------+ | +----------------------+ | [node01.srv.world] |10.0.0.51 | 10.0.0.52| [node02.srv.world] | | Keepalived#1 +----------+----------+ Keepalived#2 | | | | | +----------------------+ +----------------------+ |
[1] | |
[2] | For example, in addition to basic Keepalived settings, add settings to monitor sshd process. |
root@node01:~#
vi /etc/keepalived/keepalived.conf global_defs { router_id node01 notification_email { root@localhost } notification_email_from root@node01.srv.world smtp_server localhost smtp_connect_timeout 30 } # add monitoring setting for sshd process vrrp_track_process track_sshd { process sshd delay 1 } vrrp_instance VRRP1 { state MASTER # nopreempt interface enp1s0 virtual_router_id 101 priority 200 advert_int 1 virtual_ipaddress { 10.0.0.30/24 } # add track_process { track_sshd } smtp_alert }root@node01:~# systemctl restart keepalived
|
[3] | That's OK. Verify failover and failback when sshd would be down. |
# primary node root@node01:~# ip address show enp1s0 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 52:54:00:1e:27:13 brd ff:ff:ff:ff:ff:ff inet 10.0.0.51/24 brd 10.0.0.255 scope global enp1s0 valid_lft forever preferred_lft forever inet 10.0.0.30/24 scope global secondary enp1s0 valid_lft forever preferred_lft forever inet6 fe80::5054:ff:fe1e:2713/64 scope link valid_lft forever preferred_lft foreverroot@node01:~# systemctl stop ssh root@node01:~# ip address show enp1s0 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 52:54:00:1e:27:13 brd ff:ff:ff:ff:ff:ff inet 10.0.0.51/24 brd 10.0.0.255 scope global enp1s0 valid_lft forever preferred_lft forever inet6 fe80::5054:ff:fe1e:2713/64 scope link valid_lft forever preferred_lft foreverroot@node01:~# ssh ubuntu@node02 "ip address show enp1s0" ubuntu@node02's password: 2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 52:54:00:4c:63:11 brd ff:ff:ff:ff:ff:ff inet 10.0.0.52/24 brd 10.0.0.255 scope global enp1s0 valid_lft forever preferred_lft forever inet 10.0.0.30/24 scope global secondary enp1s0 valid_lft forever preferred_lft forever inet6 fe80::5054:ff:fe4c:6311/64 scope link valid_lft forever preferred_lft forever |
Sponsored Link |