AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 788886
Accepted
BentCoder
BentCoder
Asked: 2016-07-10 07:16:51 +0800 CST2016-07-10 07:16:51 +0800 CST 2016-07-10 07:16:51 +0800 CST

当两台 HAProxy 服务器中只有一台关闭时系统中断。故障转移似乎不起作用

  • 772

首先,我对 HAProxy 堆栈的体验只有一天之久,所以我希望我的问题是有道理的。

我有 2 个 HAProxy 虚拟机和 2 个 Apache 虚拟机(流浪机器),如下所示。

192.168.50.11 HAPROXY VM1
192.168.50.12 HAPROXY VM2
192.168.50.21 APACHE VM1
192.168.50.22 APACHE VM2

192.168.50.10 FLOATING IP - set in keepalived of both HAProxy servers above

如果我关闭其中一台 Apache 服务器并且呼叫http://192.168.50.10系统仍然可以正常工作,那很好。但是,如果我关闭其中一台 HAProxy 服务器,整个服务就会关闭。根据我下面的配置,你能告诉我我在这里缺少什么吗?

两台服务器上的 HAProxy 设置

/etc/default/haproxy

ENABLED=1

/etc/haproxy/haproxy.cfg

global
    log /dev/log local0
    log 127.0.0.1 local1 notice
    user haproxy
    group haproxy
    maxconn 2000
    daemon

defaults
    log global
    mode http
    option httplog
    option dontlognull
    retries 3
    option redispatch
    timeout connect 5000
    timeout client 50000
    timeout server 50000

listen webservers 192.168.50.10:80
    balance roundrobin
    stats enable
    stats auth admin:admin
    stats uri /haproxy?stats
    option httpchk
    option forwardfor
    option http-server-close
    server webserver1 192.168.50.21:80 check
    server webserver2 192.168.50.22:80 check

两台服务器上的保持设置

/etc/sysctl.conf

net.ipv4.ip_nonlocal_bind=1

等/keepalived/keepalived.conf

vrrp_script chk_haproxy {
    script "killall -0 haproxy"
    #Ping every 2 seconds
    interval 2
    weight 2
}

vrrp_instance VI_1 {
    interface eth0
    state MASTER
    virtual_router_id 51
    priority 11
    virtual_ipaddress {
        192.168.50.10
    }
    track_script {
        chk_haproxy
    }
}

注意:仅priority取决于 VM,因此它适用priority 11于192.168.50.11 HAPROXY VM1机器和机器。priority 12192.168.50.12 HAPROXY VM2

我在阅读下面的博客文章后创建了这个示例。

  • 在 Debian Lenny 上使用 HAProxy/Keepalived 设置高可用性负载均衡器(具有故障转移和会话支持)
  • 如何使用 KEEPALIVED 设置 HAProxy
high-availability failover haproxy keepalived
  • 1 1 个回答
  • 208 Views

1 个回答

  • Voted
  1. Best Answer
    BentCoder
    2016-07-10T09:11:11+08:002016-07-10T09:11:11+08:00

    正如我所想,keepalived 配置文件存在小错误。

    state MASTER对于 192.168.50.11# This is the master HAProxy

    state BACKUP对于 192.168.50.12# This is the failover HAProxy

    和

    priority 12对于 192.168.50.11# the higher priority goes with the master HAProxy

    priority 11对于 192.168.50.12

    • 2

相关问题

  • LVS 集群帮助

  • 适用于 Linux 的良好故障转移/高可用性解决方案?[关闭]

  • 由于 MySQL DRBD Heartbeat 故障转移脚本导致的数据丢失

  • SQL Server - 集群与镜像的高可用性?

  • SQL Server 群集选项

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve