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