Nginx与keepalived实现高可用
主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实现高可用的更多相关文章
- nginx与keepalived实现高可用+Apache实现负载均衡
nginx与keepalived实现高可用 本实验使用了四台虚拟机 两台需要安装nginx及keepalived 两台安装Apache nginx可以源码安装也可以用yum安装nginx yum安装n ...
- docker 部署nginx 使用keepalived 部署高可用
一.体系架构 在Keepalived + Nginx高可用负载均衡架构中,keepalived负责实现High-availability (HA) 功能控制前端机VIP(虚拟网络地址),当有设备发生故 ...
- nginx使用keepalived实现高可用
环境: 主:linux-node1 110.0.0.137 备:linux-node2 110.0.0.138 VIP: 110.0.0.120 NGINX安装: # rpm -ivh h ...
- 架构设计:负载均衡层设计方案(6)——Nginx + Keepalived构建高可用的负载层
1.概述 前两遍文章中,我们一直在说后文要介绍Nginx + Keepalived的搭建方式.这篇文章开始,我们就来兑现前文的承诺,后续的两篇文章我们将介绍Nginx + Keepalived和 LV ...
- Keepalived+LVS+Nginx负载均衡之高可用
Keepalived+LVS+Nginx负载均衡之高可用 上一篇写了nginx负载均衡,此篇实现高可用(HA).系统整体设计是采用Nginx做负载均衡,若出现Nginx单机故障,则导致整个系统无法正常 ...
- Nginx keepalived实现高可用负载均衡详细配置步骤
Keepalived是一个免费开源的,用C编写的类似于layer3, 4 & 7交换机制软件,具备我们平时说的第3层.第4层和第7层交换机的功能.主要提供loadbalancing(负载均衡) ...
- Nginx系列二:(Nginx Rewrite 规则、Nginx 防盗链、Nginx 动静分离、Nginx+keepalived 实现高可用)
一.Nginx Rewrite 规则 1. Nginx rewrite规则 Rewrite规则含义就是某个URL重写成特定的URL(类似于Redirect),从某种意义上说为了美观或者对搜索引擎友好, ...
- Keepalived+Nginx实现负载均衡高可用
一.负载均衡高可用 Nginx作为负载均衡器,所有请求都到了Nginx,可见Nginx处于非常重点的位置,如果Nginx服务器宕机后端web服务将无法提供服务,影响严重. 为了避免负载均衡服务器的宕机 ...
- suse 12 编译部署Keepalived + nginx 为 kube-apiserver 提供高可用
文章目录 编译部署nginx 下载nginx源码包 编译nginx 配置nginx.conf 配置nginx为systemctl管理 分发nginx二进制文件和配置文件 启动kube-nginx服务 ...
随机推荐
- GO基础之异常处理
一.异常 1. 错误指程序中出现不正常的情况,从而导致程序无法正常执行.•大多语言中使用try... catch... finally语句执行.假设我们正在尝试打开一个文件,文件系统中不存在这个文件. ...
- 「SAP技术」如何看Z移动类型是复制哪个标准移动类型而创建的?
[SAP技术]SAP MM 如何看一个自定义移动类型是复制哪个标准移动类型而创建的? 比如项目上有一个自定义移动类型Z59,是复制551移动类型而定义的. OMJJ配置界面里,是有一个Ref字段.如下 ...
- 嵌入Canvas App到Dynamics 365 Customer Engagement(Model-Driven App)中,创造更多可能!
我是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面 ...
- C lang:character input and output (I/O)
Xx_Introduction Character input and output is by more line character conpose of the text flow Defin ...
- 2、nio的例子实践
下面的例子,说明了,nio中的三大核心类的基本使用.buffer,channel,selector package com.shengsiyuan.nio; import org.junit.Test ...
- Spring注解--实现applicationContext.xml效果
随着越来越多地使用Springboot敏捷开发,更多地使用注解配置Spring,而不是Spring的applicationContext.xml文件. Configuration注解: Spring解 ...
- Test Case:: 12C ASMCMD New feature (Doc ID 1589249.1)
Test Case:: 12C ASMCMD New feature (Doc ID 1589249.1) APPLIES TO: Oracle Database - Enterprise Editi ...
- tensorflow和pytorch教程
https://github.com/dragen1860/Deep-Learning-with-TensorFlow-book
- 电位器控制两个 LED 灯交替闪烁
电路图: 布局:
- Redis开发与运维:特性
Redis 特性 速度快 内存数据库 L1 cache reference 读取CPU的一级缓存 0.5 ns Branch mispredict (转移.分支预测) 5 ns L2 cache re ...