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

相关推荐

  • 关于加密那点事

    作者【Jev Tse】 环境:sentos6.8     【本文预览】      一、关于加密      二、对称加密      三、非对称加密      四、单向散列 …

    Linux干货 2016-12-01
  • vim文本编辑器小结

    vi=vim打开文件 alias vi =vim vim -m 只读方式打开文件 修改文件时则会无法保存   -b 二进制打开文件 -d file1 file2  比较两个文件 Command(normal)默认模式:  ZZ 保存并退出 ZQ 不保存并退出Insert:编辑模式&nbsp…

    2017-08-05
  • Trap命令简介

     Trap命令简介     一、基本概念  trap是一个shell内建命令,它用来在脚本中指定信号如何处理。比如,按Ctrl+C会使脚本终止执行,实际上系统发送了SIGINT信号给脚本进程,SIGINT信号的默认处理方式就是退出程序。如果要在Ctrl +C不退出程序,那么就得使用trap命令来指定一下SIGINT的处…

    Linux干货 2015-05-11
  • 高可用keepalived+haproxy实现动静分离

    高可用keepalived+haproxy: 实验环境: clientIP为:172.18.254.149 VIRROUTEIP为:172.18.61.5 keepalived+haproxy机器1IP为172.18.61.1 keepalived+haproxy机器2IP为172.18.61.2 server1IP为172.18.61.3 server2I…

    2017-05-17
  • Linux命令学习

    阅读目录 Linux cat命令 file命令 dd命令 hexdump命令 cat命令   cat三大功能:      1.一次显示整个文件:cat filename      2.从键盘创建一个文件:cat > filename 注意只能创建新文件,…

    Linux干货 2017-07-16
  • for,while,until简介

    Shell(以Bash为例)中的循环语句一般有for、while、until这几种,偶尔还有写错语法的时候,这里结合实例来自己总结一下。也为今后使用提供一个快捷的资料获取渠道。 一、for循环语句 实例1.1 最基本的for循环: (传统的形式,for var in …) 代码如下: #!/bin/bashfor x in one two three fou…

    Linux干货 2016-08-22