| | 1 | = Keepalived active stand by = |
| | 2 | |
| | 3 | On master site ip 10.7.168.221, file '''/etc/keepalived/keepalived.conf''' |
| | 4 | {{{ |
| | 5 | root@n4:/etc/keepalived# pwd |
| | 6 | /etc/keepalived |
| | 7 | root@n4:/etc/keepalived# more keepalived.conf |
| | 8 | vrrp_script chk_service_health { |
| | 9 | #script /etc/keepalived/check_proc.sh |
| | 10 | #script /etc/keepalived/check_ping.sh |
| | 11 | weight 10 |
| | 12 | # how often script run in period 10 sec |
| | 13 | interval 5 |
| | 14 | # How long to wait for the script to return (5 seconds). |
| | 15 | timeout 5 |
| | 16 | # How many times the script must return successfully in order for the host to be considered healthy. |
| | 17 | rise 3 |
| | 18 | # How many times the script must return unsuccessfully (or time out) in order for the host to be considered unhealthy |
| | 19 | fall 3 |
| | 20 | } |
| | 21 | |
| | 22 | vrrp_instance VI_1 { |
| | 23 | #state BACKUP |
| | 24 | state MASTER |
| | 25 | interface ens3 |
| | 26 | virtual_router_id 51 |
| | 27 | priority 201 |
| | 28 | advert_int 10 |
| | 29 | authentication { |
| | 30 | auth_type PASS |
| | 31 | auth_pass 1234 |
| | 32 | } |
| | 33 | unicast_src_ip 10.7.168.221 |
| | 34 | unicast_peer { |
| | 35 | 10.7.168.58 |
| | 36 | } |
| | 37 | virtual_ipaddress { |
| | 38 | 10.7.168.200/24 |
| | 39 | } |
| | 40 | track_script { |
| | 41 | chk_service_health |
| | 42 | } |
| | 43 | notify /etc/keepalived/keepalived_notify.sh |
| | 44 | notify_master /etc/keepalived/keepalived_notify_master.sh |
| | 45 | notify_backup /etc/keepalived/keepalived_notify_backup.sh |
| | 46 | } |
| | 47 | |
| | 48 | |
| | 49 | }}} |