2LVS + keepalived

5 bind dns源站

yum -y install  ipvsadm keepalived

lvs增加并发

echo "options ip_vs conn_tab_bits=22" > /etc/modprobe.d/ip_vs.conf  然后重启服务器

cat check_dns_resolve.sh   # 该文件加执行权限

#!/bin/bash
# check dns resolve a_check="check.healthcheck.check"
nslookup_bin="/usr/bin/nslookup" ns_ip=$1
port=53
timeout=2 function EchoHelp(){
echo "use: ./check_dns_resolve.sh [ip] {port}"
exit 1
} if [ $2 ]; then
port=$2
fi if [ $ns_ip -a $a_check ]; then
$nslookup_bin -timeout=${timeout} -port=$port $a_check $ns_ip > /dev/null
else
EchoHelp fi exit $?

keepalived_notify.py 参照 https://www.cnblogs.com/linkenpark/p/7416998.html

lvs1 keepalived配置:

cat /etc/keepalived/keepalived.conf

global_defs {
notification_email {
keepalived@qq.com
} notification_email_from keepalived@qq.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id lvs_canlu
} vrrp_instance VI_1 {
state BACKUP
interface ens160
virtual_router_id 162
mcast_src_ip 172.16.12.26
priority 100
advert_int 2 authentication {
auth_type PASS
auth_pass sPkdd98m
} virtual_ipaddress {
172.16.12.30
} notify_master "/bin/python /tuandai/script/keepalived_notify.py master 172.16.12.26 172.16.12.30"
notify_backup "/bin/python /tuandai/script/keepalived_notify.py backup 172.16.12.26 172.16.12.30" } ## dns_bind
virtual_server 172.16.12.30 53 {
delay_loop 6
lb_algo lc
lb_kind DR
#persistence_timeout 1
protocol UDP real_server 172.16.7.14 53 {
weight 10
MISC_CHECK {
misc_path "/usr/bin/sh /etc/keepalived/check_dns_resolve.sh 172.16.7.14"
misc_timeout 5
}
}
real_server 172.16.7.15 53 {
weight 10
MISC_CHECK {
misc_path "/usr/bin/sh /etc/keepalived/check_dns_resolve.sh 172.16.7.15"
misc_timeout 5
}
}
real_server 172.16.7.16 53 {
weight 10
MISC_CHECK {
misc_path "/usr/bin/sh /etc/keepalived/check_dns_resolve.sh 172.16.7.16"
misc_timeout 5
}
}
real_server 172.16.7.17 53 {
weight 10
MISC_CHECK {
misc_path "/usr/bin/sh /etc/keepalived/check_dns_resolve.sh 172.16.7.17"
misc_timeout 5
}
}
real_server 172.16.7.18 53 {
weight 10
MISC_CHECK {
misc_path "/usr/bin/sh /etc/keepalived/check_dns_resolve.sh 172.16.7.18"
misc_timeout 5
}
}
}

lvs2 keepalived配置:

global_defs {
notification_email {
keepalived@qq.com
} notification_email_from keepalived@qq.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id lvs_canlu
} vrrp_instance VI_1 {
state BACKUP
interface ens160
virtual_router_id 162
mcast_src_ip 172.16.12.27
priority 99
advert_int 2 authentication {
auth_type PASS
auth_pass sPkdd98m
} virtual_ipaddress {
172.16.12.30
} notify_master "/bin/python /tuandai/script/keepalived_notify.py master 172.16.12.27 172.16.12.30"
notify_backup "/bin/python /tuandai/script/keepalived_notify.py backup 172.16.12.27 172.16.12.30" } ## dns_bind
virtual_server 172.16.12.30 53 {
delay_loop 6
lb_algo lc
lb_kind DR
#persistence_timeout 1
protocol UDP real_server 172.16.7.14 53 {
weight 10
MISC_CHECK {
misc_path "/usr/bin/sh /etc/keepalived/check_dns_resolve.sh 172.16.7.14"
misc_timeout 5
}
}
real_server 172.16.7.15 53 {
weight 10
MISC_CHECK {
misc_path "/usr/bin/sh /etc/keepalived/check_dns_resolve.sh 172.16.7.15"
misc_timeout 5
}
}
real_server 172.16.7.16 53 {
weight 10
MISC_CHECK {
misc_path "/usr/bin/sh /etc/keepalived/check_dns_resolve.sh 172.16.7.16"
misc_timeout 5
}
}
real_server 172.16.7.17 53 {
weight 10
MISC_CHECK {
misc_path "/usr/bin/sh /etc/keepalived/check_dns_resolve.sh 172.16.7.17"
misc_timeout 5
}
}
real_server 172.16.7.18 53 {
weight 10
MISC_CHECK {
misc_path "/usr/bin/sh /etc/keepalived/check_dns_resolve.sh 172.16.7.18"
misc_timeout 5
}
}
}

keepalived进程检测:

cat /script/check_keepalived.sh

#!/bin/bash

servicename="keepalived"
showname="keepalived"
pid="keepalived"
status="${showname}_failed"
success_status="${showname}_success" function CheckPs(){
local ret=`pidof $pid | wc -l`
echo $ret
} if [ $(CheckPs) == 0 ]; then
service $servicename restart
sleep 1
if [ $(CheckPs) != 0 ]; then
status=$success_status
fi else
status=$success_status
fi echo $status

添加定时任务

cat /etc/crontab

## check keepalived
* * * * * root sh /script/check_keepalived.sh > /dev/null;

centos7 lvs keepalived做DNS集群负载的更多相关文章

  1. LVS+Keepalived搭建MyCAT高可用负载均衡集群

    LVS+Keepalived 介绍 LVS LVS是Linux Virtual Server的简写,意即Linux虚拟服务器,是一个虚拟的服务器集群系统.本项目在1998年5月由章文嵩博士成立,是中国 ...

  2. Nginx+Keepalived高可用集群应用实践

    Nginx+Keepalived高可用集群应用实践 1.Keepalived高可用软件 1.1 Keepalived服务的三个重要功能 1.1.1管理LVS负载均衡软件 早期的LVS软件,需要通过命令 ...

  3. lunix 集群,负载均衡,location

       nginx location语法: location支持的语法优先级: 复制代码location匹配顺序 #  www.s14hanju.com/1.location = / {  我是代码1} ...

  4. zookeeper在集群负载均衡中的应用

    zookeeper本身是不提供负载均衡的策略,需要自己来实现,所以这里确切的说,是在负载均衡中应用到了zookeeper做集群的协调. 对于HTTP请求的负载均衡,成熟的解决方案是Nginx(或Hap ...

  5. haproxy+keepalived实现web集群高可用性[转]

    负载均衡集群的概念 负载均衡是设计分布式系统架构必须要考虑的因素之一,它指的是通过调度分发的方式尽可能将“请求”.“访问”的压力负载平均分摊到集群中的各个节点,避免有些节点负载太高导致访问延迟,而有些 ...

  6. Keepalived高可用集群应用

    Keepalived高可用集群应用 1.keepalived服务说明 1.1.keepalived介绍 Keepalived是一个用C语言编写的路由软件.该项目的主要目标是为Linux系统和基于Lin ...

  7. Apache + Tomcat集群 + 负载均衡

    Part I: 取经处: http://www.ramkitech.com/2012/10/tomcat-clustering-series-simple-load.html  http://blog ...

  8. Haproxy+keepalived高可用集群实战

    1.1  Haproxy+keepalived高可用集群实战 随着互联网火热的发展,开源负载均衡器的大量的应用,企业主流软件负载均衡如LVS.Haproxy.Nginx等,各方面性能不亚于硬件负载均衡 ...

  9. Application Request Route实现IIS Server Farms集群负载详解

    序言 随着公司业务的发展,后台业务就变的越来越多,然而服务器的故障又像月经一样,时不时的汹涌而至,让我们防不胜防.那么后台的高可用,以及服务器的处理能力就要做一个横向扩展的方案,以使后台业务持续的稳定 ...

随机推荐

  1. POJ-1475 Pushing Boxes (BFS+优先队列)

    Description Imagine you are standing inside a two-dimensional maze composed of square cells which ma ...

  2. 高精度减法用string 和 stack

    #include "bits/stdc++.h" using namespace std; int main() { string a,b; while(cin >> ...

  3. EL表达式、 jstl标签

    https://www.cnblogs.com/zhaotiancheng/p/6391894.html https://blog.csdn.net/zdwzzu2006/article/detail ...

  4. bzoj1008

    题解: 要求有几种方案可以越狱,可以用总方案-不会越狱的方案 那么总方案就是m^n 那么考虑不会越狱的方案 显然第一个人有m中,后面都是m-1中(和前一个不一样) 答案就是m^n-m*(m-1)^(n ...

  5. 猎豹浏览器(chrome内核)屏蔽视频广告

    1.基于猎豹浏览器(原则上chrome内核浏览器都可以) 2.下载插件Adblock Plus,下载地址:http://chromecj.com/productivity/2014-07/24/dow ...

  6. iOS使用UIWebView遇到Error Domain=WebKitErrorDomain Code=101 “The operation couldn’t be completed. (WebKitErrorDomain error 101

    现在在接触iOS开发,今天在调试一个界面加载web页面的问题,发现死活无法加载,浏览器里能正常打开,加上相应代码之后得到了错误信息为: 2013-04-18 15:05:06.446 Client_D ...

  7. js中定时器

    周期性定时器:周期性的执行某段代码 window.setInterval()      window.clearInterval() 示例: document.it = setInterval(fun ...

  8. js 兼容各类手机 的写法 待续

    //通过高度来判断是否是iPhone 4还是iPhone 5 isPhone4inches = (window.screen.height==480); isPhone5inches = (windo ...

  9. Java实现交换两个String

    在Java中我们所使用的实例变量其实都是一个引用,所以如果要求实现一个swap(String A, String B)这种函数时无法实现的,因为在类方法的定义中是先对行参进行地址传递,然后对形参修改, ...

  10. CentOS7安装OpenStack(Rocky版)-05.安装一个nova计算节点实例

    上一篇文章分享了控制节点的nova计算服务的安装方法,在实际生产环境中,计算节点通常会安装一些单独的节点提供服务,本文分享单独的nova计算节点的安装方法 ----------------  完美的分 ...