安装步骤
1.防火墙设置
centos7.0默认防火墙为firewalld(为了测试,关闭默认防火墙,使用iptables防火墙)
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2.下载ipvsadm之前,先使用以下命令查看当前Load Balancer服务器内核版本:
rpm -q kernel-devel
(我的centos 7 kernel-devel-3.10.0-327.el7.x86_64)
根据这个版本号到官网上下载对应该内核版本的ipvsadm版本。
下载地址http://www.linuxvirtualserver.org/software/ipvs.html
3.安装ipvsadm
wget http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.26.tar.gz
tar zxf ipvsadm-1.26.tar.gz
cd ipvsadm-1.26
rpm -qa | grep kernel-devel(默认已经安装)
make && make install
注:安装前确定依赖包都已安装,否则安装失败
[root@localhost ipvsadm-1.26]# make && make install
make -C libipvs
make[1]: Entering directory `/usr/ipvsadm-1.26/libipvs'
gcc -Wall -Wunused -Wstrict-prototypes -g -fPIC -DLIBIPVS_USE_NL -DHAVE_NET_IP_VS_H -c -o libipvs.o libipvs.c
In file included from libipvs.h:13:0,
from libipvs.c:23:
ip_vs.h:15:29: fatal error: netlink/netlink.h: No such file or directory
#include <netlink/netlink.h>
^
compilation terminated.
make[1]: *** [libipvs.o] Error 1
make[1]: Leaving directory `/usr/ipvsadm-1.26/libipvs'
make: *** [libs] Error 2
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
(安装所需依赖包
yum install popt-static kernel-devel make gcc openssl-devel lftplibnl* popt* openssl-devel lftplibnl* popt* libnl* libpopt* gcc*)
经上步骤 lvs 已可以安装成功
检验是否安装成功如下
[root@localhost ipvsadm-1.26]# ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
[root@localhost ipvsadm-1.26]# lsmod |grep ip_vs
ip_vs 140944 0
nf_conntrack 105745 1 ip_vs
libcrc32c 12644 2 xfs,ip_vs
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
这样可以看到 我们的lvs已彻底安装成功了