keepalived 配置,vip 配置

可紊 提交于 2020-02-29 14:33:32

keepalived 配置,vip 配置
A主机:
! Configuration File for keepalived
global_defs {
router_id mycat
}
vrrp_script chk_haproxy {
script "killall -0 haproxy" #cheaper than pidof
interval 2 #check every 2 seconds
}
vrrp_instance Mycat1 {
state BACKUP
interface eth0
track_interface {
eth0
}
virtual_router_id 150
priority 200
! nopreempt
advert_int 5
authentication {
auth_type PASS
auth_pass test_mycat1
}
virtual_ipaddress {
192.168.1.200/24 brd 192.168.1.255 dev eth0 label eth0:1
}
track_script {
check_haproxy weight=0 #+2 if process is present
}
}
vrrp_instance Mycat2 {
state BACKUP
interface eth0
track_interface {
eth0
}
virtual_router_id 151
priority 100
nopreempt
advert_int 5
authentication {
auth_type PASS
auth_pass test_mycat2
}
virtual_ipaddress {
192.168.1.201/24 brd 192.168.1.255 dev eth0 label eth0:2
}
track_script {
check_haproxy weight=0 #+2 if process is present
}
}


B主机:
! Configuration File for keepalived

global_defs {
router_id mycat
}

vrrp_script chk_haproxy {
script "killall -0 haproxy" #cheaper than pidof
interval 2 #check every 2 seconds
}

vrrp_instance Mycat1 {
state BACKUP
interface eth0
track_interface {
eth0
}
virtual_router_id 150
priority 100
nopreempt
advert_int 5
authentication {
auth_type PASS
auth_pass test_mycat1
}
virtual_ipaddress {
192.168.1.200/24 brd 192.168.1.255 dev eth0 label eth0:1
}
track_script {
check_haproxy weight=0 #+2 if process is present
}
}

vrrp_instance Mycat2 {
state BACKUP
interface eth0
track_interface {
eth0
}
virtual_router_id 151
priority 200
! nopreempt
advert_int 5
authentication {
auth_type PASS
auth_pass test_mycat2
}
virtual_ipaddress {
192.168.1.201/24 brd 192.168.1.255 dev eth0 label eth0:2
}
track_script {
check_haproxy weight=0 #+2 if process is present
}
}

 #都存活A为1.200,B为1.201  ; 任一挂了,另一同时为1.200,1.201,两倍工作量;

最后通过DNS将两个IP(A记录)指向相同域名轮询。

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!