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

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

[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 imudpUDPServerRun 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)

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

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/52696.html

(0)
上一篇 2021年8月6日
下一篇 2021年8月6日

相关推荐

发表回复

登录后才能评论