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 ...
随机推荐
- ORACEL12c求和SUM(a+b)与SUM(a)+SUM(b)结果不一致问题
今天在oracle12c数据库遇到的问题,下面重现一下: 1.先创建一个临时表 temp.一个数据表bitest_sum; -- Create table create table PEC.BITES ...
- django+celery+rabitmq
django 项目中的设置(proj代表项目目录) proj settings.py CELERY_BROKER_URL = 'amqp://guest:guest@localhost:5672/' ...
- sqlalchemy 映射的小例子
1.多张表映射到一个类 import pandas as pdfrom settings import DATABASESfrom sqlalchemy import create_engineimp ...
- linshi_temp_erweima_html_backup
<!doctype html><html><head><meta charset="utf-8"><meta content= ...
- POJ 1789 Truck History(Prim+邻接矩阵)
( ̄▽ ̄)" #include<iostream> #include<cstdio> #include<cstring> #include<algo ...
- java中的foreach输出数组中的元素
public class forEach { public static void main(String[]args){ String [] hobby = {"imooc",& ...
- 4、mybatis动态sql+struts2(通配符+全局配置+分页)
1.创建userinfo.sql数据库脚本 create table USERINFO ( id NUMBER not null, uname ), password ), age NUMBER ) ...
- 感知哈希算法 python 3.4
#!/usr/bin/python # -*- coding: UTF-8 -*- #Less than 10 add to list and sort import glob import os i ...
- jvm工具的使用
打开Java VisualVm->工具->插件 如图: 关于要填写的URL地址到 http://visualvm.java.net/pluginscenters.html 找到jdk版本 ...
- 观后感-MySQL索引类型 btree索引和hash索引的区别
http://www.cnblogs.com/osfipin/p/4943229.html.http://www.2cto.com/database/201411/351106.html-文章地址 首 ...