---------------------安装服务软件包----------------
yum install pcre-devel bzip2-devel gcc gcc-c++ -y
tar zxvf haproxy-1.5.19.tar.gz -C /opt
cd /opt/haproxy-1.5.19/
make TARGET=linux26
make install
----------------------------修改配置文件-------------
mkdir /etc/haproxy
cp /opt/haproxy-1.5.19/examples/haproxy.cfg /etc/haproxy/
vim /etc/haproxy/haproxy.cfg
# chroot /usr/share/haproxy //禁锢share目录
# redispatch //反复重新发送
----------删除所有listen,增加下段---------
listen webcluster 0.0.0.0:80 //允许任意网络访问网站
option httpchk GET /index.html //定义默认首页类型
balance roundrobin //负载均衡算法,轮询
server inst1 192.168.218.130:80 check inter 2000 fall 3 //定义在线节点
server inst2 192.168.218.131:80 check inter 2000 fall 3
--------------------创建启动连接,开启服务----------------------
cp /opt/haproxy-1.5.19/examples/haproxy.init /etc/init.d/haproxy
chmod 755 /etc/init.d/haproxy
chkconfig --add haproxy //开机自启
ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
systemctl start haproxy.service
systemctl stop firewalld.service
setenforce 0
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。