【问题标题】:Error while Running Haproxy and Apache on same server for load balancing在同一台服务器上运行 Haproxy 和 Apache 以进行负载平衡时出错
【发布时间】:2015-05-21 10:50:03
【问题描述】:

让我描述一下场景:

我有两台服务器,即 server1 和 server2 并在两者上运行 apache。 我在 server1 上安装了 haproxy 并配置如下: global log /dev/log local0 log /dev/log local1 notice chroot /var/lib/haproxy stats socket /run/haproxy/admin.sock mode 660 level admin stats timeout 30s user haproxy group haproxy daemon defaults log global mode http option httplog option dontlognull timeout connect 5000 timeout client 50000 timeout server 50000 errorfile 400 /etc/haproxy/errors/400.http errorfile 403 /etc/haproxy/errors/403.http errorfile 408 /etc/haproxy/errors/408.http errorfile 500 /etc/haproxy/errors/500.http errorfile 502 /etc/haproxy/errors/502.http errorfile 503 /etc/haproxy/errors/503.http errorfile 504 /etc/haproxy/errors/504.http frontend localnodes bind *:80 mode http default_backend nodes backend nodes mode http balance roundrobin option forwardfor option httpchk HEAD / HTTP/1.1\r\nHost:localhost server web01 IP1:80 check server web02 IP2:80 check listen stats *:1936 stats enable stats uri / stats hide-version stats auth username:password

在运行 haproxy (service haproxy restart) 时,出现以下错误:

启动前端本地节点:无法绑定套接字

我尝试将 apache 默认端口更改为 81 ,我也尝试过 更改 sysctl.conf , net.ipv4.ip_nonlocal_bind=1 ... 仍然得到同样的错误。我对服务器配置很陌生, 有人可以帮忙吗?

【问题讨论】:

  • 1023 以上的端口可以用吗?我猜你手动启动它?如果是这种情况,请设置适当的 initscript/unit-file。

标签: linux ubuntu server haproxy


【解决方案1】:

如果端口空闲(使用 netstat -punta | grep 80 检查)以 root 用户启动服务。 将“user haproxy”和“group haproxy”更改为“user root”和“group root”

【讨论】:

    猜你喜欢
    • 2019-06-20
    • 1970-01-01
    • 2013-10-23
    • 2016-08-23
    • 2013-03-24
    • 1970-01-01
    • 2015-10-26
    • 2021-09-06
    • 2022-01-13
    相关资源
    最近更新 更多