lvs + keepalived + httpd 高可用集群(转)

实验信息和拓扑:
备注: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 {

[email protected]

}

notification_email_from [email protected]

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 {

[email protected]

}

notification_email_from [email protected]

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

时间: 2024-10-10 20:11:23

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

lvs+keepalived+httpd高可用集群

实验环境 (1)本次基于VMware Workstation搭建一个四台Linux(CentOS 7.4)系统所构成的一个服务器集群,其中两台负载均衡服务器(一台为主机,另一台为备机),另外两台作为真实的Web服务器(向外部提供http服务,这里仅仅使用了CentOS默认自带的http服务,没有安装其他的类似Tomcat.Jexus服务). (2)本次实验基于DR负载均衡模式,设置了一个VIP(Virtual IP)为172.18.38.99,用户只需要访问这个IP地址即可获得网页服务.其中,负

lvs + keepalived + httpd 高可用集群

实验信息和拓扑:备注: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 配置lvs Master & lvs Backup # y

LVS+Keepalived实现高可用集群

Keepalived + LVS 1.操作环境 操作系统平台:CentOS6.5 软件:keepalived-1.2.12.tar.gz Ipvsadm使用yum自带的安装 2.原理技术 LVS提 供负载均衡,keepalived提供健康检查,故障转移,提高系统的可用性!采用这样的架构以后很容易对现有系统进行扩展,只要在后端添加或者减少realserver,只要更改lvs的配置文件即可.Keepalived在这里主要用作RealServer的健康状态检查以及master主机和backup主机之间

lvs+keepalived配置高可用集群

说明: 上周使用keepalived实现了mysql主主同步的高可用,借着刚研究了keepalived,顺便把lvs集群搞一下 参考文档: lvs集群简介:http://732233048.blog.51cto.com/9323668/1617201 LVS.Nginx和HAProxy负载均衡区别:http://732233048.blog.51cto.com/9323668/1623375 环境: 前段LB 后端web 底端共享存储 vip (主)192.168.186.132 (R1)192

lvs+keepalived部署高可用集群

本环境基于centos7部署,基本架构图: client ip: 192.168.1.101 lvs1 ip: 192.168.1.173 lvs2 ip: 192.168.1.110 web1: 192.168.1.114 web2: 192.168.1.119 VIP: 192.168.1.10 部署流程: lvs1: # yum install ipvsadm # ipvsadm    #查看是否输出安装成功 # yum install keepalived # vim /etc/keep

keepalived实现高可用集群方案

一.keepalived和VRRP协议介绍 keepalived是基于vrrp协议实现的一个高可用集群解决方案,可以利用keepalived来解决单点故障问题,使用keepalived实现的高可用集群方案中,一般有两台服务器,一个是MASTER(主服务器),另一个是BACKUP(备用服务器),这个集群中对外提供一个虚拟IP,MASTER服务器会定时发送特定信息给BACKUP服务器,当BACKUP服务器接收不到MASTER发送的消息时,BACKUP服务器会接管虚拟IP,继续提供服务. VRRP协议

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

前言 前面说过基于heartbeat的LVS高可用方案,今天带来另一种解决方案:基于Keepalived实现LVS双主高可用集群.什么是Keepalived呢,keepalived观其名可知,保持存活,在网络里面就是保持在线了, 也就是所谓的高可用或热备,用来防止单点故障的发生.本文将详细讲述Keepalived工作原理及高可用解决方案的实现. 相关介绍 Keepalived简介 Keepalived采用VRRP(virtual router redundancy protocol,虚拟路由冗余

基于Keepalived构建高可用集群配置实例(HA Cluster)

什么是集群 简单的讲集群(cluster)就是一组计算机,它们作为一个整体向用户提供一组网络资源.这些单个的计算机系统就是集群的节点(node).一个理想的集群是,用户从来不会意识到集群系统底层的节点,在他/她们看来,集群是一个系统,而非多个计算机系统.并且集群系统的管理员可以随意增加和删改集群系统的节点. 关于更详细的高可用集群我们在后面再做详解,先来说说Keepalived Keepalived是什么 Keepalived是集群管理中保证集群高可用的一个服务软件,其功能类似于heartbea

18.1 集群介绍;18.2 keepalived介绍;18.3,18.4,18.5 用keepalived配置高可用集群(上,中,下);

18.1 集群介绍 1. 根据功能划分为两大类:高可用和负载均衡 2. 高可用集群通常为两台服务器,一台工作,另外一台作为冗余,当提供服务的机器宕机,冗余将接替继续提供服务 3. 实现高可用的开源软件有:heartbeat.keepalived 负载均衡集群,需要有一台服务器作为分发器,它负责把用户的请求分发给后端的服务器处理,在这个集群里,除了分发器外,就是给用户提供服务的服务器了,这些服务器数量至少为2 4. 实现负载均衡的开源软件有LVS.keepalived.haproxy.nginx,