1.8 KiB
1.8 KiB
DNS enteries:
ivera-db1 IN A 192.168.0.109
ivera-db2 IN A 192.168.0.110
ivera-db-vip IN A 192.168.0.115
Master node
File docker-compose.yml:
services:
keepalived:
image: osixia/keepalived:latest
container_name: keepalived-master
restart: unless-stopped
network_mode: host
cap_add:
- NET_ADMIN
- NET_RAW
- NET_BROADCAST
volumes:
- ./keepalived.conf:/etc/keepalived/keepalived.conf:ro
File keepalived.conf:
vrrp_instance VI_1 {
state MASTER
interface enp1s0
virtual_router_id 51
priority 100
advert_int 1
unicast_src_ip 192.168.0.109 # Replace with Master node's actual IP
unicast_peer {
192.168.0.110 # Replace with Backup node's actual IP
}
authentication {
auth_type PASS
auth_pass secret
}
virtual_ipaddress {
192.168.0.115/24 # The shared Virtual IP (VIP)
}
}
Backup node
File docker-compose.yml:
services:
keepalived:
image: osixia/keepalived:latest
container_name: keepalived-backup
restart: unless-stopped
network_mode: host
cap_add:
- NET_ADMIN
- NET_RAW
- NET_BROADCAST
volumes:
- ./keepalived.conf:/etc/keepalived/keepalived.conf:ro
File keepalived.conf:
vrrp_instance VI_1 {
state BACKUP
interface enp1s0
virtual_router_id 51
priority 90
advert_int 1
unicast_src_ip 192.168.0.110 # Replace with Backup node's actual IP
unicast_peer {
192.168.0.109 # Replace with Master node's actual IP
}
authentication {
auth_type PASS
auth_pass secret
}
virtual_ipaddress {
192.168.0.115/24 # The shared Virtual IP (VIP)
}
}