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

相关推荐

  • 1019作业

    1019作业 柴震 软连接 硬连接 软连接和硬链接的区别 属性与定义: 硬链接:新建的文件是已经存在的文件的一个别名,所以创建时链接数递增;而且当原文件删除时,新建的链接文件仍然可以使用,因其直接对应于数据块。 软链接:也称为符号链接。新建的链接文件以“路径”的形式来表示另一个文件,其大小为指向的路径字符串的长度,不增加或减少目标文件in…

    Linux干货 2016-10-19
  • Linux之bash shell脚本编程入门篇(二)以及文件查找和压缩的使用

    bash shell脚本编程入门篇(二) read命令的使用 作用:     使用read来把输入值分配给一个或多个shell变量:         -p指定要显示的提示      &nbs…

    Linux干货 2016-08-18
  • linux进程管理

    linux系统进程查看及管理工具 对于服务器来说重要的IO 设备磁盘网络 pstree,ps,pidof,pgrep,top,htop,glances,pmap,vmstat,dstat,kill,pkill,job,bg,fg,nohup,nice,renice,killall….. pstree命令: pstree-display …

    Linux干货 2016-09-09
  • python分支循环和列表

    if语句 if condition: 代码块 condition必须是一个bool类型,这个地方有一个隐式转换bool(condition) if 1<2: print(‘1 less than 2’)   循环——while语句 while condition: block 当条件满足即condition为True,…

    2018-03-27
  • 初识Linux基础

    一:计算机的组成及其基本功能 计算机主要由五大基础部件组成:控制器,运算器,存储器,输入设备,输出设备. 控制器:计算机的核心组件,协调各程序的运行,对计算机的各项资源进行控制分配; 运算器:计算机实现算术运算以及逻辑运算的部件; 存储器:计算机用来存放数据和程序的基本部件。 存储器由若干存储单元组成,每个存储单元都有一个地址,计算机通过地址对存储单元进行读…

    Linux干货 2018-03-04
  • Linux手动编译源代码文件

    一、简介     Linux系统上程序包安装的方式多种多样,一般来说可通过rpm包安装、yum在线安装等方式实现。但有时候为了实现某种功能,而这种功能在通常情况下又不是太常用或是因为其他原因,不能通过yum下载安装或在网上没有找到rpm包,只是找到了程序安装包的源代码的话,这种情况下我们就可以对源代码直接进行编译安装,以便解决这种临时需求…

    Linux干货 2015-09-26