您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。