l {
path /
status_code 200
}
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
[root@backup ~]# systemctl restart keepalived.service
[root@master ~]# systemctl restart keepalived.service
[root@master ~]# yum -y install ipvsadm
[root@backup ~]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.26.222:80 wrr
-> 192.168.26.101:80 Route 1 0 0
-> 192.168.26.102:80 Route 1 0 0
1.3Rs1 安装nginx 添加虚拟IP arp抑制
#关闭防火墙和slinux
[root@rs1 ~]# systemctl stop firewalld.service
[root@rs1 ~]# setenforce 0
[root@rs1 ~]# yum -y install nginx
[root@rs1 ~]# echo "rs1" > /usr/share/nginx/html/index.html
[root@rs1 ~]# systemctl enable --now nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@rs1 ~]# curl 127.0.0.1 rs1
[root@rs1 ~]# ip addr add 192.168.26.222/32 dev ens33 label ens33:1
[root@rs1 ~]# vim /etc/sysctl.conf #在末尾插入
[root@rs1 ~]# sysctl -p
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
1.4RS2同上
[root@rs2 ~]# systemctl stop firewalld.service
[root@rs2 ~]# setenforce 0
[root@rs2 ~]# yum -y install nginx
[root@rs2 ~]# echo "rs2" > /usr/share/nginx/html/index.html
[root@rs2 ~]# systemctl enable --now nginx
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root@rs2 ~]# ip addr add 192.168.26.222/32 dev lo label lo:1
[root@rs2 ~]# curl 127.0.0.1
rs2
[root@rs2 ~]# vim /etc/sysctl.conf
[root@rs2 ~]# sysctl -p
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
1.5测试
二.实现后端服务器上运行wordpress博客站点
2.1Rs1 rs2继续配置 都配置PHP环境(编译安装)
[root@rs1 ~]# yum -y remove php-fpm php-mysqlnd php-json #(删除自带yum安装的)
Loaded plugins: fastestmirror
No Match for argument: php-fpm
No Match for argument: php-mysqlnd
No Match for argument: php-json
No Packages marked for removal
[root@rs1 ~]# yum -y install gcc openssl-devel libxml2-devel bzip2-devel libmcrypt-devel sqlite-devel oniguruma-devel
[root@rs1 ~]# cd /usr/local/src
[root@rs1 src]# wget https://www.php.net/distributions/php-7.4.11.tar.xz
--2023-03-23 15:56:56-- https://www.php.net/distributions/php-7.