您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
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
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。