keepalive的配置文件

! 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_script check_80 { //定义vrrp脚本
script '/root/check_code.py' //脚本路径
interval //脚本检测时间间隔,脚本必须在间隔时间内返回状态,不然日志报错
//Keepalived_vrrp[7813]: Process [7894] didn't respond to SIGTERM
weight - //当脚本返回的状态码不是0时,操作权重
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id
priority
advert_int
authentication {
auth_type PASS
auth_pass
}
virtual_ipaddress {
192.168.89.100
}
track_script { //定义监控脚本
check_80
}
}

使用的脚本:/root/check_code.py

(该脚本检查http的状态吗,如果不是200,则关闭keepalive服务,使VIP漂移到备份机上)
#!/usr/bin/env python
import urllib2
import os
url = 'http://192.168.89.81/index.html'
try:
check_code = urllib2.urlopen(url,timeout=).code
except Exception,e:
print e
check_code =
print check_code
if check_code == :
pass
else:
os.system('service keepalived stop')

keepalive笔记之二:keepalive+nginx(自定义脚本实现,上述例子也可以实现)的更多相关文章

  1. Dynamic CRM 2013学习笔记(二十一)自定义审批流2 - 配置按钮

    上次介绍了 Dynamic CRM 2013学习笔记(十九)自定义审批流1 - 效果演示 现在开始介绍如何配置审批流,首先在form上添加三个按钮,Submit, Agree, Reject: 1. ...

  2. Android学习笔记(二十)——自定义内容提供器

    //此系列博文是<第一行Android代码>的学习笔记,如有错漏,欢迎指正! 如果我们想要实现跨程序共享数据的功能,官方推荐的方式就是使用内容提供器,可以通过新建一个类去继承 Conten ...

  3. Robot Framework 学习笔记(二)-------第一个脚本

    robot Framework环境搭建好之后先来一个简单的脚本跑一下 一.新建项目 二.新建测试套件  三.创建测试用例 四.导入Selenium2Library库 因为RF框架编写基于web 的测试 ...

  4. Spring-Cloud-Ribbon学习笔记(二):自定义负载均衡规则

    Ribbon自定义负载均衡策略有两种方式,一是JavaConfig,一是通过配置文件(yml或properties文件). 需求 假设我有包含A和B服务在内的多个微服务,它们均注册在一个Eureka上 ...

  5. Scala学习笔记(二):运行脚本文件

    在某个目录(如:F:\)下新建一个文本文件,命名为:hello.scala 其内容为: println("Hello World!") 那么这个时候该怎么运行这个脚本文件呢? 通过 ...

  6. Nginx 笔记(二)nginx常用的命令和配置文件

    个人博客网:https://wushaopei.github.io/    (你想要这里多有) 1.nginx常用的命令 (1)启动命令 在/usr/local/nginx/sbin 目录下执行 ./ ...

  7. Cocos2d-x 3.2 学习笔记(二)创建自定义项目

    一.通过命令创建项目 前面搭建好环境后,怎样创建自己的cocos2d-x项目呢? 先来看看cocos2dx 3.2的目录吧(涉及到3.1.1版本的,请自动对应3.2版本,3.x版本的环境搭建都是一样的 ...

  8. Openresty 学习笔记(二)Nginx Lua 正则表达式相关API

    ngx.re.match 语法: captures, err = ngx.re.match(subject, regex, options?, ctx?, res_table?) 环境: init_w ...

  9. Nginx笔记总结二十:nginx索引目录配置

    location / { autoindex on; autoindex_localtime on; }

随机推荐

  1. Python—后台运行(nohup 、&、 2>&1详解)

    一.脚本文件(test.py) # -*- coding: UTF-8 -*- import time print("hello"," python") os. ...

  2. Java之同步代码块处理继承Thread类的线程安全问题

    package com.atguigu.java; /** *//** * 使用同步代码块解决继承Thread类的方式的线程安全问题 * * 例子:创建三个窗口卖票,总票数为100张.使用继承Thre ...

  3. 吴裕雄--天生自然python Google深度学习框架:经典卷积神经网络模型

    import tensorflow as tf INPUT_NODE = 784 OUTPUT_NODE = 10 IMAGE_SIZE = 28 NUM_CHANNELS = 1 NUM_LABEL ...

  4. Educational Codeforces Round 55 (Rated for Div. 2)E

    题:https://codeforces.com/contest/1082/problem/E 题意:给出n个数和一个数c,只能操作一次将[L,R]之间的数+任意数,问最后该序列中能存在最多多少个c ...

  5. ZJNU 1130 - 龟兔赛跑——中高级

    只需求出乌龟最短耗时跟兔子耗时比即可将起点 0 和终点 N+1 也看做充电站,进行动态规划对第i个点进行动态规划,则可以得到状态转移方程为dp[i] = max{dp[j]+time[i][j]} j ...

  6. 893C. Rumor#谣言传播(赋权无向图&搜索)

    题目出处:http://codeforces.com/problemset/problem/893/C 题目大意:一个城中有一些关系圈,圈内会传播谣言,求使每个人都知道谣言的最小花费 #include ...

  7. Hive(二)—— 架构设计

    Hive架构 Figure 1 also shows how a typical query flows through the system. 图一显示一个普通的查询是如何流经Hive系统的. Th ...

  8. Equal Cut

    Equal Cut 题目描述 Snuke has an integer sequence A of length N. He will make three cuts in A and divide ...

  9. [LC] 1170. Compare Strings by Frequency of the Smallest Character

    Let's define a function f(s) over a non-empty string s, which calculates the frequency of the smalle ...

  10. 吴裕雄--天生自然C语言开发:强制类型转换

    #include <stdio.h> int main() { , count = ; double mean; mean = (double) sum / count; printf(& ...