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

相关推荐

  • 【N25第一周作业】Linux上命令的使用格式和基础命令详解

    一、Linux上命令的使用格式 命令行提示符详解: 用户通过终端的命令行接口来控制操作系统,登陆后如下: [root@localhost ~]# root: 当前登录的用户 @:分隔符 localhost: 当前主机的主机名,非完整格式;此处的完整格式为:localhost.localdomain [root@localhost ~]#&…

    Linux干货 2016-12-03
  • 第九周作业

    1. 写一个脚本,判断当前系统上所有用户的shell是否为可登录shell(即用户的shell不是/sbin/nologin);分别这两类用户的个数;通过字符串比较来实现; # awk -F: ‘{if($7!=”/sbin/nologin”) {printf “Logined user %s\n”…

    Linux干货 2017-03-01
  • 8/10作业脚本

    1、编写脚本/root/bin/systeminfo.sh,显示当前主机系统信息,包括主机名,IPv4地址,操作系统版本,内核版本,CPU型号,内存大小,硬盘大小。 2、编写脚本/root/bin/backup.sh,可实现每日将/etc/目录备份到/root/etcYYYY-mm-dd中 3、编写脚本/root/bin/disk.sh,显示当前硬盘分区中空…

    Linux干货 2016-08-15
  • nginx配置文件中文文档

    Nginx配置参数中文说明。 #定义Nginx运行的用户和用户组user www www; #nginx进程数,建议设置为等于CPU总核心数。worker_processes 8; #全局错误日志定义类型,[ debug | info | notice | warn | error | crit ]error_log /var/log/nginx/error…

    Linux干货 2017-08-08
  • python 多版本管理(pyenv)

    01 – Python 简介和安装 01 – Python 简介和安装 1. Python 简介 2. 安装 pyenv 3. pyenv 使用 4. pyenv-virtualenv 5. 安装 IPython 和 Jupyter 01 – Python 简介和安装 1. Python 简介 编程风格 面向过程:以指令为…

    Linux干货 2016-07-10
  • 马哥教育网络班26期+第一周学习宣言

    30岁前,目标年薪50w!gogogo

    Linux干货 2016-12-27