2026-11-15 09:05:34
This commit is contained in:
1 parent
f61f22c7c4
commit
3ec5ba6294
1 file changed
+94
@@ -0,0 +1,94 @@
|
||||
|
||||
## DNS enteries:
|
||||
```text
|
||||
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`:
|
||||
```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`:
|
||||
```text
|
||||
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`:
|
||||
```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`:
|
||||
```text
|
||||
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)
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in new issue
Block a user