2020-10-21

How to install Keepalived: 2 node/3 node

#1/ Node:
Node01: 10.0.2.111
Node02: 10.0.2.112
Node03: 10.0.2.113
V.IP: 10.0.2.110


2/ Config:
#/etc/keepalived/keepalived.conf
#LastUpdate: #18:47 2020.10.21, #18:43 2020.10.21
################################################################
#cat /etc/keepalived/keepalived.conf | egrep "LastUpdate|#10.0.2.11"
################################################################
#RESTART KEEPALIVED:
#START:
#systemctl daemon-reload; sudo systemctl restart keepalived; sleep 5; sudo systemctl status keepalived --no-pager;
#STOP:
#systemctl daemon-reload; sudo systemctl stop keepalived; sudo systemctl status keepalived --no-pager;
#10.0.2.111*
#10.0.2.112
#10.0.2.113
################################################################
#LAN INTERFACE: ens160
#LAN MASTER : 10.0.2.111/24
#LAN BACKUP1: 10.0.2.112/24
#LAN BACKUP2: 10.0.2.113/24
#V.I.P      : 10.0.2.110/32
################################################################
global_defs {
    router_id PSQL_HA
}

#LAN, MASTER: highest ID
vrrp_instance VRRP_LAN_ens160 {
    state MASTER
    interface ens160            # interface to monitor
    virtual_router_id 110       # Assign one ID for this route
    priority 9                  #MASTER, highest ID
    #priority 8                 #BACKUP, lowest ID
    #priority 7                 #BACKUP, lowest ID
    advert_int 1
    smtp_alert
    authentication {
        auth_type PASS
        auth_pass 111173LAN
    }
    virtual_ipaddress {
        10.0.2.110
    }
}
########
#THE_END
########


3/ Restart:
systemctl daemon-reload; sudo systemctl restart keepalived; sleep 5; sudo systemctl status keepalived --no-pager;


4/ Monitor:

root@srv111:~# sudo systemctl status keepalived --no-pager;

● keepalived.service - Keepalive Daemon (LVS and VRRP)
   Loaded: loaded (/lib/systemd/system/keepalived.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-10-21 18:51:07 +07; 5s ago
  Process: 2564 ExecStart=/usr/sbin/keepalived $DAEMON_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 2565 (keepalived)
    Tasks: 3 (limit: 4915)
   CGroup: /system.slice/keepalived.service
           ├─2565 /usr/sbin/keepalived
           ├─2566 /usr/sbin/keepalived
           └─2567 /usr/sbin/keepalived
Oct 21 18:51:07 srv111 Keepalived_healthcheckers[2566]: Opening file '/etc/keepalived/keepalived.conf'.
Oct 21 18:51:07 srv111 Keepalived[2565]: Starting VRRP child process, pid=2567
Oct 21 18:51:07 srv111 Keepalived_vrrp[2567]: Registering Kernel netlink reflector
Oct 21 18:51:07 srv111 Keepalived_vrrp[2567]: Registering Kernel netlink command channel
Oct 21 18:51:07 srv111 Keepalived_vrrp[2567]: Registering gratuitous ARP shared channel
Oct 21 18:51:07 srv111 Keepalived_vrrp[2567]: Opening file '/etc/keepalived/keepalived.conf'.
Oct 21 18:51:07 srv111 Keepalived_vrrp[2567]: Truncating auth_pass to 8 characters
Oct 21 18:51:07 srv111 Keepalived_vrrp[2567]: Using LinkWatch kernel netlink reflector...
Oct 21 18:51:08 srv111 Keepalived_vrrp[2567]: VRRP_Instance(VRRP_LAN_ens160) Transition to MASTER STATE
Oct 21 18:51:09 srv111 Keepalived_vrrp[2567]: VRRP_Instance(VRRP_LAN_ens160) Entering MASTER STATE

No comments:

Post a Comment