基于Keepalived+Haproxy搭建四层负载均衡器

www.net130.com     日期:2011-6-16    浏览次数:
作者:刘天斯

一、前言
       Haproxy是稳定、高性能、高可用性的负载均衡解决方案,支持HTTP及TCP代理后端服务器池,因支持强大灵活的7层acl规则,广泛作为HTTP反向代理。本文则详细介绍如何利用它的四层交换与Keepalived实现一个负载均衡器,适用于Socket、ICE、Mail、Mysql、私有通讯等任意TCP服务。系统架构图如下:


 

二、平台环境


OS:Centos5.4(64X)
MASTER:192.168.0.20
BACKUP:192.168.0.21
VIP:192.168.0.100
Serivce Port:11231


三、平台安装配置
1、添加非本机IP邦定支持


#vi /etc/sysctl.conf
net.ipv4.ip_nonlocal_bind=1
#sysctl –p


2、配置平台日志支持


#vi /etc/syslog.conf
添加:
local3.*        /var/log/haproxy.log
local0.*        /var/log/haproxy.log

#vi /etc/sysconfig/syslog
修改:
SYSLOGD_OPTIONS="-r -m 0"
#/etc/init.d/syslog restart


3、关闭SELINUX


vi /etc/sysconfig/selinux
修改:
SELINUX=disabled
#setenforce 0


4、配置iptables,添加VRRP通讯支持


iptables -A INPUT -d 224.0.0.18 -j ACCEPT


5、Keepalived的安装、配置


#mkdir -p /home/install/keepalivedha
#cd /home/install/keepalivedha
#wget http://www.keepalived.org/software/keepalived-1.2.2.tar.gz
#tar zxvf keepalived-1.2.2.tar.gz
#cd keepalived-1.2.2
#./configure
#make && make install


 


#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/


 

本新闻共3页,当前在第1页  1  2  3  

分享道
相关新闻