实验信息和拓扑:
备注:Centos 6.5 selinux –disabled iptables off

ServerName Ipaddress information
LVSMaster 172.16.100.10/24
LVSBackup 172.16.100.11/24
VIP 172.16100.200/24
RealServer1 172.16.100.100/24
RealServer2 172.16.100.101/24

  1. 配置lvs Master & lvs Backup

# yum install popt popt-devel popt-static libnl-devel libnl–y

# mkdir -p mkdir /usr/local/src/lvs

# cd /usr/local/src/lvs/

安装ipvsadm

# wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz

# tar zxvf ipvsadm-1.26.tar.gz

# make && make install && echo"install LVS ok"

安装keepalived

# wget http://www.keepalived.org/software/keepalived-1.2.13.tar.gz

# tar zxvf keepalived-1.2.13.tar.gz

# cd keepalived-1.2.13

# ./configure && make && make install && echo "installkeepalived ok" || echo "install keepalived is failed"

配置keepalived为启动脚本:

# cp /usr/local/etc/rc.d/init.d/keepalived  /etc/init.d/

# cp /usr/local/etc/sysconfig/keepalived  /etc/sysconfig/

# mkdir /etc/keepalived

# cp /usr/local/etc/keepalived/keepalived.conf  /etc/keepalived/

# cp /usr/local/sbin/keepalived  /usr/sbin/

LVS Backup 配置同上

Master keepalived.conf配置文件:

!Configuration File for keepalived

global_defs{

notification_email {

mengtao10@163.com

}

notification_email_from mengtao10@163.com

smtp_server 127.0.0.1

router_id LVS_DEVEL

}

vrrp_instanceVI_1 {

state MASTER

interface eth0

virtual_router_id 51

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass 1q2w3e4r5t6y

}

virtual_ipaddress {

172.16.100.200

}

}

virtual_server172.16.100.200 80 {

delay_loop 6

lb_algo wrr

lb_kind DR

persistence_timeout 60

protocol TCP

real_server 172.16.100.100 80 {

weight 3

TCP_CHECK {

connect_timeout 10

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

real_server 172.16.100.101 80 {

weight 3

TCP_CHECK {

connect_timeout 10

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

}

Lvs Backup配置文件:

! Configuration File for keepalived

global_defs{

notification_email {

mengtao10@163.com

}

notification_email_from mengtao10@163.com

smtp_server 127.0.0.1

router_id LVS_DEVEL

}

vrrp_instanceVI_1 {

state BACKUP

interface eth0

virtual_router_id 51

priority 99

advert_int 1

authentication {

auth_type PASS

auth_pass 1q2w3e4r5t6y

}

virtual_ipaddress {

172.16.100.200

}

}

virtual_server172.16.100.200 80 {

delay_loop 6

lb_algo wrr

lb_kind DR

persistence_timeout 60

protocol TCP

real_server 172.16.100.100 80 {

weight 3

TCP_CHECK {

connect_timeout 10

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

real_server 172.16.100.101 80 {

weight 3

TCP_CHECK {

connect_timeout 10

nb_get_retry 3

delay_before_retry 3

connect_port 80

}

}

}

两台realserver配置脚本如下:

#!/bin/bash

#

# Script to start LVS DR real server.

# description: LVS DR real server

#

. /etc/rc.d/init.d/functions

VIP=172.16.100.200

host=`/bin/hostname`

case "$1" in

start)

# Start LVS-DR real server on this machine.

/sbin/ifconfig lo down

/sbin/ifconfig lo up

echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore

echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce

echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore

echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce

/sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up

/sbin/route add -host $VIP dev lo:0

;;

stop)

# Stop LVS-DR real server loopback device(s).

/sbin/ifconfig lo:0 down

echo 0 > /proc/sys/net/ipv4/conf/lo/arp_ignore

echo 0 > /proc/sys/net/ipv4/conf/lo/arp_announce

echo 0 > /proc/sys/net/ipv4/conf/all/arp_ignore

echo 0 >/proc/sys/net/ipv4/conf/all/arp_announce

;;

status)

# Status of LVS-DR real server.

islothere=`/sbin/ifconfig lo:0 | grep $VIP`

isrothere=`netstat -rn | grep "lo:0" | grep $VIP`

if [ ! "$islothere" -o !"isrothere" ];then

# Either the route or the lo:0 device

# not found.

echo "LVS-DR real server Stopped."

else

echo "LVS-DR real server Running."

fi

;;

*)

# Invalid entry.

echo "$0: Usage: $0 {start|status|stop}"

exit 1

;;

esac

# sh realserver.sh  start

  1. 访问验证:

    1.任意关闭一台web服务器,服务都可以正常访问
    2.任意关闭一台lvs,服务都可以正常访问

本文出自 “Sword Slave” 博客,请务必保留此出处http://diudiu.blog.51cto.com/6371183/1568003

lvs + keepalived + httpd 高可用集群(转)的更多相关文章

  1. LVS+Keepalived实现高可用集群

    LVS+Keepalived实现高可用集群来源: ChinaUnix博客 日期: 2009.07.21 14:49 (共有条评论) 我要评论 操作系统平台:CentOS5.2软件:LVS+keepal ...

  2. 基于Keepalived实现LVS双主高可用集群

    Reference:  https://mp.weixin.qq.com/s?src=3&timestamp=1512896424&ver=1&signature=L1C7us ...

  3. Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群

    一.集群介绍 根据功能划分为两大类:高可用和负载均衡 高可用集群通常为两台服务器,一台工作,另外一台作为冗余,当提供服务的机器宕机,冗余将接替继续提供服务 实现高可用的开源软件有:heartbeat. ...

  4. Nginx(四):Keepalived+Nginx 高可用集群

    Keepalived+Nginx 高可用集群 (主从模式) 集群架构图 安装keepalived [root@localhost ~]# yum install -y keepalived 查看状态 ...

  5. 集群相关、用keepalived配置高可用集群

    1.集群相关 2.keepalived相关 3.用keepalived配置高可用集群 安装:yum install keepalived -y   高可用,主要是针对于服务器硬件或服务器上的应用服务而 ...

  6. lvs+keepalive构建高可用集群

    大纲 一.前言 二.Keepalived 详解 三.环境准备 四.LVS+Keepalived 实现高可用的前端负载均衡器 一.前言        Keepalived使用的vrrp协议方式,虚拟路由 ...

  7. 集群介绍 keepalived介绍 用keepalived配置高可用集群

    集群介绍 • 根据功能划分为两大类:高可用和负载均衡 • 高可用集群通常为两台服务器,一台工作,另外一台作为冗余,当提供服务的机器宕机,冗余将接替继续提供服务 • 实现高可用的开源软件有:heartb ...

  8. Keepalived+Nginx高可用集群

    Keepalived简介 Keepalived的作用是检测服务器的状态,如果有一台web服务器宕机,或工作出现故障,Keepalived将检测到,并将有故障的服务器从系统中剔除,同时使用其他服务器代替 ...

  9. keepalived+MySQL高可用集群

    基于keepalived搭建MySQL的高可用集群   MySQL的高可用方案一般有如下几种: keepalived+双主,MHA,MMM,Heartbeat+DRBD,PXC,Galera Clus ...

随机推荐

  1. 转:详解JMeter正则表达式(1)

    1.概览 JMeter中包含范本匹配软件Apache Jakarta ORO .在Jakarta网站上有一些关于它的文档,例如a summary of the pattern matching cha ...

  2. 如何在sublime中使用sass

    搞了好久,终于把sass搞定了. 最开始,我是想使用koala来实现对sass的实时编译的,但是每当我保存的时候,总是弹出erro错误,即无法编译生成css文件,百度了半天,问了好久,这个问题还是没能 ...

  3. Kali Rolling 下利用rtl-sdr跟踪飞机路线

    环境 kali rolling 状态:未升级发行版,仅用 "apt-get upgrade " 命令更新了软件 原料 RTL-SDR电视棒一个,芯片是RTL2832U 原理 我国民 ...

  4. 第八十七节,html5+css3pc端固定布局,大纲算法,section和div,结构分析

    html5+css3pc端固定布局,大纲算法,section和div,结构分析 一.大纲算法 在HTML5中有一个很重要的概念,叫做HTML5 大纲算法(HTML5Outliner),它的用途是为用户 ...

  5. HDU2124 Repair the Wall(贪心)

    Problem Description Long time ago , Kitty lived in a small village. The air was fresh and the scener ...

  6. POJ 1328 Radar Installation#贪心(坐标几何题)

    (- ̄▽ ̄)-* #include<iostream> #include<cstdio> #include<algorithm> #include<cmath ...

  7. hdu_5314_Happy King(树的点分治)

    题目链接:hdu_5314_Happy King 题意: 给出一颗n个结点的树,点上有权值: 求点对(x,y)满足x!=y且x到y的路径上最大值与最小值的差<=D: 题解: 还是树的点分治,在统 ...

  8. 大D实例化model-->调用自定义类方法,大M调用原声model方法

    class ContactsModel extends Model{ public function addxxx(){ } } $conmodel = D('contacts','Model'); ...

  9. 1、Web应用程序中的安全向量 -- XSS跨站脚本攻击

    XSS攻击(跨站脚本攻击)的概念: 用户通过网站页面的输入框植入自己的脚本代码,来获取额外的信息. XSS的实现方式: (1)通过用户将恶意的脚本命令输入到网站中,而这些网站又能够接收"不干 ...

  10. 利用yield关键字输出杨辉三角

    最近学习了下python,发现里面也有yield的用法,本来对C#里的yield不甚了解,但是通过学习python,对于C#的yield理解更深了!! 不多说了,小学生水平的表达能力伤不起.... 直 ...