配置haproxy负载均衡http
环境说明:
环境 | ip | 要安装的应用 |
---|---|---|
调度器(haproxy) | 192.168.192.135 | haproxy |
第一台服务器(rs1) | 192.168.192.136 | httpd、https |
第二台服务器(rs2) | 192.168.192.137 | httpd、https |
准备工作
三台主机都做,同时在rs1和rs2上面安装好httpd
#配置阿里源
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
配置epel源
yum -y install epel-release
关闭selinux和防火墙
systemctl disable --now firewalld
firewall-cmd --state
not running
sed -i "s/=enforcing/=disabled/g" /etc/selinux/config
setenforce 0
getenforce
Permissive
reboot
getenforce
Disabled
配置httpd负载均衡
haproxy安装
yum -y install make gcc pcre-devel bzip2-devel openssl-devel systemd-devel
#创建用户
useradd -r -M -s /sbin/nologin haproxy
下载并解压haproxy包 http://github.com/haproxy/haproxy
[root@haproxy ~]# ls
anaconda-ks.cfg haproxy-2.6.0.tar.gz
[root@haproxy ~]# tar xf haproxy-2.6.0.tar.gz
[root@haproxy ~]# cd haproxy-2.6.0
[root@haproxy haproxy-2