keepalived(主主) 结合lvs(dr工作 模式) 实现高可用性。

keepalived(主主) 结合lvs(dr工作 模式) 实现高可用性。

client: 192.168.100.6
————————————————-

#for i in {1..10};do sleep 0.5;curl 192.168.100.200;done

proxy1: 192.168.100.7
————————————————–
vim /etc/keepalived/keepalived.conf –配置文件
vrrp_instance VI_1 { –主
state MASTER
interface eth1
virtual_router_id 66
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.100.100/24
}
notify_master “/etc/keepalived/notify.sh master”
notify_backup “/etc/keepalived/notify.sh backup”
notify_fault “/etc/keepalived/notify.sh fault”
}
#lvs-dr
virtual_server 192.168.100.100 80 {
delay_loop 6
lb_algo rr
lb_kind DR
# persistence_timeout 50
protocol TCP
sorry_server 127.0.0.1 80

real_server 192.168.100.27 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.100.37 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
# ——lingwai de yige cong—————————–
vrrp_instance VI_2 { –从
state BACKUP
interface eth1
virtual_router_id 88
priority 80
advert_int 1
authentication {
auth_type PASS
auth_pass 54321
}
virtual_ipaddress {
192.168.100.200/24
}
notify_master “/etc/keepalived/notify.sh master”
notify_backup “/etc/keepalived/notify.sh backup”
notify_fault “/etc/keepalived/notify.sh fault”
}
#lvs-dr
virtual_server 192.168.100.200 80 {
delay_loop 6
lb_algo rr
lb_kind DR
# persistence_timeout 50
protocol TCP
sorry_server 127.0.0.1 80

real_server 192.168.100.28 80 {
weight 1
HTTP_GET {
url {
path /
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.100.38 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

proxy2: 192.168.100.17
————————————————–
vim /etc/keepalived/keepalived.conf
vrrp_instance VI_1 {
state BACKUP
interface eth1
virtual_router_id 66
priority 80
advert_int 1
authentication {
auth_type PASS
auth_pass 123456
}
virtual_ipaddress {
192.168.100.100/24
}
notify_master “/etc/keepalived/notify.sh master”
notify_backup “/etc/keepalived/notify.sh backup”
notify_fault “/etc/keepalived/notify.sh fault”
}

virtual_server 192.168.100.100 80 {
delay_loop 6
lb_algo rr
lb_kind DR
# persistence_timeout 50
protocol TCP
sorry_server 127.0.0.1 80

real_server 192.168.100.27 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.100.37 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
# ——lingwai de yige zu—————————–
vrrp_instance VI_2 {
state MASTER
interface eth1
virtual_router_id 88
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 54321
}
virtual_ipaddress {
192.168.100.200/24
}
notify_master “/etc/keepalived/notify.sh master”
notify_backup “/etc/keepalived/notify.sh backup”
notify_fault “/etc/keepalived/notify.sh fault”
}
virtual_server 192.168.100.200 80 {
delay_loop 6
lb_algo rr
lb_kind DR
# persistence_timeout 50
protocol TCP
sorry_server 127.0.0.1 80

real_server 192.168.100.28 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 192.168.100.38 80 {
weight 1
HTTP_GET {
url {
path /
status_code 200
}
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}

自测试:
#curl 192.168.100.37
192.168.100.100 RS2
#curl 192.168.100.38
192.168.100.200 RS2

自测试:
curl 192.168.100.27
192.168.100.100 RS1 –网站内容
curl 192.168.100.28
192.168.100.200 RS1

 

测试用户:
for i in {1..1000};do sleep 0.5;curl 192.168.100.200;curl 192.168.100;100;done
宕机 proxy1
killall -9 keepalived

访问不受影响 .

小结2 : 宕机 RS1
for i in {1..1000};do sleep 0.5;curl 192.168.100.200;curl 192.168.100;100;done
影响2 3 秒 。

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/92090

(1)
百涧溪百涧溪
上一篇 2018-03-11
下一篇 2018-03-11

相关推荐

  • windows server 2008 r2 每隔一段时间自动关机

    首先来说一下我的狗血经历:     话说作为一个地铁汪,每天背着电脑从房山到朝阳那简直就是能累死我的节奏,所以我跟公司申请我不要用自己的笔记本了(补助我不要了)。最后公司把一台不用的server 2008r2给我用,12G内存,志强CPU,跑虚拟机杠杠的。 但是噩梦开始了,我发现一个特点,这台server 2008 r…

    2015-11-26
  • 马哥教育网络班第21期+第五周课程作业

    1、 显示/boot/grub/grub.conf中以至少一个空白字符开头的行; [root@redhat6 ~]# grep '^[[:space:]]\+' /boot/grub/grub.conf   2、显示/etc/rc.d/rc.sysinit文件中以#开头,后面跟至少一个空白字符,而后又有至少一个非空白字符的…

    Linux干货 2016-08-08
  • N25期—第五周作业

    1、 显示当前系统上root、fedora或user1用户的默认shell; grep -E "^(root|fedora|user1):" /etc/passwd | cut -d: -f7 2、找出/etc/rc.d/init.d/functions文件中某单词后面…

    Linux干货 2017-01-02
  • 三台主机部署phpwind

    PHPWind(简称:PW)的使命是让网站更具价值,让更多人从网络中享受便利,以提升生活品质。 phpwind是一个基于PHP和MySQL的开源社区程序,是国内最受欢迎的通用型论坛程序之一。phpwind第一个版本ofstar发布于2004年。截止2013年12月phpwind项目品牌由阿里云计算有限公司拥有,软件全面开源免费。 特点 1. 非凡的访问速度 …

    2017-06-13
  • httpd功能配置之https

       HTTPS(全称:Hyper Text Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版。即HTTP下加入SSL层,HTTPS的安全基础是SSL,因此加密的详细内容就需要SSL。HTTPS使用443端口进行通信。    …

    Linux干货 2016-03-13
  • http

    http 笔记整理

    Linux干货 2018-01-31