当前位置:网站首页>[cluster] haproxy load balancing

[cluster] haproxy load balancing

2022-06-11 07:34:00 Sprite, don't be angry


Preface

The content of this blog is only to record the thoughts of bloggers , For reference only , Everything is subject to the results of their own practice .


One 、haproxy Load balancing

1.0 Architecture Overview

effect IP Address Installation services
Main load balancer 192.168.13.10haproxy-1.5.19
Node server 1192.168.13.20httpd
Node server 2192.168.13.30httpd
Log collector 192.168.13.40ipvsadm/keepalived

1.1 Load balancing scheduler

systemctl stop firewalld
setenforce 0
yum install -y pcre-devel bzip2-devel gcc gcc-c++ make
 Upload compressed package 
tar zxvf haproxy-1.5.19.tar.gz
cd haproxy-1.5.19/
make TARGET=linux2628 ARCH=x86_64
make install

mkdir /etc/haproxy
cp examples/haproxy.cfg /etc/haproxy/
vim /etc/haproxy/haproxy.cfg
	4 That's ok :log /dev/log    local0
	5 That's ok :log /dev/log    local1 notice
	
	8 That's ok :#chroot /usr/share/haproxy
	26 Below row : Delete all 
	26-30 That's ok : Add node server information 
		listen  webcluster 0.0.0.0:80
        option httpchk GET /index.html
        balance roundrobin
        server inst1 192.168.13.20:80 check inter 2000 fall 3
        server inst1 192.168.13.30:80 check inter 2000 fall 3

cp /opt/haproxy-1.5.19/examples/haproxy.init /etc/init.d/haproxy
chmod +x /etc/init.d/haproxy
ln -s /usr/local/sbin/haproxy /usr/sbin/haproxy
service haproxy start

1.2 Node server

systemctl stop firewalld
setenforce 0
yum install httpd -y
echo 'this is web1!' >/var/www/html/index.html
systemctl start httpd

 The other server repeats the operation 

Two 、 Conclusion

  • Be steady , Wrong, take your time
  • In the configuration file option httpchk GET /index.html This business , It corresponds to the last default file type of the node server , Must correspond to , Otherwise return to 503
原网站

版权声明
本文为[Sprite, don't be angry]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110729301652.html