LVS是Linux Virtual Server的简称,也就是Linux虚拟服务器, 是一个由章文嵩博士发起的自由软件项目,现在已经是 Linux标准内核的一部分。在Linux2.4内核以前,使用LVS时必须要重新编译内核以支持LVS功能模块,但是从Linux2.4内核以后,已经完全内置了LVS的各个功能模块,无需给内核打任何补丁,可以直接使用LVS提供的各种功能。使用LVS技术要达到的目标是:通过LVS提供的负载均衡技术和Linux操作系统实现一个高性能、高可用的服务器群集,它具有良好可靠性、可扩展性和可操作性。从而以低廉的成本实现最优的服务性能。

可以利用LVS框架实现高可伸缩的、高可用的网络服务有WWW服务、Cache服务、DNS服务、FTP服务、MAIL服务、视频/音频点播服务等等,有许多比较著名网站和组织都在使用LVS架设的集群系统,例如:linux的门户网站(www.linux.com)、向RealPlayer提供音频视频服务而闻名的Real公司(www.real.com)、全球最大的开源网站(sourceforge.net)等。

使用LVS架设的服务器集群系统有三个部分组成,最前端的负载均衡层,用Load Balancer表示,中间的服务器群组层,用Server Array表示,最底端的数据共享存储层,用Shared Storage表示,在用户看来,所有的内部应用都是透明的,用户只是在使用一个虚拟服务器提供的高性能服务。

Configuation example

Now we're going to using keepalived to contruct a highly-available VS/NAT web cluster with two load balancers and three web servers. The topology is illustrated in the following figure. In the example, virtual IP address and gateway IP address are 10.23.8.80 and 172.18.1.254, which are floating between the two load balancers (LD1 and LD2), and the ip addresses of three real servers are 172.18.1.11, 172.18.1.12 and 172.18.1.13 respectively.

wKiom1g2od3jWkxNAAGRIdr3OrU542.png-wh_50

In our example, the keepalived configuration file (/etc/keepalived/keepalived.conf) at the LD1 looks like:

 

实验环境:

系统平台:RedHat Linux 6.4 32位

Kernel:2.6.32-358.el6.i686

LVS版本ipvsadm-1.26-1.src.rpm(http://www.linuxvirtualserver.org/

keepalived版本keepalived-1.3.1.tar.gz(http://www.keepalived.org/download.html)

1、在两台Director Server上分别配置LVS+Keepalived

2、安装LVS前系统需要安装popt-static,kernel-devel,make,gcc,openssl-devel,lftp,libnl*,popt*

[root@localhost pakge]# rpm -qa | grep popt-static kernel-devel make gcc openssl-devel lftp libnl* popt*

yum install popt-static kernel-devel make gcc openssl-devel lftp

 

 

1、在两台Director Server上分别配置LVS+Keepalived

[root@localhost LVS]# rpm -ivh ipvsadm-1.26-1.src.rpm
   1:ipvsadm                warning: user wensong does not exist - using root
warning: group wensong does not exist - using root
warning: user wensong does not exist - using root)
warning: group wensong does not exist - using root
########################################### [100%]
[root@localhost LVS]#

 

tar -xvf keepalived-1.3.1.tar.gz

cd /soft/keepalived/keepalived-1.3.1