Friday, February 7, 2025

.::: Install & Configuration Virtual IP Using Keepalived :::.

 

1. Install keepalived
yum install keepalived -y

[root@teguhth01 ~]# yum install keepalived -y

[root@teguhth02 ~]# yum install keepalived -y

[root@teguhth01 ~]# systemctl enable keepalived
Created symlink from /etc/systemd/system/multi-user.target.wants/keepalived.service to /usr/lib/systemd/system/keepalived.service.
[root@teguhth01 ~]# systemctl start keepalived
[root@teguhth01 ~]#


2. Configure as

[root@ha01 ~]# cat /etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
    state MASTER  # or BACKUP on the backup node
    interface ens33  # the network interface to be used
    virtual_router_id 51  # a unique ID for this VRRP instance
    priority 100  # higher value means higher priority (for MASTER), lower for BACKUP
    advert_int 1  # advertisement interval in seconds
    authentication {
        auth_type PASS
        auth_pass YourSecretPassword
    }
    virtual_ipaddress {
        10.10.10.110  # the virtual IP address to be used
    }
}

[root@ha01 ~]#


3. restart keepalived

systemctl restart keepalived

[root@ha01 ~]# systemctl restart keepalived
[root@ha01 ~]#
[root@ha01 ~]# systemctl status keepalived
● keepalived.service - LVS and VRRP High Availability Monitor
   Loaded: loaded (/usr/lib/systemd/system/keepalived.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2025-02-07 13:47:51 WIB; 7s ago
  Process: 6205 ExecStart=/usr/sbin/keepalived $KEEPALIVED_OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 6206 (keepalived)
   CGroup: /system.slice/keepalived.service
           ├─6206 /usr/sbin/keepalived -D
           ├─6207 /usr/sbin/keepalived -D
           └─6208 /usr/sbin/keepalived -D

Feb 07 13:47:53 ha01 Keepalived_vrrp[6208]: Sending gratuitous ARP on ens33 for 10.10.10.110
Feb 07 13:47:53 ha01 Keepalived_vrrp[6208]: Sending gratuitous ARP on ens33 for 10.10.10.110
Feb 07 13:47:53 ha01 Keepalived_vrrp[6208]: Sending gratuitous ARP on ens33 for 10.10.10.110
Feb 07 13:47:53 ha01 Keepalived_vrrp[6208]: Sending gratuitous ARP on ens33 for 10.10.10.110
Feb 07 13:47:58 ha01 Keepalived_vrrp[6208]: Sending gratuitous ARP on ens33 for 10.10.10.110
Feb 07 13:47:58 ha01 Keepalived_vrrp[6208]: VRRP_Instance(VI_1) Sending/queueing gratuitous ARPs on ens33 for 10.10.10.110
Feb 07 13:47:58 ha01 Keepalived_vrrp[6208]: Sending gratuitous ARP on ens33 for 10.10.10.110
Feb 07 13:47:58 ha01 Keepalived_vrrp[6208]: Sending gratuitous ARP on ens33 for 10.10.10.110
Feb 07 13:47:58 ha01 Keepalived_vrrp[6208]: Sending gratuitous ARP on ens33 for 10.10.10.110
Feb 07 13:47:58 ha01 Keepalived_vrrp[6208]: Sending gratuitous ARP on ens33 for 10.10.10.110
[root@ha01 ~]#

4. check ip

[root@ha01 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:d5:60:ff brd ff:ff:ff:ff:ff:ff
    inet 10.10.10.15/24 brd 10.10.10.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet 10.10.10.110/32 scope global ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::ab:9da3:cd98:e07a/64 scope link noprefixroute
       valid_lft forever preferred_lft forever
3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:d5:60:09 brd ff:ff:ff:ff:ff:ff
[root@ha01 ~]#

[root@ha01 ~]# ifconfig -a
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.10.10.15  netmask 255.255.255.0  broadcast 10.10.10.255
        inet6 fe80::ab:9da3:cd98:e07a  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:d5:60:ff  txqueuelen 1000  (Ethernet)
        RX packets 4578  bytes 349152 (340.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 134908  bytes 8261883 (7.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens34: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether 00:0c:29:d5:60:09  txqueuelen 1000  (Ethernet)
        RX packets 155544  bytes 11163143 (10.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1735  bytes 286914 (280.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 439563  bytes 49067876 (46.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 439563  bytes 49067876 (46.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@ha01 ~]#

 

No comments:

Post a Comment

Popular Posts