环境说明
系统信息 | 主机名 | IP |
---|---|---|
rhel8 | zabbix | 192.168.236.136 |
rhel8 | MASTER | 192.168.236.131 |
rhel8 | SLAVE | 192.168.236.135 |
keepalived安装
配置主keepalived
//关闭防火墙与SELINUX
[root@MASTER ~]# systemctl stop firewalld
[root@MASTER ~]# systemctl disable firewalld
[root@MASTER ~]# setenforce 0
[root@MASTER ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
//配置网络源
[root@MASTER ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
[root@MASTER ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@MASTER ~]# sed -i 's/\$releasever/8/g' /etc/yum.repos.d/CentOS-Base.repo
[root@MASTER ~]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[root@MASTER ~]# sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@MASTER ~]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
//安装keepalived
[root@MASTER ~]# yum -y install keepalived
在主备机上分别安装httpd
在master上安装httpd
[root@MASTER ~]# yum -y install httpd
[root@MASTER ~]# echo "web1" > /var/www/html/index.html
[root@MASTER ~]# systemctl start httpd
[root@MASTER ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@MASTER ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
在slave上安装httpd
[root@SLAVE ~]# yum -y install httpd
[root@SLAVE ~]# echo "web2" > /var/www/html/index.html
[root@SLAVE ~]# systemctl start httpd
[root@SLAVE ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*