首页 > 其他 > 详细

keepalived 配置,vip 配置

时间:2019-05-25 16:13:01      阅读:129      评论:0      收藏:0      [点我收藏+]

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

 

keepalived 配置,vip 配置

原文:https://www.cnblogs.com/hmj589119/p/10922698.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!