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
# 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.任意关闭一台web服务器,服务都可以正常访问
2.任意关闭一台lvs,服务都可以正常访问
本文出自 “Sword Slave” 博客,请务必保留此出处http://diudiu.blog.51cto.com/6371183/1568003
lvs + keepalived + httpd 高可用集群(转)的更多相关文章
- LVS+Keepalived实现高可用集群
LVS+Keepalived实现高可用集群来源: ChinaUnix博客 日期: 2009.07.21 14:49 (共有条评论) 我要评论 操作系统平台:CentOS5.2软件:LVS+keepal ...
- 基于Keepalived实现LVS双主高可用集群
Reference: https://mp.weixin.qq.com/s?src=3×tamp=1512896424&ver=1&signature=L1C7us ...
- Linux centosVMware 集群介绍、keepalived介绍、用keepalived配置高可用集群
一.集群介绍 根据功能划分为两大类:高可用和负载均衡 高可用集群通常为两台服务器,一台工作,另外一台作为冗余,当提供服务的机器宕机,冗余将接替继续提供服务 实现高可用的开源软件有:heartbeat. ...
- Nginx(四):Keepalived+Nginx 高可用集群
Keepalived+Nginx 高可用集群 (主从模式) 集群架构图 安装keepalived [root@localhost ~]# yum install -y keepalived 查看状态 ...
- 集群相关、用keepalived配置高可用集群
1.集群相关 2.keepalived相关 3.用keepalived配置高可用集群 安装:yum install keepalived -y 高可用,主要是针对于服务器硬件或服务器上的应用服务而 ...
- lvs+keepalive构建高可用集群
大纲 一.前言 二.Keepalived 详解 三.环境准备 四.LVS+Keepalived 实现高可用的前端负载均衡器 一.前言 Keepalived使用的vrrp协议方式,虚拟路由 ...
- 集群介绍 keepalived介绍 用keepalived配置高可用集群
集群介绍 • 根据功能划分为两大类:高可用和负载均衡 • 高可用集群通常为两台服务器,一台工作,另外一台作为冗余,当提供服务的机器宕机,冗余将接替继续提供服务 • 实现高可用的开源软件有:heartb ...
- Keepalived+Nginx高可用集群
Keepalived简介 Keepalived的作用是检测服务器的状态,如果有一台web服务器宕机,或工作出现故障,Keepalived将检测到,并将有故障的服务器从系统中剔除,同时使用其他服务器代替 ...
- keepalived+MySQL高可用集群
基于keepalived搭建MySQL的高可用集群 MySQL的高可用方案一般有如下几种: keepalived+双主,MHA,MMM,Heartbeat+DRBD,PXC,Galera Clus ...
随机推荐
- day23 框架之基础加强
day23 框架之基础加强 今日任务 aptana(javascript的eclipse插件):http://www.cnblogs.com/terrylin/archive/2012/06/20/2 ...
- SQLSERVER异机备份
/* 作者:landv 功能:异机备份 开发时间:2016年7月2日 15:27:08 */ ) drop procedure [dbo].[p_backupdb] GO create proc p_ ...
- magento数据添加
1.第一种方法是一个字段一个字段地添加! $record = Mage::getModel('warehouse/record'); $record->addData($postDat ...
- java中的日期处理
学习Java日期处理,看见这一篇比较详细,转载之. 转自:http://www.cnblogs.com/hqr9313/archive/2012/04/19/2458221.html 时间日期1) ...
- cmstop核心
控制器在什么时候实例化? ---每发送一次请求,都要从入口文件开始一步步往下走 index.php入口文件-->到第二个文件(核心文件cmstop.php)中实例化controller类核心文 ...
- digitalocean完成B轮8300万美元融资,赠送10美元优惠码
7月8日,美国vps服务商digitalocean在官方博客宣传,公司完成高达8300万美元B轮融资.融资方包括 IA Ventures, Andreessen Horowitz和Access Ind ...
- LINQ的Any() 方法
Enumerable.Any 方法 确定序列中的任何元素是否存在或满足条件.
- 【FBA】SharePoint 2013自定义Providers在基于表单的身份验证(Forms-Based-Authentication)中的应用
//http://www.cnblogs.com/OceanEyes/p/custom-provider-in-sharepoint-2013-fba-authentication.html 由于项目 ...
- epoll详解
转自:http://blog.chinaunix.net/uid-24517549-id-4051156.html 什么是epoll epoll是什么?按照man手册的说法:是为处理大批量句柄而作了改 ...
- redis数据类型:hashes
redis hash 是一个string类型的field和value的映射表. 它的添加.删除操作都是O(1)(平均),hash特别适合用于存储对象 将一个对象存储在hash类型总会占用更少的内存,并 ...