环境准备:关闭防火墙、关闭SELinux、配置YUM源
一、部署keepalived服务
1.web4安装Keepalive
[root@web4 ~]# yum -y install keepalived
- 1
- 修改配置文件
[root@web4 ~]# vim /etc/keepalived/keepalived.conf
- 1
配置文件下边全部删掉,下边的配置都是用来设置LVS规则的,在我们今天的这个实验里用不到
- 启动服务
[root@web4 ~]# systemctl start keepalived
- 1
- web5安装Keepalive服务
[root@web5 ~]# yum -y install keepalived
- 1
- 修改配置文件
[root@web5 ~]# vim /etc/keepalived/keepalived.conf
- 1
配置文件下边全部删掉,下边的配置都是用来设置LVS规则的,在我们今天的这个实验里用不到
- 启动服务
[root@web5 ~]# systemctl start keepalived
- 1
配置网站服务
2、web4部署网站服务
- 源码安装nginx
[root@web4 lnmp_soft]# tar -xf nginx-1.12.2.tar.gz
[root@web4 lnmp_soft]# cd nginx-1.12.2
- 1
- 2
- 安装nginx依赖包
[root@web4 nginx-1.12.2]# yum -y install gcc pcre-devel openssl-devel
- 1
3.检测环境
[root@web4 nginx-1.12.2]# ./configure
- 1
- 编译并安装
[root@web4 nginx-1.12.2]# make && make install
- 1
- 修改默认首页
[root@web4 nginx-1.12.2]# echo web4 > /usr/local/nginx/html/index.html
- 1
- 创键连接到$PATH变量路径,启动服务
[root@web4 nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /sbin
[root@web4 nginx-1.12.2]# nginx
- 1
- 2
web5部署网站服务
[root@web5 lnmp_soft]# tar -xf nginx-1.12.2.tar.gz
[root@web5 lnmp_soft]# cd nginx-1.12.2
- 1
- 2
- 安装依赖包
[root@web5 nginx-1.12.2]# yum -y install gcc pcre-devel openssl-devel
- 1
- 检测环境
[root@web5 nginx-1.12.2]# ./configure
- 1
- 编译安装
[root@web5 nginx-1.12.2]# make && make install
- 1
- 修改默认首页
[root@web5 nginx-1.12.2]# echo web5 > /usr/local/nginx/html/index.html
- 1
- 创键连接,启动服务
[root@web5 nginx-1.12.2]# ln -s /usr/local/nginx/sbin/nginx /sbin
[root@web5 nginx-1.12.2]# nginx
- 1
- 2
配置keepalived监控Nginx服务状态
- 编写检测Nginx状态脚本
- 修改keepalived配置文件
[root@web4 ~]# vim /etc/keepalived/keepalived.conf
- 1
3. 重启keepalived服务
[root@web4 nginx-1.12.2]# systemctl restart keepalived
- 1
参考链接 :
keepalived+Nginx实现Web高可用
https://mp.weixin.qq.com/s/kq-QH1j4iCG9IFl1voC-Dg
</div><div data-report-view="{"mod":"1585297308_001","dest":"https://blog.csdn.net/qq_40907977/article/details/107962898","extend1":"pc","ab":"new"}"><div></div></div>
<link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-ff98e99283.css" rel="stylesheet">
</div>