主keepalived设置

#安装keepalived
[root@localhost ~]# yum -y install keepalived
#安装nginx
[root@localhost ~]# yum -y install nginx
——————————————————————————————————
#keepalived配置文件
[root@localhost ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_garp_interval
vrrp_gna_interval
} vrrp_script check_nginx { #引入脚本文件
script "/shell/nginx_check.sh"
interval
weight -
} vrrp_instance VI_1 {
state MASTER #主
interface eno16777728 #心跳网卡
virtual_router_id
priority #优先级
advert_int
authentication {
auth_type PASS
auth_pass
}
virtual_ipaddress {
192.168.200.201
}
track_script {
check_nginx #引用脚本
}
}
______________________________________________________
#装备测试文件
[root@localhost ~]# echo "" > /usr/share/nginx/html/index.html

从keepalived设置

#安装keepalived
[root@localhost ~]# yum -y install keepalived
#安装nginx
[root@localhost ~]# yum -y install nginx
______________________________________________________________
#keepalived配置文件
[root@localhost ~]# vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived global_defs {
notification_email {
acassen@firewall.loc
failover@firewall.loc
sysadmin@firewall.loc
}
notification_email_from Alexandre.Cassen@firewall.loc
smtp_server 192.168.200.1
smtp_connect_timeout
router_id LVS_DEVEL
vrrp_skip_check_adv_addr
vrrp_strict
vrrp_garp_interval
vrrp_gna_interval
} vrrp_script check_nginx {
script "/shell/nginx_check.sh"
interval
weight -
} vrrp_instance VI_1 {
state BACKUP
interface eno16777728
virtual_router_id
priority
advert_int
authentication {
auth_type PASS
auth_pass
}
virtual_ipaddress {
192.168.200.201
}
track_script {
check_nginx
}
} ———————————————————————————————————
#准备测试文件
[root@localhost ~]# echo "" > /usr/share/nginx/html/index.html

三、测试
主服务器工作时

从服务器工作时

四、nginx_check.sh shell文件,配置为周期性任务

#!/bin/bash
count="$(ps -C nginx --no-header|wc -l)" if [ $count -eq ];then
systemctl restart nginx
sleep
if [ ps -c nginx --no-header|wc -l -eq ];then
systemctl stop keepalived
fi
fi
#给脚本加执行权限
chmod +x /shell/nginx_check.sh

Nginx与keepalived实现高可用的更多相关文章

  1. nginx与keepalived实现高可用+Apache实现负载均衡

    nginx与keepalived实现高可用 本实验使用了四台虚拟机 两台需要安装nginx及keepalived 两台安装Apache nginx可以源码安装也可以用yum安装nginx yum安装n ...

  2. docker 部署nginx 使用keepalived 部署高可用

    一.体系架构 在Keepalived + Nginx高可用负载均衡架构中,keepalived负责实现High-availability (HA) 功能控制前端机VIP(虚拟网络地址),当有设备发生故 ...

  3. nginx使用keepalived实现高可用

    环境: 主:linux-node1  110.0.0.137 备:linux-node2  110.0.0.138   VIP: 110.0.0.120   NGINX安装: # rpm -ivh h ...

  4. 架构设计:负载均衡层设计方案(6)——Nginx + Keepalived构建高可用的负载层

    1.概述 前两遍文章中,我们一直在说后文要介绍Nginx + Keepalived的搭建方式.这篇文章开始,我们就来兑现前文的承诺,后续的两篇文章我们将介绍Nginx + Keepalived和 LV ...

  5. Keepalived+LVS+Nginx负载均衡之高可用

    Keepalived+LVS+Nginx负载均衡之高可用 上一篇写了nginx负载均衡,此篇实现高可用(HA).系统整体设计是采用Nginx做负载均衡,若出现Nginx单机故障,则导致整个系统无法正常 ...

  6. Nginx keepalived实现高可用负载均衡详细配置步骤

    Keepalived是一个免费开源的,用C编写的类似于layer3, 4 & 7交换机制软件,具备我们平时说的第3层.第4层和第7层交换机的功能.主要提供loadbalancing(负载均衡) ...

  7. Nginx系列二:(Nginx Rewrite 规则、Nginx 防盗链、Nginx 动静分离、Nginx+keepalived 实现高可用)

    一.Nginx Rewrite 规则 1. Nginx rewrite规则 Rewrite规则含义就是某个URL重写成特定的URL(类似于Redirect),从某种意义上说为了美观或者对搜索引擎友好, ...

  8. Keepalived+Nginx实现负载均衡高可用

    一.负载均衡高可用 Nginx作为负载均衡器,所有请求都到了Nginx,可见Nginx处于非常重点的位置,如果Nginx服务器宕机后端web服务将无法提供服务,影响严重. 为了避免负载均衡服务器的宕机 ...

  9. suse 12 编译部署Keepalived + nginx 为 kube-apiserver 提供高可用

    文章目录 编译部署nginx 下载nginx源码包 编译nginx 配置nginx.conf 配置nginx为systemctl管理 分发nginx二进制文件和配置文件 启动kube-nginx服务 ...

随机推荐

  1. java 线程同步方法执行与唤醒实例

    账号提钱.存钱实例方法 public class Account { private int balance; private int maxBalance; public Account(int b ...

  2. .netcore2.1 ef 使用外键关联查询

    //实体类 [Table("invoiceinfo", Schema = "obs")] public class invoice { [Key] public ...

  3. InnoDB On-Disk Structures(四)--Doublewrite Buffer (转载)

    转载.节选于 https://dev.mysql.com/doc/refman/8.0/en/innodb-doublewrite-buffer.html The doublewrite buffer ...

  4. http服务需要pycurl模块这样去监控服务

    最近运维还是比较空闲,写篇自己的心得体会.做过运维的应该都做过http服务了.像一些电子商城,或者是一些互联网公司,web的服务之类是至关重要的,近期看了刘天斯大哥的书觉得自己运维平台应该也可以这样去 ...

  5. Web项目配置https

    在java安装目录下bin目录下keytool工具 keytool -genkey -storetype PKCS12 -keysize 2048 -alias tomcat -keyalg RSA ...

  6. openstack-neutron安装与配置

    一.实验目的: 1.理解neutron服务在OpenStack中的作用 2.掌握在控制节点上安装配置neutron的方法和步骤 3.掌握在计算节点上安装与配置neutron的方法和步骤 二.实验步骤: ...

  7. 安装oracle11g服务端

    1.将oracle11g压缩包 解压到D盘根目录下 2.打开解压出来的文件夹,以管理员身份运行setup 3.警告弹框点击“是(Y)” 4.在此步骤中,可以提供您的电子邮件,以获取有关Oracle安全 ...

  8. TKinter当Label绑定bind事件时传参方法

    记录下tkinter的 当在label绑定bind事件时,遇到需要传参时的解决方法(因为有event存在 所以不能直接传参) https://www.cnblogs.com/liyuanhong/ar ...

  9. ccf-csp201809题解

    目录 ccf-csp201809题解 1. 201809-1 卖菜 题目描述 解析 通过代码 2. 201809-2 买菜 题目描述 解析 通过代码 3.201809-3 元素选择器 题目描述 解析 ...

  10. 性能分析-java程序篇之案例-工具和方法

    1. 背景说明 线上服务响应时间超过40秒,登录服务器发现cpu将近100%了(如下图),针对此问题,本文说明排查过程.工具以定位具体的原因. 2. 分析排查过程 此类问题的排查,有两款神器可用,分别 ...