ipvsadm源码编译:
源码下载地址:http://www.linuxvirtualserver.org/software/ipvs.html
RHEL7安装依赖库:
yum install popt* libnl* #安装popt、libnl
rpm -ivh popt-static-1.13-16.el7.x86_64.rpm #安装popt-static.
#下载地址http://rpm.pbone.net/index.php3/stat/4/idpl/31983442/dir/centos_7/com/popt-static-1.13-16.el7.x86_64.rpm.html
SELS11安装依赖库:
zypper in popt popt-devel libnl libnl-devel
下载popt编译并安装:http://freecode.com/projects/popt
./configure
make && make install
SELS11好像不支持ip_vs内核模块,需要重新编译内核
编译ipvsadm:
make
prianha实现动态负载均衡代码分析
原理:http://www.linuxvirtualserver.org/zh/lvs4.html 最后一节
代码地址:http://www.filewatcher.com/d/Red%20Hat/src/System%20Environment/Base/piranha-0.8.3.1-7.src.rpm.727716.html
安装rpm:http://rpm.pbone.net/index.php3/stat/4/idpl/31368326/dir/centos_6/com/piranha-0.8.6-4.el6_5.2.x86_64.rpm.html
实现:使用命令收集系统负载数据,通过计算得到最新的weight, 通过ipvsadm -e设置。
|->rereadConfigFiles()---|
| V
lvsd.c main()------->startServices-->startVirtualServer()---->startClientMonitor()-->"/usr/sbin/nanny" --->
--> getRemoteLoad -->rup、rsh uptime命令获取1分钟load average
nanny.c main()-->run()-->adjustWeight--》adjustDevice--》runCommand--》ipvsadm -e改变weight