系统 CentOS 5.6 X64
物理机 IP 10.10.10.104
Xen : 三台 CentOS 5.8
ip为: 10.10.10.106
10.10.10.107
10.10.10.108
-----------------------------------
IP 分配 :
LVS-vip 10.10.10.110
LVS-MASTER 10.10.10.104 是LVS 也是 WEB
LVS-BACKUP 10.10.10.106 是LVS 也是 WEB
WEB1-REALSERVER 10.10.10.107
WEB2-REALSERVER 10.10.10.108
WEB3-REALSERVER 10.10.10.106 是LVS 也是 WEB
WEB4-REALSERVER 10.10.10.104 既是LVS 也是 WEB
------------------------------------
安装开始:
首先在两台 LVS 上安装 LVS+Keppalived
下载
wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz
ln -s /usr/src/kernels/2.6.18-238.el5-x86_64/ /usr/src/linux
【PS: Xen 下面没有 2.6.18-238.el5-x86_64 . 将物理机上面的 复制到 虚拟机上面去,否则无法安装】
tar zxvf ipvsadm-1.24.tar.gz
cd ipvsadm-1.24
make
make install
安装完毕以后,下面安装 Keepalved
下载 wget http://www.keepalived.org/software/keepalived-1.2.1.tar.gz
tar zxvf keepalived-1.2.1.tar.gz
cd keepalived-1.2.1
./configure
make
make install
将keepalived做成启动脚务:
cp /usr/local/etc/rc.d/init.d/keepalived /etc/rc.d/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/
【service keepalived start 可启动,这里暂时不启动,等修改完配置文件以后再启动】
Keealived的配置文件修改..
vi /etc/keepalived/keepalived.conf
主的配置文件为:
------------------------------------------------------------
! Configuration File for keepalived
global_defs {
notification_email {
jicki@qq.com
}
notification_email_from jicki@qq.com
smtp_server 127.0.0.1
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.10.10.110
}
}
virtual_server 10.10.10.110 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
persistence_timeout 60
protocol TCP
real_server 10.10.10.107 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 10.10.10.108 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 10.10.10.106 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 10.10.10.104 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
----------------------------------------------------
从的配置文件为:
----------------------------------------------------
! Configuration File for keepalived
global_defs {
notification_email {
jicki@qq.com
}
notification_email_from jicki@qq.com
smtp_server 127.0.0.1
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.10.10.110
}
}
virtual_server 10.10.10.110 80 {
delay_loop 6
lb_algo wrr
lb_kind DR
persistence_timeout 60
protocol TCP
real_server 10.10.10.107 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 10.10.10.108 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 10.10.10.106 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
real_server 10.10.10.104 80 {
weight 3
TCP_CHECK {
connect_timeout 10
nb_get_retry 3
delay_before_retry 3
connect_port 80
}
}
}
----------------------------------------------------
修改完配置文件以后启动 servcie keepalived start
配置WEB服务器....
在WEB主机上实行脚本realserver 每一台WEB主机都必须启动这个脚本.
----------------------------------------------------------------
#vim /usr/local/sbin/realserver
#!/bin/bash
SNS_VIP=10.10.10.110
. /etc/rc.d/init.d/functions
case "$1" in
start)
ifconfig lo:0 $SNS_VIP netmask 255.255.255.255 broadcast $SNS_VIP
/sbin/route add -host $SNS_VIP dev lo:0
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
sysctl -p >/dev/null 2>&1
echo "RealServer Start OK"
;;
stop)
ifconfig lo:0 down
route del $SNS_VIP >/dev/null 2>&1
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
echo "RealServer Stoped"
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
exit 0
----------------------------------------------------------------
【FreeBSD 做realserver 的时候 只需要给网卡加 -arp 就可以了
ifconfig lo0 alias 10.10.10.110 netmask -arp up 】
----------------------------------------------------------------
chmod +x /usr/local/sbin/realserver 给权限
/usr/local/sbin/realserver start 启动它
然后 ifconfig 查看环回接口lo0:0 是否已经绑定VIP IP..
运行 ipvsadm -l 看看是否已经启动.
ipvsadm -l
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.10.10.110:http wrr persistent 60
-> 10.10.10.106:http Route 3 0 0
-> 10.10.10.108:http Route 3 0 0
-> 10.10.10.107:http Route 3 0 0
-> 10.10.10.104:http Local 3 0 0
查看日志 cat /var/log/messages 文件查看
keepalived指定日志文件
vi /etc/sysconfig/keepalived
-------------------------------------------------------------------------
# Options for keepalived. See `keepalived --help' output and keepalived(8) and
# keepalived.conf(5) man pages for a list of all options. Here are the most
# common ones :
#
# --vrrp -P Only run with VRRP subsystem.
# --check -C Only run with Health-checker subsystem.
# --dont-release-vrrp -V Dont remove VRRP VIPs & VROUTEs on daemon stop.
# --dont-release-ipvs -I Dont remove IPVS topology on daemon stop.
# --dump-conf -d Dump the configuration data.
# --log-detail -D Detailed log messages.
# --log-facility -S 0-7 Set local syslog facility (default=LOG_DAEMON)
#
KEEPALIVED_OPTIONS="-D -d -S 0"
-----------------------------------------------------------------------------------
设置syslog,修改/etc/syslog.conf
vi /etc/syslog.conf
------------------------------------------------------------------------
# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.* /dev/console
# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages
# The authpriv file has restricted access.
authpriv.* /var/log/secure
# Log all the mail messages in one place.
mail.* -/var/log/maillog
# Log cron stuff
cron.* /var/log/cron
# Everybody gets emergency messages
*.emerg *
# Save news errors of level crit and higher in a special file.
uucp,news.crit /var/log/spooler
# Save boot messages also to boot.log
local7.* /var/log/boot.log
# keepalived -S 0
local0.* /var/log/keepalived.log
------------------------------------------------------------------------
重启syslog,设置完成。
- [转帖]负载均衡 LVS+Keepalived
负载均衡 LVS+Keepalived https://www.cnblogs.com/jicki/p/5546862.html 改天试试 一直没搞过. 系统 CentOS 5.6 X64 物理机 ...
- Linux集群之高可用负载均衡lvs+keepalived
LVS简介 LVS介绍 LVS是Linux Virtual Server的缩写,意即Linux虚拟服务器,是一个虚拟的服务器集群系统,属于4层负载均衡 ipvs和ipvsadm的关系 我们使用配置LV ...
- 企业级Nginx负载均衡与keepalived高可用实战(二)keepalived篇
1.Keepalived高可用软件 1.1.Keepalived介绍 Keepalived软件起初是专门为LVS负载均衡软件设计的,用来管理并监控LVS集群系统中各个服务节点的状态,后来又加入了可以实 ...
- 服务器负载均衡lvs(Linux Virtual Server)
服务器负载均衡lvs(Linux Virtual Server) 一.总结 LVS是Linux Virtual Server的简写,意即Linux虚拟服务器,是一个虚拟的服务器集群系统. 三.Linu ...
- lvs 中DR模式负载均衡及keepalived
lvs DR配置 LVS负载均衡:三种负载均衡模式:DR,TUN(ip隧道),NAT,这里我们介绍DR模式 server1: 首先,配置server机yum源 方便后期实验流畅vim /etc/yum ...
- Haproxy/LVS负载均衡实现+keepalived实现高可用
haproxy+keepalived 集群高可用集群转发 环境介绍 #内核版本 Ubuntu 18.04.4 LTS \n \l 107-Ubuntu SMP Thu Jun 4 11:27:52 U ...
- LVS实现(VS/DR)负载均衡和Keepalived高可用
LVS是Linux Virtual Server的简写即Linux虚拟服务器,是一个虚拟的服务器集群系统一组服务器通过高速的局域网或者地理分布的广域网相互连接,在它们的前端有一个负载调度器(Load ...
- JAVAEE——宜立方商城03:商品类目选择、Nginx端口或域名区分虚拟机、Nginx反向代理、负载均衡、keepalived实现高可用
1. 学习计划 第三天: 1.商品类目选择(EasyUI的tree实现) 2.图片上传 a) 图片服务器FastDFS(Nainx部分) 2. 商品类目选择 2.1. 原型 2.2. 功能分析 展示商 ...
- 负载均衡LVS
可参考:http://ixdba.blog.51cto.com/2895551/555738 http://os.51cto.com/art/201202/319979.html 也可以参考官网:ht ...
随机推荐
- 不注册COM组件直接调用接口
本文以COM组件AppTest.dll为例,AppTest.dll中提供了ITest接口,在不使用regsvr32命令向系统注册的情况下创建ITest接口并调用. 一.导入组件或类型库: 在C++中使 ...
- wpf之ListBox横向显示所有ListBoxItem
Xaml: <Window x:Class="WpfApplication6.MainWindow" xmlns="http://schemas.microsoft ...
- spring bean之间关系
ByeService.java package com.service; public class ByeService { public String sayBye() { return " ...
- pom 的scope标签分析
一.compile:编译范围compile是默认的范围:如果没有提供一个范围,编译范围依赖在所有的classpath 中可用,同时它们也会被打包.而且这些dependency会传递到依赖的项目中. 二 ...
- 学习笔记:GLSL Core Tutorial – Pipeline (OpenGL 3.2 – OpenGL 4.2)
GLSL Core Tutorial – Pipeline (OpenGL 3.2 – OpenGL 4.2) GLSL 是一种管道,一种图形化的流水线 1.GLSL 的具体工作流程: 简化流程如下: ...
- SEO策略与细节:细节决定成败
昨天展开seo探讨会.听了一场医疗界seo大神的讲座.收益匪浅今天讲他的演讲内容整理出来与大家分享.希望对医疗界的seo带来些帮助.站长们一起成长! 一.首页 1.元标签设置 标题:上海癫痫病医院哪家 ...
- Local declaration of 'XXX' hides instance variable
今天调试程序遇到这么一个警告! Local declaration of 'XXX' hides instance variable 遇到这种原因,是因为本地变量跟函数参数变量同名.改变其一即可.
- Java R&W Related
In Java, byte = 8 bit, char = 16 bit In C/C++, char = 8 bit There is difference because Java uses Un ...
- g++ 编译c文件
//编译c文件为.o文件 g++ -c virify.c //打包.o文件为.a静态库文件 ar crv libandroid_um36_virify.a virify.o //将静态库.a文件编译进 ...
- 在vim下,实现nesC语句的高亮
默认的vim没有支持nesC语法高亮,给阅读源码带来不便.不过可以通过装NesC Syntax Highlighting插件来解决这个问题,具体操作如下: 步骤一:下载插件 在http://www.v ...