HAProxy没有运行stats套接字

时间:2016-05-13 16:37:02

标签: haproxy

我在Arch Linux中安装了haproxy并修改了配置文件:

global
    maxconn     20000
    log         127.0.0.1 local0
    user        haproxy
    stats socket /run/haproxy/haproxy.sock mode 660 level admin
    stats timeout 30s
    chroot      /usr/share/haproxy
    pidfile     /run/haproxy.pid
    daemon

defaults
    mode    http
    stats   enable
    stats   uri /stats
    stats   realm Haproxy\ Statistics

frontend www-http
    bind 127.0.0.1:80
    default_backend www-backend

backend www-backend
    mode        http
    balance     roundrobin
    timeout     connect 5s
    timeout     server  30s
    timeout     queue   30s
    server  app1 127.0.0.1:5001 check
    server  app2 127.0.0.1:5002 check

我确保目录/run/haproxy存在,并且具有用户haproxy写入的权限:

 ツ ls -al /run/haproxy
total 0
drwxr-xr-x  2 haproxy root  40 May 13 21:37 .
drwxr-xr-x 27 root    root 720 May 13 22:00 ..

当我使用systemctl start haproxy.service启动haproxy时,它会正常加载。我甚至可以转到/stats页面查看统计信息,但socat报告以下错误:

ツ sudo socat unix-connect:/run/haproxy/haproxy.sock stdio
2016/05/13 22:04:11 socat[24202] E connect(5, AF=1 "/run/haproxy/haproxy.sock", 27): No such file or directory

我在智慧结束时无法理解发生了什么。这是我从journalctl -xe得到的:

May 13 21:56:31 rohanarch.local systemd[1]: Starting HAProxy Load Balancer...
May 13 21:56:31 rohanarch.local systemd[1]: Started HAProxy Load Balancer.
May 13 21:56:31 rohanarch.local haproxy-systemd-wrapper[20454]: haproxy-systemd-wrapper: executing /usr/bin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds
May 13 21:56:31 rohanarch.local haproxy-systemd-wrapper[20454]: [WARNING] 133/215631 (20456) : config : missing timeouts for frontend 'www-http'.
May 13 21:56:31 rohanarch.local haproxy-systemd-wrapper[20454]:    | While not properly invalid, you will certainly encounter various problems
May 13 21:56:31 rohanarch.local haproxy-systemd-wrapper[20454]:    | with such a configuration. To fix this, please ensure that all following
May 13 21:56:31 rohanarch.local haproxy-systemd-wrapper[20454]:    | timeouts are set to a non-zero value: 'client', 'connect', 'server'.

基本上,没有错误/警告,甚​​至没有关于stats套接字的指示。其他遇到stats套接字问题的人无法启动haproxy。在我的情况下,它启动正常,但套接字只是没有创建。

1 个答案:

答案 0 :(得分:0)

您需要自己手动创建目录。请确保 / run / haproxy存在。如果没有,请首先使用以下命令创建它:

sudo mkdir /run/haproxy

这应该可以解决您的问题。