测试LVS+Keepalived高可用负载均衡集群

1、 启动LVS高可用集群服务

此时查看Keepalived服务的系统日志信息如下:

[root@localhost ~]# tail -f /var/log/messages

Feb 28 10:01:56 localhost Keepalived: Starting Keepalived v1.1.19 (02/27,2011)

Feb 28 10:01:56 localhost Keepalived_healthcheckers: Netlink reflector reports IP 192.168.12.25 added

Feb 28 10:01:56 localhost Keepalived_healthcheckers: Opening file '/etc/keepalived/keepalived.conf'.

Feb 28 10:01:56 localhost Keepalived_healthcheckers: Configuration is using : 12063 Bytes

Feb 28 10:01:56 localhost Keepalived: Starting Healthcheck child process, pid=4623

Feb 28 10:01:56 localhost Keepalived_vrrp: Netlink reflector reports IP 192.168.12.25 added

Feb 28 10:01:56 localhost Keepalived: Starting VRRP child process, pid=4624

Feb 28 10:01:56 localhost Keepalived_healthcheckers: Activating healtchecker for service [192.168.12.246:80]

Feb 28 10:01:56 localhost Keepalived_vrrp: Opening file '/etc/keepalived/keepalived.conf'.

Feb 28 10:01:56 localhost Keepalived_healthcheckers: Activating healtchecker for service [192.168.12.237:80]

Feb 28 10:01:57 localhost Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE

Feb 28 10:01:58 localhost Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE

Feb 28 10:01:58 localhost Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.

Feb 28 10:01:58 localhost Keepalived_healthcheckers: Netlink reflector reports IP 192.168.12.135 added

Feb 28 10:01:58 localhost avahi-daemon[2778]: Registering new address record for 192.168.12.135 on eth0.

2、 高可用性功能测试

高可用性是通过LVS的两个Director Server完成的,为了模拟故障,我们先将主Director Server上面的Keepalived服务停止,然后观察备用Director Server上Keepalived的运行日志,信息如下:

Feb 28 10:08:52 lvs-backup Keepalived_vrrp: VRRP_Instance(VI_1) Transition to MASTER STATE

Feb 28 10:08:54 lvs-backup Keepalived_vrrp: VRRP_Instance(VI_1) Entering MASTER STATE

Feb 28 10:08:54 lvs-backup Keepalived_vrrp: VRRP_Instance(VI_1) setting protocol VIPs.

Feb 28 10:08:54 lvs-backup Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.12.135

Feb 28 10:08:54 lvs-backup Keepalived_vrrp: Netlink reflector reports IP 192.168.12.135 added

Feb 28 10:08:54 lvs-backup Keepalived_healthcheckers: Netlink reflector reports IP 192.168.12.135 added

Feb 28 10:08:54 lvs-backup avahi-daemon[3349]: Registering new address record for 192.168.12.135 on eth0.

Feb 28 10:08:59 lvs-backup Keepalived_vrrp: VRRP_Instance(VI_1) Sending gratuitous ARPs on eth0 for 192.168.12.135

从日志中可以看出,主机出现故障后,备机立刻检测到,此时备机变为MASTER角色,并且接管了主机的虚拟IP资源,最后将虚拟IP绑定在eth0设备上。

接着,重新启动主Director Server上的Keepalived服务,继续观察备用Director Server的日志状态:

备用Director Server的日志状态:

Feb 28 10:12:11 lvs-backup Keepalived_vrrp: VRRP_Instance(VI_1) Received higher prio advert
Feb 28 10:12:11 lvs-backup Keepalived_vrrp: VRRP_Instance(VI_1) Entering BACKUP STATE
Feb 28 10:12:11 lvs-backup Keepalived_vrrp: VRRP_Instance(VI_1) removing protocol VIPs.
Feb 28 10:12:11 lvs-backup Keepalived_vrrp: Netlink reflector reports IP 192.168.12.135 removed
Feb 28 10:12:11 lvs-backup Keepalived_healthcheckers: Netlink reflector reports IP 192.168.12.135 removed
Feb 28 10:12:11 lvs-backup avahi-daemon[3349]: Withdrawing address record for 192.168.12.135 on eth0.

3、 负载均衡测试

这里假定两个real server节点配置www服务的网页文件根目录均为/webdata/www目录,然后分别执行如下操作:

在real  server1 执行:

echo "This is real server1"  /webdata/www/index.html

在real  server2 执行:

echo "This is real server2" /webdata/www/index.html

接着打开浏览器,访问http://192.168.12.135这个地址,然后不断刷新此页面,如果能分别看到“This is real server1”和“This is real server2”就表明LVS已经在进行负载均衡了。

4、 故障切换测试

故障切换是测试当某个节点出现故障后,Keepalived监控模块是否能及时发现,然后屏蔽故障节点,同时将服务转移到正常节点来执行。

这里我们将real server 1节点服务停掉,假定这个节点出现故障,然后查看主、备机日志信息,相关日志如下:

Feb 28 10:14:12 localhost Keepalived_healthcheckers: TCP connection to [192.168.12.246:80] failed !!!
Feb 28 10:14:12 localhost Keepalived_healthcheckers: Removing service [192.168.12.246:80] from VS [192.168.12.135:80]
Feb 28 10:14:12 localhost Keepalived_healthcheckers: Remote SMTP server [192.168.12.1:25] connected.
Feb 28 10:14:12 localhost Keepalived_healthcheckers: SMTP alert successfully sent.

从日志可知,Keepalived监控模块检测到192.168.12.246这台主机恢复正常后,又将此节点加入了集群系统中。

此时再次访问http://192.168.12.135这个地址,然后不断刷新此页面,应该又能分别看到“This is real server1”和“This is real server2”页面了,这说明在real server 1节点恢复正常后,Keepalived监控模块将此节点加入了集群系统中。

至此LVS集群搭建和测试完成!

.

.

.

本文摘自华章教育!

测试LVS+Keepalived高可用负载均衡集群的更多相关文章

  1. LVS+Keepalived高可用负载均衡集群架构实验-01

    一.为什么要使用负载均衡技术? 1.系统高可用性 2.  系统可扩展性 3.  负载均衡能力 LVS+keepalived能很好的实现以上的要求,LVS提供负载均衡,keepalived提供健康检查, ...

  2. 配置LVS + Keepalived高可用负载均衡集群之图文教程

    负载均衡系统可以选用LVS方案,而为避免Director Server单点故障引起系统崩溃,我们可以选用LVS+Keepalived组合保证高可用性.  重点:每个节点时间都同步哈! C++代码 [r ...

  3. Ubuntu构建LVS+Keepalived高可用负载均衡集群【生产环境部署】

    1.环境说明: 系统版本:Ubuntu 14.04 LVS1物理IP:14.17.64.2   初始接管VIP:14.17.64.13 LVS2物理IP:14.17.64.3   初始接管VIP:14 ...

  4. Keepalived+LVS(dr)高可用负载均衡集群的实现

    一 环境介绍 1.操作系统CentOS Linux release 7.2.1511 (Core) 2.服务keepalived+lvs双主高可用负载均衡集群及LAMP应用keepalived-1.2 ...

  5. Dubbo入门到精通学习笔记(十四):ActiveMQ集群的安装、配置、高可用测试,ActiveMQ高可用+负载均衡集群的安装、配置、高可用测试

    文章目录 ActiveMQ 高可用集群安装.配置.高可用测试( ZooKeeper + LevelDB) ActiveMQ高可用+负载均衡集群的安装.配置.高可用测试 准备 正式开始 ActiveMQ ...

  6. Heartbeat+LVS构建高可用负载均衡集群

    1.heartbeat简介: Heartbeat 项目是 Linux-HA 工程的一个组成部分,它实现了一个高可用集群系统.心跳服务和集群通信是高可用集群的两个关键组件,在 Heartbeat 项目里 ...

  7. LVS+Keepalived搭建MyCAT高可用负载均衡集群

    LVS+Keepalived 介绍 LVS LVS是Linux Virtual Server的简写,意即Linux虚拟服务器,是一个虚拟的服务器集群系统.本项目在1998年5月由章文嵩博士成立,是中国 ...

  8. Linux 笔记 - 第十八章 Linux 集群之(三)Keepalived+LVS 高可用负载均衡集群

    一.前言 前两节分别介绍了 Linux 的高可用集群和负载均衡集群,也可以将这两者相结合,即 Keepalived+LVS 组成的高可用负载均衡集群,Keepalived 加入到 LVS 中的原因有以 ...

  9. LVS+Keepalived 实现高可用负载均衡集群

    LVS+Keepalived  实现高可用负载均衡集群     随着网站业务量的增长,网站的服务器压力越来越大?需要负载均衡方案!商业的硬件如 F5 ,Array又太贵,你们又是创业型互联公司如何有效 ...

随机推荐

  1. gym923B

    Even though he isn't a student of computer science, Por Costel the pig has started to study Graph Th ...

  2. [转]REST简介

    转自:http://www.cnblogs.com/loveis715/p/4669091.html 一说到REST,我想大家的第一反应就是“啊,就是那种前后台通信方式.”但是在要求详细讲述它所提出的 ...

  3. 系统间通信(9)——通信管理与RMI 下篇

    接上文<架构设计:系统间通信(8)--通信管理与RMI 上篇>.之前说过,JDK中的RMI框架在JDK1.1.JDK1.2.JDK1.5.JDK1.6+几个版本中做了较大的调整.以下我们讨 ...

  4. 扩展html 无边框的input 边框

    public static class HtmlHelper { /// <summary> /// 返回没有边框的只读的TextBox标签 /// </summary> // ...

  5. random模块

    如下 #!/usr/bin/env python # encoding: utf-8 import sys import platform print (platform.python_version ...

  6. Arraylist Vector Linkedlist区别和用法 (转)

    ArrayList 和Vector是采用数组方式存储数据,此数组元素数大于实际存储的数据以便增加和插入元素,都允许直接序号索引元素,但是插入数据要设计到数组元素移动等内存操作,所以索引数据快插入数据慢 ...

  7. Leetcode 300 Longest Increasing Subsequence

    Given an unsorted array of integers, find the length of longest increasing subsequence. For example, ...

  8. Leetcode 77, Combinations

    Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For exampl ...

  9. TYVJ1982 武器分配

    描述     后勤部队运来一批武器(机枪和盔甲).你要把这些武器分配给手下的marine们(每人一部机枪,一套盔甲).可是问题来了...    这些武器的型号不相同(武器是由出价最低的承包商制造的), ...

  10. POJ 3662 Telephone Lines(二分+最短路)

    查看题目 最小化第K大值. 让我怀疑人生的一题目,我有这么笨? #include <cstdio> #include <queue> #include <cstring& ...