配置主keepalived
客户端关闭防火墙与SELINUX
[root@master ~]# systemctl stop firewalld.service
[root@master ~]# systemctl disable firewalld.service
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@master ~]# setenforce 0
[root@master ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
[root@master ~]#
客户端配置网络源
[root@master ~]# dnf -y install epel-release
[root@master ~]# dnf list all |grep keepalived
keepalived.x86_64 2.1.5-6.el8 AppStream
[root@master ~]#
客户端安装keepalived
[root@master ~]# dnf -y install keepalived
客户端查看安装生成的文件
[root@master ~]# rpm -ql keepalived
/etc/keepalived //配置目录
/etc/keepalived/keepalived.conf //此为主配置文件
/etc/sysconfig/keepalived
/usr/bin/genhash
/usr/lib/systemd/system/keepalived.service //此为服务控制文件
/usr/libexec/keepalived
/usr/sbin/keepalived
.....此处省略N行
用同样的方法在备服务器上安装keepalived
服务端关闭防火墙与SELINUX
[root@client ~]# systemctl stop firewalld.service
[root@client ~]# systemctl disable firewalld.service
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@client ~]# setenforce 0
[root@client ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
[root@client ~]#
服务端配置网络源
[root@client ~]# dnf -y install epel-release
[root@client ~]# dnf list all |grep keepalived
keepalived.x86_64 2.1.5-6.el8 AppStream
[root@client ~]#
服务端安装keepalived
[root@client ~]# dnf -y install keepalived
在主备机上分别安装nginx
在master上安装nginx
[root@master ~]# dnf -y install nginx
[root@master ~]# cd /usr/share/nginx/html/
[root@master html]# ls
404.html 50x.html index.html nginx-logo.png poweredby.png
[root@master html]# echo 'master' > index.html
[root@master html]# systemctl start nginx
[root@master html]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:80 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:80