keepalived的配置文件‘
时间: 2023-11-16 21:20:13 浏览: 91
keepalived配置文件参考
Keepalived是一个基于VRRP协议的高可用性解决方案,其配置文件主要包含以下几个部分:
1.全局设置:
global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}
2.虚拟IP设置:
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 101
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.0.1/24 dev eth0
}
}
3.监控脚本设置:
vrrp_script chk_http_port {
script "/usr/local/bin/check_apache.sh"
interval 2
weight 2
}
4.故障转移设置:
virtual_server 192.168.0.1 80 {
delay_loop 6
lb_algo rr
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 192.168.0.2 80 {
weight 1
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 192.168.0.3 80 {
weight 1
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
配置文件中的各个部分需要根据实际情况进行修改,可参考官方文档进行配置。
阅读全文