FileManagement/linux/Haproxy安装.txt

28 lines
1.2 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#将HAProxy安装到CentOS和RHEL上
yum install haproxy
#日志配置内容位于/etc/haproxy/haproxy.cfg的global部分
log 127.0.0.1 local2
换成:
log 127.0.0.1 local0
#在/var/log中为HAProxy创建单独的日志文件。为此我们需要改动当前的rsyslog配置。
为了让配置简单而清楚,我们将在/etc/rsyslog.d/中创建一个名为haproxy.conf的新文件其内容如下
$ModLoad imudp
$UDPServerRun 514
$template Haproxy,"%msg%\n"
local0.=info ­/var/log/haproxy.log;Haproxy
local0.notice ­/var/log/haproxy­status.log;Haproxy
local0.* ~
#该配置将把基于$template的所有HAProxy消息隔离到/var/log中的日志文件。现在重启rsyslog让变更内容生效。
service rsyslog restart
#启动重启
service haproxy start
service haproxy restart