首页 Haproxy教程haproxy实战案例-启动本地和远程日志

Haproxy-日志配置

haproxy-Proxies配置

运维派隶属马哥教育旗下专业运维社区,是国内成立最早的IT运维技术社区,欢迎关注公众号:yunweipai
领取学习更多免费Linux云计算、Python、Docker、K8s教程关注公众号:马哥linux运维

实战案例:启动本地和远程日志

[root@centos7 ~]#vim /etc/haproxy/haproxy.cfg 
log 127.0.0.1 local2 info
log 10.0.0.8 local2 info
[root@centos7 ~]#systemctl restart haproxy

#开启本地日志
[root@centos7 ~]#vim /etc/rsyslog.conf 
$ModLoad imudp
$UDPServerRun 514
......
local3.*                                        /var/log/haproxy.log
[root@centos7 ~]#systemctl restart rsyslog

#开启远程主机日志
[root@centos8 ~]#vim /etc/rsyslog.conf 
module(load="imudp") # needs to be done just once   
input(type="imudp" port="514")
local3.*                   /var/log/haproxy.log 
[root@centos8 ~]#systemctl restart rsyslog

#浏览器访问:http://haproxy-server:9999/haproxy-status,观察本机和远程主机生成的日志
[root@centos7 ~]#tail /var/log/haproxy.log
[root@centos7 ~]#cat /var/log/haproxy.log 
Mar 30 23:42:52 localhost haproxy[28643]: Connect from 10.0.0.1:7820 to 10.0.0.7:9999 (stats/HTTP)
Mar 30 23:42:52 localhost haproxy[28643]: Connect from 10.0.0.1:7821 to 10.0.0.7:9999 (stats/HTTP)
Mar 30 23:42:53 localhost haproxy[28643]: Connect from 10.0.0.1:7822 to 10.0.0.7:9999 (stats/HTTP)

[root@centos8 ~]#tail /var/log/haproxy.log
Mar 30 23:42:53 10.0.0.7 haproxy[28643]: Connect from 10.0.0.1:7824 to 10.0.0.7:9999 (stats/HTTP)
Mar 30 23:42:53 10.0.0.7 haproxy[28643]: Connect from 10.0.0.1:7825 to 10.0.0.7:9999 (stats/HTTP)
Mar 30 23:42:53 10.0.0.7 haproxy[28643]: Connect from 10.0.0.1:7826 to 10.0.0.7:9999 (stats/HTTP)
Mar 30 23:42:53 10.0.0.7 haproxy[28643]: Connect from 10.0.0.1:7827 to 10.0.0.7:9999 (stats/HTTP)

本文链接:https://www.yunweipai.com/35263.html

Haproxy-日志配置

haproxy-Proxies配置

网友评论comments

发表回复

您的电子邮箱地址不会被公开。

暂无评论

Copyright © 2012-2022 YUNWEIPAI.COM - 运维派 京ICP备16064699号-6
扫二维码
扫二维码
返回顶部