haproxy+keepalived(主主模式)实现高可用环境的简单配置

发布时间:2020-08-07 20:05:16 作者:Mr_sheng
来源:网络 阅读:534

参考:haproxy+keepalived(主从模式)实现高可用环境的简单配置     https://blog.51cto.com/sf1314/2357735 

主主模式就是需要两个VIP,即两个haproxy节点都同时在提供服务,

当有一个haproxy挂掉后,它的vip资源就会漂到另一个haproxy节点上(此时它将有两个vip都在提供服务),故障转移无感知.


[root@Haproxy_Keepalived_Master ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
  notification_email {
    root@localhost
    }
 
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id HAproxy237
}
 
vrrp_script chk_haproxy {                                   #HAproxy 服务监控脚本                    
  script "/etc/keepalived/check_haproxy.sh"
  interval 2
  weight 2
}
 
vrrp_instance VI_1 {
  state MASTER
  interface eth0
  virtual_router_id 51
  priority 100
  advert_int 1
  authentication {
    auth_type PASS
    auth_pass 1111
}
  track_script {
    chk_haproxy
}
virtual_ipaddress {
    182.148.15.239
}
notify_master "/etc/keepalived/clean_arp.sh 182.148.15.239"
}
vrrp_instance VI_2 {
  state BACKUP
  interface eth0
  virtual_router_id 52
  priority 99
  advert_int 1
  authentication {
    auth_type PASS
    auth_pass 1111
}
virtual_ipaddress {
  182.148.15.235
}
notify_master "/etc/keepalived/clean_arp.sh 182.148.15.235"
}
  
3)Haproxy_Keepalived_Backup服务器上的Keepalived配置如下:
[root@Haproxy_Keepalived_Backup ~]# /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf-bak
[root@Haproxy_Keepalived_Backup ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
  notification_email {
    root@localhost
    }
 
notification_email_from keepalived@localhost
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id HAproxy236
}
 
vrrp_script chk_haproxy {                            
  script "/etc/keepalived/check_haproxy.sh"
  interval 2
  weight 2
}
 
vrrp_instance VI_1 {
  state BACKUP
  interface eth0
  virtual_router_id 51
  priority 99
  advert_int 1
  authentication {
    auth_type PASS
    auth_pass 1111
}
  track_script {
    chk_haproxy
}
virtual_ipaddress {
    182.148.15.239
}
notify_master "/etc/keepalived/clean_arp.sh 182.148.15.239"
}
vrrp_instance VI_2 {
  state MASTER
  interface eth0
  virtual_router_id 52
  priority 100
  advert_int 1
  authentication {
    auth_type PASS
    auth_pass 1111
}
virtual_ipaddress {
  182.148.15.235
}
notify_master "/etc/keepalived/clean_arp.sh 182.148.15.235"
}




推荐阅读:
  1. keepalived+Haproxy搭建高可用Web群集
  2. keepalived+haproxy高可用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

haproxy keepalived rox

上一篇:RAC环境中的阻塞 查找锁

下一篇:一招搞定各种报表合计需求

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》