Starting the Service and Enabling Auto-Start
On lb01:
[root@lb01 nginx]# systemctl start keepalived.service
[root@lb01 nginx]# systemctl enable keepalived.service
On lb02:
[root@lb02 ~]# systemctl start keepalived.service
[root@lb02 ~]# systemctl enable keepalived.service
Packet Capture Analysis with Wireshark
Once the service is running, capture network packets to verify VRRP communication:
![Packet capture screenshot]
Examine the captured packets to identify VRRP advertisement messages being exchanged between Master and Backup nodes.
Configuration File Structure
The primary configuration file is located at /etc/keepalived/keepalived.conf. Before making any modifications, create a backup of the original configuration file.
[root@lb01 nginx]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id lb01
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 150
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.3/24 dev eth0 label eth0:1
}
}
Configuration for Primary and Backup Nodes
The Master node configuration differs from the Backup node in the following key parameters:
- state: Set to MASTER for the primary node, BACKUP for secondary nodes
- priority: Higher value (150) for Master, lower value (100) for Backup
- router_id: Unique identifier for each node in the cluster
Master node (lb01) uses priorrity 150, while the Backup node (lb02) uses priority 100.
Testing Failover Behavior
To verify the high availability setup:
- Stop the keepalived service on the Master node
- Observe the Backup node taking over the virtual IP address
- Restart the Master node service
- Confirm that the Master node regains control due to higher priority
The VRRP protocol ensures seamless failover by electing a new Master when the current Master becomes unavailable. The Backup node continuously monitors the Master through VRRP advertisements sent at configured intervals.
Key VRRP Parameters
| Parameter | Description | Typical Value |
|---|---|---|
| virtual_router_id | Unique identifier for the VRRP instance | 51 |
| priority | Node priority for Master election | 150 (Master), 100 (Backup) |
| advert_int | Advertisement interval in seconds | 1 |
| auth_type | Authentication method | PASS |
| virtual_ipaddress | Floating IP assigned to the cluster | 10.0.0.3/24 |
This configuration provides a fully functional high availability setup where the Backup node automatically assumes the virtual IP address when the Master node fails, ensuring continuous service availability.