keepalived 配置,vip 配置


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记录)指向相同域名轮询。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM