高可用搭建
使用keepalived实现高可用
主副节点Keepalived设置vi /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
router_id R1
}
vrrp_instance VI_1 {
# 副节点 SLAVE
state MASTER
interface ens37
virtual_router_id 66
# 副节点稍微降低,建议30
priority 80
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
120.10.10.100
}
}
virtual_server 120.10.10.100 80 {
delay_loop 1
lb_algo rr
lb_kind DR
persistence_timeout 50
protocol TCP
real_server 120.10.10.12 80 {
weight 1
TCP_CHECK{
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 4
}
}
real_server 120.10.10.13 80 {
weight 1
TCP_CHECK{
connect_port 80
connect_timeout 3
nb_get_retry 3
delay_before_retry 4
}
}
}