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 21:34
下一篇 2018-03-11 21:40

相关推荐

  • Linux的文件压缩、解压之tar的使用

    文件的压缩   一、压缩、解压缩及归档工具 压缩 解压 后缀(压缩后) file-roller 图形操作界面上的使用(略) compress 解压一:uncompress 或compress -d (注:使用上面的解压命令,实际上是在屏幕上打印解压的文件信息,并不是真正上解压到文件,所以需要在命令后面加上“重定向到指定的文件中”,方可完成解压。如:…

    Linux干货 2016-08-18
  • nfs,samba同步LAMP与Mysql

    使用nfs功能实现WEB页面同步     拓扑图见NFS实现LAMP冗余:     目的:使用网络文件系实现LAMP的分步式资源共享    配置步骤:    配置test1:搭建NFS环境:&nbsp…

    2017-04-26
  • 内核参数修改 内核编译 第14天

    Linux内核:单内核,模块化 内核的某些模块 编译进内核本体 [*] 编译成内核模块 [M] 不选择使用     [ ] 内核的组成部分 /boot/vmlinuz-VERSION /lib/modules/VERSION/ *.ko 模块间有可能有依赖关系 内核模块管理 lsmod:显…

    Linux干货 2016-01-18
  • Linux三剑客awk命令

    1 .awk是一个强大的文本分析工具,相对于grep的查找,sed的编辑,awk在其对数据分析并生成报告时,显得尤为强大。简单来说awk就是把文件逐行的读入,以空格为默认分隔符将每行切片,切开的部分再进行各种分析处理。 awk有3个不同版本: awk、nawk和gawk,未作特别说明,一般指gawk,gawk 是 AWK 的 GNU 版本。 awk其名称得自…

    2017-09-08
  • linux中rpm命令的妙用

    linux中rpm命令的妙用 CentOS系统上使用rpm命令管理程序包: 安装、卸载、升级、查询、校验、数据库维护 安装:         rpm {-i|–install} [install-options] PACKAGE_FILE…    …

    Linux干货 2016-08-24
  • 将两个局域网用openvpn连接起来

    考虑到我们做集群的时候需要用到可能有20台机器,可能我的要求跟别人的不一样的,我需要做20台左右的集群,不仅仅是会,而且需要非常熟练的搭建,最后通过脚步一键自动化部署安装。 目前我有两台电脑,一台可以运行7台,另一台可以运行12台左右,刚好可以满足的我的要求,但是我两台电脑都是设置的nat模式的网络,为什么我非要配置nat模式呢,根据集群架构思想,为了保证架…

    Linux干货 2017-05-01