配置Haproxy日志支持
cp /etc/rsyslog.conf /etc/rsyslog.conf`date +%F`
ll /etc/rsyslog.con*
cat>> /etc/rsyslog.conf<<EOF
#haproxy
local0.* /application/haproxy/logs/haproxy.log
#end
EOF
##应为在haproxy配置文件中指定了是local0,所以这里选择local0。下面的haproxy配置文件的相应配置:
===============
log 127.0.0.1:514 local0 warning
##全局的日志配置,,log关键字,指定使用127.0.0.1:514的syslog服务中的local0日志设备,日志 级别,这里选择是warning,一般不要用info
================
#修改/etc/sysconfig/rsyslog内容如下:
[root@MASTER ~]# tail -2 /etc/sysconfig/rsyslog
#SYSLOGD_OPTIONS="-c 5"
SYSLOGD_OPTIONS="-c 2 -m 0 -r -x"
[root@MASTER ~]#
#重启 /etc/init.d/rsyslog
/etc/init.d/rsyslog restart
#6.4 默认没端口
netstat -lntup
/etc/init.d/rsyslog restart
########修改rsyslog.conf 让其出现端口
egrep 'UDPServerRun|ModLoad' /etc/rsyslog.conf
sed -i 's/#$UDPServerRun 514/$UDPServerRun 514/g' /etc/rsyslog.conf
sed -i 's/#$ModLoad imudp/$ModLoad imudp/g' /etc/rsyslog.conf
sed -n -e '/$ModLoad imudp/p' -e '/$UDPServerRun/p' /etc/rsyslog.conf
#重启 /etc/init.d/rsyslog
/etc/init.d/rsyslog restart
netstat -lntup | grep rsyslog
[root@MASTER ~]# netstat -lntup | grep rsyslog
udp 0 0 0.0.0.0:514 0.0.0.0:* 5031/rsyslogd
udp 0 0 :::514 :::* 5031/rsyslogd
[root@MASTER ~]#
====================
[root@MASTER ~]# cat /application/haproxy/logs/haproxy.log
Nov 6 10:58:49 127.0.0.1 haproxy[5049]: Stopping proxy test in 0 ms.
Nov 6 10:58:49 127.0.0.1 haproxy[5049]: Proxy test stopped (FE: 0 conns, BE: 0 conns).
Nov 6 10:58:58 127.0.0.1 haproxy[5055]: Stopping proxy test in 0 ms.
Nov 6 10:58:58 127.0.0.1 haproxy[5055]: Proxy test stopped (FE: 0 conns, BE: 0 conns).
[root@MASTER ~]#
###注意,如果还是无法记录日志,记得要关闭selinux
Haproxy+Keepalived搭建Weblogic高可用负载均衡集群
CentOS 6.3下Haproxy+Keepalived+Apache配置笔记