2

你好 StackOverflow,

我的 haproxy 似乎有错误,这是我尝试运行它时得到的

[ALERT] 208/051346 (5865) : Starting proxy ah1: cannot bind socket
[ALERT] 208/051346 (5865) : Starting proxy ah2: cannot bind socket

我正在为 TCP 代理运行它。

这是我的配置:

#---------------------------------------------------------------------
# Example configuration for a possible web application.  See the
# full configuration options online.
#
#   http://haproxy.1wt.eu/download/1.3/doc/configuration.txt
#
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
    global
    log         127.0.0.1 local2 
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will 
# use if not designated in their block
#---------------------------------------------------------------------
defaults
    mode        tcp
    log         global
    option      dontlognull
    option      forwardfor
    option      redispatch
    timeout connect 10000 # default 10 second time out if a backend is not found
    timeout client 300000
    timeout server 300000
    maxconn     60000
    retries     3


listen ah1 207.254.9.41:30000
mode tcp
balance leastconn
server ah1_1 46.16.77.23:30000

listen ah2 207.254.9.41:30001
mode tcp
balance leastconn
server ah2_1 46.16.77.23:30001

我们正在运行 Red Hat Enterprise Linux 5 (x64)

4

2 回答 2

7

使用端口 30000 和 30001 检查现有进程:

lsof -i 或 netstat -lnp

如果您没有在端口 30000 或 30001 上进行任何侦听,请确保您在系统上实际配置了 207.254.9.41 的 IP 地址:

ip 地址或 ifconfig

如果您没有看到 207.254.9.41 列出,那么您可以将其更改为正确的 IP 地址或直接取消 IP 地址:

:30000 而不是 207.254.9.41:30000

如果这些都不能解决问题,那么我建议升级到 1.4 或 1.5(我在非常大的生产环境中使用 1.5 已经快一年了,没有任何问题)。如果 1.4 和 1.5 不在包存储库中,那么我建议自己编译。

于 2013-08-05T03:34:48.013 回答
1

可能是您在该服务器上运行 apache,它使用的端口与您在 Haproxy 上使用的端口相同。然后停止使用与 haproxy 上使用的相同端口的应用程序,然后重新启动它。它应该工作。

谢谢

于 2014-07-09T12:38:51.140 回答