keepalived+Nginx实现Web高可用

环境准备:关闭防火墙、关闭SELinux、配置YUM源

一、部署keepalived服务

1.web4安装Keepalive

[root@web4 ~]# yum -y install keepalived

   
   
  • 1
  1. 修改配置文件
[root@web4 ~]# vim /etc/keepalived/keepalived.conf

   
   
  • 1

在这里插入图片描述
配置文件下边全部删掉,下边的配置都是用来设置LVS规则的,在我们今天的这个实验里用不到

  1. 启动服务
[root@web4 ~]# systemctl start keepalived

   
   
  • 1
  1. web5安装Keepalive服务
[root@web5 ~]# yum -y install keepalived

   
   
  • 1
  1. 修改配置文件
[root@web5 ~]# vim /etc/keepalived/keepalived.conf

   
   
  • 1

在这里插入图片描述
配置文件下边全部删掉,下边的配置都是用来设置LVS规则的,在我们今天的这个实验里用不到

  1. 启动服务
[root@web5 ~]# systemctl start keepalived

   
   
  • 1

配置网站服务

2、web4部署网站服务

  1. 源码安装nginx
[root@web4 lnmp_soft]# tar -xf nginx-1.12.2.tar.gz
[root@web4 lnmp_soft]# cd nginx-1.12.2

   
   
  • 1
  • 2
  1. 安装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
  1. 编译并安装
[root@web4 nginx-1.12.2]# make && make install

   
   
  • 1
  1. 修改默认首页
[root@web4 nginx-1.12.2]# echo web4 > /usr/local/nginx/html/index.html

   
   
  • 1
  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
  1. 安装依赖包
[root@web5 nginx-1.12.2]# yum -y install gcc pcre-devel openssl-devel

   
   
  • 1
  1. 检测环境
[root@web5 nginx-1.12.2]# ./configure

   
   
  • 1
  1. 编译安装
[root@web5 nginx-1.12.2]# make && make install

   
   
  • 1
  1. 修改默认首页
[root@web5 nginx-1.12.2]# echo web5 > /usr/local/nginx/html/index.html

   
   
  • 1
  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服务状态

  1. 编写检测Nginx状态脚本
    在这里插入图片描述
  2. 修改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="{&quot;mod&quot;:&quot;1585297308_001&quot;,&quot;dest&quot;:&quot;https://blog.csdn.net/qq_40907977/article/details/107962898&quot;,&quot;extend1&quot;:&quot;pc&quot;,&quot;ab&quot;:&quot;new&quot;}"><div></div></div>
            <link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-ff98e99283.css" rel="stylesheet">
                            </div>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值