dongnan
总版主
总版主
  • 粉丝52
  • 发帖数2198
  • 铜币14128枚
  • 威望6136点
  • 银元155个
  • 社区居民
  • 最爱沙发
  • 忠实会员
  • 喜欢达人
  • 原创写手
阅读:1736回复:0

Haproxy HA(Keepalived)

楼主#
更多 发布于:2015-11-17 09:05
1. 环境
#Nginx-VIP              1.1.1.1
#Nginx-Master           1.1.1.2/10.0.100.2
#Nginx-BACKUP           1.1.1.3/10.0.100.3
#WEB1                   10.0.100.4
#WEB1                   10.0.100.5

2.配置文件
2.1 haporxy
参考这里: http://ywwd.net/read-873

2.2keepalived
#MASTER
! Configuration File for keepalived
    
#Global
global_defs {
   router_id haproxy-ha
}
    
vrrp_script chk_haproxy {
    script "killall -0 haproxy"
    interval 3
    fall 3
    rise 1
    weight -30
}
    
#VRRP
vrrp_instance VI_1 {
    state MASTER
    interface eth0
    track_interface {
        eth0
        eth1
    }
    
    virtual_router_id 45
    priority 120
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass ywwd.net
    }
    
    track_script {
        chk_haproxy
    }
    
    virtual_ipaddress {
        1.1.1.1
    }
}

#Backup
! Configuration File for keepalived
    
#Global
global_defs {
   router_id haproxy-ha
}
    
vrrp_script chk_haproxy {
    script "killall -0 haproxy"
    interval 3
    fall 3
    rise 1
    weight -30
}
    
#VRRP
vrrp_instance VI_1 {
    #state MASTER
    state BACKUP
    interface eth0
    track_interface {
        eth0
        eth1
    }
    
    virtual_router_id 45
    #priority 120
    priority 100
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass ywwd.net
    }
    
    track_script {
        chk_haproxy
    }
    
    virtual_ipaddress {
        1.1.1.1
    }
}

注意:master 与 backup 配置文件的区别。

3. 测试
请参考 http://ywwd.net/read-635


4. 注意事项
防火墙允许vrrp 协议通信,请参考: http://ywwd.net/read-662

参考
Nginx HA(Keepalived)

#
欢迎关注微信公众号: 运维录
游客

返回顶部