keepalived+LVS搭建高可用负载均衡系统
相关架构设置:
1)vip : 192.168.137.6
2)DS master ip : 192.168.137.8
3)DS backup ip : 192.168.137.9
4)RS 1 ip: 192.168.137.100
5)RS 2 ip: 192.168.137.200
两台RS上的配置脚本:lvsrs
[root@localhost init.d]# cat /etc/init.d/lvsrs
#!/bin/sh
vip=192.168.137.6
. /etc/rc.d/init.d/functions case "$1" in
start)
ifconfig lo: $vip netmask 255.255.255.255 broadcast $vip
route add -host $vip dev lo:
echo "" > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo "" > /proc/sys/net/ipv4/conf/lo/arp_announce
echo "" > /proc/sys/net/ipv4/conf/all/arp_ignore
echo "" > /proc/sys/net/ipv4/conf/all/arp_announce
sysctl -p > /dev/null >&
echo "Real server start ok"
;; stop)
ifconfig lo: down
route del $vip >/dev/null >&
echo "" > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo "" > /proc/sys/net/ipv4/conf/lo/arp_announce
echo "" > /proc/sys/net/ipv4/conf/all/arp_ignore
echo "" > /proc/sys/net/ipv4/conf/all/arp_announce
echo "Real server stoped"
;; *)
echo "Usage: $0 {start|stop}"
exit
esac
DS master上的keepalived的配置文件:
[root@localhost ~]# cat /etc/keepalived/keepalived.conf
global_defs {
#notification_email {
# acassen@firewall.loc
# failover@firewall.loc
# sysadmin@firewall.loc
#}
#notification_email_from Alexandre.Cassen@firewall.loc
#smtp_server 192.168.137.1
#smtp_connect_timeout 30
router_id LVS_DS_IP
} vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.137.6
}
} virtual_server 192.168.137.6 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
persistence_timeout 0
protocol TCP real_server 192.168.137.100 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
} real_server 192.168.137.200 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
DS backup上的keepalived的配置文件:
[root@localhost ~]# cat /etc/keepalived/keepalived.conf
global_defs {
#notification_email {
# acassen@firewall.loc
# failover@firewall.loc
# sysadmin@firewall.loc
#}
#notification_email_from Alexandre.Cassen@firewall.loc
#smtp_server 192.168.137.1
#smtp_connect_timeout 30
router_id LVS_DS_IP
} vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 90
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.137.6
}
} virtual_server 192.168.137.6 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
persistence_timeout 0
protocol TCP real_server 192.168.137.100 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
} real_server 192.168.137.200 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
启动命令:
service keepalived start | stop
service lvsrs start | stop
查看DS上的keepalived是否配置成功:
tail -f /var/log/message
[root@localhost ~]# tail -f /var/log/messages
Feb :: localhost Keepalived_healthcheckers[]: Activating healthchecker for service [192.168.137.100]:
Feb :: localhost Keepalived_healthcheckers[]: Activating healthchecker for service [192.168.137.200]:
Feb :: localhost Keepalived_vrrp[]: VRRP_Instance(VI_1) Transition to MASTER STATE
Feb :: localhost Keepalived_vrrp[]: VRRP_Instance(VI_1) Received lower prio advert, forcing new election
Feb :: localhost Keepalived_healthcheckers[]: TCP connection to [192.168.137.200]: failed !!!
Feb :: localhost Keepalived_healthcheckers[]: Removing service [192.168.137.200]: from VS [192.168.137.6]:
Feb :: localhost Keepalived_vrrp[]: VRRP_Instance(VI_1) Entering MASTER STATE
Feb :: localhost Keepalived_vrrp[]: VRRP_Instance(VI_1) setting protocol VIPs.
Feb :: localhost Keepalived_vrrp[]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.137.6
Feb :: localhost Keepalived_healthcheckers[]: Netlink reflector reports IP 192.168.137.6 added
Feb :: localhost Keepalived_vrrp[]: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.137.6
查看分发配置:
[root@localhost ~]# ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.137.6:http wrr
-> 192.168.137.100:http Route 3 0 0
-> 192.168.137.200:http Route 3 3 0
[root@localhost ~]#
keepalived+LVS搭建高可用负载均衡系统的更多相关文章
- Keepalived+lvs 搭建高可用负载均衡
本站点停止更新,请访问:blog.coocap.com 不了解负载均衡高可用的童鞋,强烈建议先看keepalived+nginx高可用负载均衡: 传送门(求粉):http://www.cnblogs. ...
- Keepalived+HAProxy 搭建高可用负载均衡
转载自:https://mp.weixin.qq.com/s/VebiWftaRa26x1aA21Jqww 1. 概述 软件负载均衡技术是指可以为多个后端服务器节点提供前端IP流量分发调度服务的软件技 ...
- Keepalived+LVS(dr)高可用负载均衡集群的实现
一 环境介绍 1.操作系统CentOS Linux release 7.2.1511 (Core) 2.服务keepalived+lvs双主高可用负载均衡集群及LAMP应用keepalived-1.2 ...
- 【Linux运维-集群技术进阶】Nginx+Keepalived+Tomcat搭建高可用/负载均衡/动静分离的Webserver集群
额.博客名字有点长.. . 前言 最终到这篇文章了,心情是有点激动的. 由于这篇文章会集中曾经博客讲到的全部Nginx功能点.包含主要的负载均衡,还有动静分离技术再加上这篇文章的重点.通过Keepal ...
- Linux keepalived+lvs实现高可用负载均衡
LVS的具有强大的负载均衡功能,但是它缺少对负载层节点(DS)的健康状态检测功能,也不能对后端服务(RS)进行健康状态检测:keepalived是专门用来监控高可用集群架构的中各服务的节点状态,如果某 ...
- Keepalived+LVS实现高可用负载均衡双主模式
LVS是一种集群(Cluster)技术:采用IP负载均衡技术和基于内容请求分发技术.调度器具有很好的吞吐率,将请求均衡地转移到不同的服务器上执行,且调度器自动屏蔽掉服务器的故障,从而将一组服务器构成一 ...
- Keepalived+Haproxy搭建高可用负载均衡
Keepalived 简单的是一个路由的软件用C写的这个项目的主要目标是提供简单而强大的设施的负载均衡和高可用性对Linux系统和基于Linux的基础设施.负载均衡架构依赖于众所周知的和广泛使用的Li ...
- Nginx+Keepalived(双机热备)搭建高可用负载均衡环境(HA)
原文:https://my.oschina.net/xshuai/blog/917097 摘要: Nginx+Keepalived搭建高可用负载均衡环境(HA) http://blog.csdn.ne ...
- Nginx+Keepalived(双机热备)搭建高可用负载均衡环境(HA)-转帖篇
原文:https://my.oschina.net/xshuai/blog/917097 摘要: Nginx+Keepalived搭建高可用负载均衡环境(HA) http://blog.csdn.ne ...
随机推荐
- 如何彻底的卸载和删除Windows service
最近遇到很头疼的问题,安装到服务器的Windows Service卸载的时候出错了,结果在服务列表中就一直驻留,并且系统进程一直在运行,怎么都杀不掉. 最后终于找到办法了: 1.常规做法,批处理命令卸 ...
- [ORM] Entity Framework(2) CodeFirst进阶
在上一节中,实现了CodeFirst快速入门.但是很多与数据库的细节还无法自定义.以及使用EF过程中,需要注意的事项. 在本节中,会涉及到以下 EF中的连接字符串 EF的对象状态 延迟加载,为什么需要 ...
- Scrum团队
5.Scrum团队成立 5.1 团队名称,团队目标.团队口号.团队照: 团队名称:@four! 团队目标:做出像“数学口袋精灵”那么棒的软件 团队口号:多劳多得 团队照: 5.2 角色分配 产品负责人 ...
- 用Qt写软件系列四:定制个性化系统托盘菜单
导读 一款流行的软件,往往会在功能渐趋完善的时候,通过改善交互界面来提高用户体验.毕竟,就算再牛逼的产品,躲藏在糟糕的用户界面之后总会让用户心生不满.界面设计需综合考虑审美学.心理学.设计学等多因素, ...
- jQuery的 delegate问题
习惯了bind,用惯了live,就不习惯delegate了呀有木有... 支持为动态生成的标签元素绑定事件也许就live和delegate了吧,不过新版本已经不支持live了,只有delegate d ...
- AC自动机 - 关于Fail指针
fail指针可以说是AC自动机里最难理解的东西,怎样更好的理解AC自动机的fail指针? 先来看一幅图: 看这幅图上的fail指针是怎么构造的. 树上的词分别是: { he , hers , his ...
- C#设计模式——策略模式(Strategy Pattern)
一.概述我们来实现一个企业的工资系统,该企业中不同级别的员工工资算法都不相同,针对该问题,最容易想到的莫过于在代码中堆积一大堆if…else…语句或者是switch…case…语句.如果该企业中不同级 ...
- vmware安装mac
1.笔记本安装mac10.6 2.用VMware8,需要在mac.vmx中添加以下语句 guestOS = "darwin10"ich7m.present="TRUE&q ...
- Html5学习笔记(1)
1.figure\figcaption||detail\summary||mark学习笔记 效果图 代码为: <!DOCTYPE html> <html> <head&g ...
- Access数据库的常用数据类型和alter的用法
一.Access比较常用的数据类型:文本.备注.数字.日期/时间.货币 意思 Sql Access 1)文本 nvarchar(30) ...