实验信息和拓扑:
备注: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. 关于STM32的IO口速率问题

    输入模式可以不用配置速度,但是输出模式必须确定最大输出频率.当STM32的GPIO端口设置为输出模式时,有三种速度可以选择:2MHz.10MHz和50MHz,这个速度是指I/O口驱动电路的速度,是用来 ...

  2. HomeBrew 安装 PHP7.1(开发笔记)

    HomeBrew 安装 PHP7.1 $ brew update $ brew tap homebrew/dupes $ brew tap homebrew/php $ brew update $ b ...

  3. NYIST OJ 题目42 一笔画问题

    水题.无向图欧拉通路的判定.用并查集判定是不是连通图! #include<cstdio> #include<cstring> #include<cmath> #in ...

  4. ubuntu下pip install mysql-python 失败的解决方案

    ubuntu连接mysql 需要安装mysql-python 出现can not find mysql-config 文件错误 先安装 sudo apt-get install libmysqld-d ...

  5. dubbo 的monitor监视器安装问题——————monitor一直处于正在启动状态

    一台服务器安装完zookeeper并启动后,然后在另一服务器安装monitor     dubbo-monitor-simple-2.8.3  解压安装 修改配置文件 dubbo.container= ...

  6. 【Python】@property的用法

    设想我们要给一个student()类的一个实例s,添加一个score的属性,比如: s.score=999999 这个值明显是不合理的,但是它却是可行的,怎么能改变这种情况?我们能想到的就是用类方法 ...

  7. hdu_5889_Barricade(最小割+最短路)

    题目链接:hdu_5889_Barricade 题意: 有n个点,m条边,每个边的长度都为1,每个边有一个消耗w,如果要阻断这条路,那么就会消耗w,现在让你阻断点1到点n的所有最短路,问你最小的消耗是 ...

  8. PHP中使用CURL(二)

    https不需要进行ca认证和证书中域名认证 curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false); curl_setopt($ch,CURLOPT_SSL_VE ...

  9. MVC中发生System.Data.Entity.Validation.DbEntityValidationException验证异常的解决方法

    发生System.Data.Entity.Validation.DbEntityValidationException这个异常的时候,如果没有用特定的异常类去捕捉,是看不到具体信息的. 通常都是用Sy ...

  10. poj 1687 Buggy Sat 简单计算几何

    暑期集训出的第一道一血 感觉自己萌萌哒…… 这道题本身并没有坑点 仅仅是翻译巨坑…… 解大腿在做B 安学长在做E 我闲着也没事 就一个词一个词翻译F…… 最后感觉…… 题干大多数都看不懂…… 也都没啥 ...