系统 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 ...
随机推荐
- Delphi XE2 生成的.exe 在未安装有Delphi的电脑上运行提示 “丢失 rtl160.bpl”
解决方案: XE2中加入了多平台的概念,默认的Release模式,也是带包编译,带运行时库的,所以,需要手工设置一下工程选项: 打开工程以后,Project-->Options-->左侧树 ...
- js中Object.__proto__===Function.prototype
参考:http://stackoverflow.com/questions/650764/how-does-proto-differ-from-constructor-prototype http:/ ...
- java实现类似qq的窗口对聊
Swing实现界面,socket实现通信 package com.learn.talk; import java.awt.BorderLayout; import java.awt.Dimension ...
- Swift & OC 混编 浅析
转载自:http://www.infoq.com/cn/articles/wangyi-cartoon-swift-mixed-practice?utm_campaign=rightbar_v2&am ...
- 下拉刷新和上拉加载 Swift
转载自:http://iyiming.me/blog/2015/07/05/custom-refresh-and-loading/ 关于下拉刷新和上拉加载,项目中一直使用MJRefresh(原先还用过 ...
- maven学习笔记 1
1 概述 1.1 Maven是什么 1.2 为什么要用Maven 2 怎么用Maven 2.1 Maven仓库 2.2 Maven安装 2.3 Eclipse插件 2.4 Maven常用命 ...
- My workbench draft
System Linux / Ubuntu 14.04.5 LTS (Trusty Tahr) + ROS Indigo Linux / Ubuntu 16.04.1 LTS (Xenial Xeru ...
- update set from where
原文链接:http://blog.csdn.net/xcbsdu/article/details/6736503 关于update set from where 下面是这样一个例子: 两个表a.b,想 ...
- AdminLTE的使用
1.AdminLTE的必要配置文件<!-- Tell the browser to be responsive to screen width --> <meta content=& ...
- Android Studio的使用(十)--读取assets、Raw文件夹下文件,以及menu、drawable文件夹
1.直接在/src/main目录下面新建assets目录 2.接下来即可读取文件 3.读取Raw文件夹下文件也类似.首先在res文件夹下新建raw目录,然后放入需要的文件即可读取. 4.menu和dr ...