标签:技术 启动脚本 硬件 lis chm ram 文件 install png
文章目录yum install bzip2-devel pcre-devel gcc gcc-c++ make -y
tar zxvf haproxy-1.5.19.tar.gz -C /opt/
//解压到/opt目录下
make TARGET=linux3100
注:这个版本号,可以使用 uname -a 命令来查看版本号
make install
mkdir /etc/haproxy
cp examples/haproxy.cfg /etc/haproxy/
vim /etc/haproxy/haproxy.cfg
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
uid 99
gid 99
daemon
#debug
#quiet
defaults
log global
mode http
option httplog
option dontlognull
retries 3
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
listen webcluster 0.0.0.0:80
option httpchk GET /test.html
balance roundrobin
server inst1 192.168.100.201:80 check inter 2000 fall 3
server inst2 192.168.100.202:80 check inter 2000 fall 3
cp examples/haproxy.init /etc/init.d/haproxy
//复制到init.d启动进程中
chmod +x /etc/init.d/haproxy
//添加执行权限
chkconfig --add haproxy
//添加到service,便于识别
ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
//创建软连接
service haproxy start
[root@Haproxy haproxy-1.5.19]# systemctl stop firewalld.service
[root@Haproxy haproxy-1.5.19]# setenforce 0
vim/etc/haproxy/haproxy.cfg
修改global段:
log /dev/log local0 info //正常访问的信息存放地
log /dev/log local0 notice //提示、警告等信息存放地
service haproxy restart
[root@Haproxy haproxy]# touch /etc/rsyslog.d/haproxy.conf
[root@Haproxy haproxy]# cd /etc/rsyslog.d/
[root@Haproxy rsyslog.d]# vim haproxy.conf
if ($programname == ‘haproxy‘ and $syslogseverity-text == ‘info‘)
then -/var/log/haproxy/haproxy-info.log
&~
if ($programname == ‘haproxy‘ and $syslogseverity-text == ‘notice‘)
then -/var/log/haproxy/haproxy-notice.log
&~
systemctl restart rsyslog.service
标签:技术 启动脚本 硬件 lis chm ram 文件 install png
原文地址:https://blog.51cto.com/14557584/2469766