在例子中,我在网上看到
https://www.datadoghq.com/blog/how-to-collect-haproxy-metrics/#show-me-the-metrics
您可以使用命令行
echo "show stat" | nc -U /var/lib/haproxy/stats
Run Code Online (Sandbox Code Playgroud)
这在输出中非常难看。列不匹配,很难看出发生了什么。
# pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq,dresp,ereq,econ,eresp,wretr,wredis,status,weight,act,bck,chkfail,chkdown,lastchg,downtime,qlimit,pid,iid,sid,throttle,lbtot,tracked,type,rate,rate_lim,rate_max,check_status,check_code,check_duration,hrsp_1xx,hrsp_2xx,hrsp_3xx,hrsp_4xx,hrsp_5xx,hrsp_other,hanafail,req_rate,req_rate_max,req_tot,cli_abrt,srv_abrt,comp_in,comp_out,comp_byp,comp_rsp,lastsess,last_chk,last_agt,qtime,ctime,rtime,ttime,
someapp,FRONTEND,,,1,1,512,1,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,2,0,,,,0,0,0,1,,,,,,,,,,,0,0,0,,,0,0,0,0,,,,,,,,
anotherdb,anotherdb-tp-01,0,0,1,1,,1,0,0,,0,,0,0,0,0,no check,1,1,0,,,,,,1,2,1,,1,,2,0,,1,,,,,,,,,,0,,,,0,0,,,,,3006,,,0,0,0,0,
someotherappdb,BACKEND,0,0,1,1,52,1,0,0,0,0,,0,0,0,0,UP,1,1,0,,0,3008,0,,1,2,0,,1,,1,0,,1,,,,,,,,,,,,,,0,0,0,0,0,0,3006,,,0,0,0,0,
Run Code Online (Sandbox Code Playgroud)
有没有一种好方法来清理它并使其更具可读性。
这是我的配置
global
log /dev/log local0
log 127.0.0.1 local1 notice
maxconn 4096
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
listen webfarm 0.0.0.0:80
mode http
stats enable
stats uri /haproxy?stats
balance roundrobin
option httpclose
option forwardfor
server apache 192.168.1.10:8001 weight 1 maxconn 512 check
Run Code Online (Sandbox Code Playgroud)
配置后我重新启动了haproxy服务,我收到以下消息
root@d32b2eb97bf0:/# service haproxy start
* Starting haproxy haproxy [WARNING] 144/130034 (436) : parsing [/etc/haproxy/haproxy.cfg:17] : the 'contimeout' directive …Run Code Online (Sandbox Code Playgroud) 多个进程正在侦听同一个端口。但据我所知,只有一个进程可以监听一个端口。是否有可能(如何?)多个进程可以在同一个端口上侦听?
$ sudo lsof -n -i :80 | grep LISTEN
haproxy 2039 root 4u IPv4 12874 0t0 TCP *:http (LISTEN)
haproxy 2042 root 4u IPv4 12898 0t0 TCP *:http (LISTEN)
haproxy 2045 root 4u IPv4 12923 0t0 TCP *:http (LISTEN)
Run Code Online (Sandbox Code Playgroud)
pstree 输出:
init
??acpid -c /etc/acpi/events -s /var/run/acpid.socket
??atd
??cron
??dbus-daemon --system --fork
??dhclient -1 -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0
??docker -d
? ??6*[{docker}]
??getty -8 38400 tty4
??getty -8 38400 tty5
??getty -8 38400 tty2
??getty -8 38400 …Run Code Online (Sandbox Code Playgroud) 我在同一个网络中有 2 个 docker 容器-web并proxy在haproxy后端运行
backend web
server web web:80 check
Run Code Online (Sandbox Code Playgroud)
也init-addr设置为last,libc,none,因此如果无法web在启动时解决它不会失败。
如果我proxy先开始,haproxy报告could not resolve address 'web', disabling server。
然后我开始web。它可以通过名称从 访问proxy,在 ping 和 telnet 上响应。但haproxy仍然对待web后端。
我希望在默认间隔(根据文档每 2 秒)haproxy重试检查后端web,并且作为 resilt - 尝试在每次检查时再次解析 dns。
如何配置haproxy等待 dns 解析后端服务器名称,然后自动启动该后端?
haproxy ×4
linux ×2
command-line ×1
installation ×1
networking ×1
port ×1
sockets ×1
ubuntu ×1