安装步骤
- 安装必要软件:
yum -y install m4 gcc redhat-rpm-config xmlto asciidoc elfutils-libelf-devel binutils-devel newt-devel perl-ExtUtils-Embed hmaccalc rng-tools
- 下载源码
mkdir /home/lvs cd /home/lvs 去百度云盘下载220内核的ipvs和ip_vs.h上传到/home/lvs文件夹下 链接: https://pan.baidu.com/s/1miLp7BE 密码: wdh7 tar zxvf ipvs.tar.gz wget http://vault.centos.org/6.4/os/Source/SPackages/kernel-2.6.32-358.el6.src.rpm wget http://kb.linuxvirtualserver.org/images/a/a5/Lvs-fullnat-synproxy.tar.gz tar zxvf Lvs-fullnat-synproxy.tar.gz
- 编译内核重启
cat > ~/.rpmmacros << EOF %_topdir /home/lvs/rpms %_tmppath /home/lvs/rpms/tmp %_sourcedir /home/lvs/rpms/SOURCES %_specdir /home/lvs/rpms/SPECS %_srcrpmdir /home/lvs/rpms/SRPMS %_rpmdir /home/lvs/rpms/RPMS %_builddir /home/lvs/rpms/BUILD EOF cd /home/lvs mkdir rpms mkdir rpms/tmp mkdir rpms/SOURCES mkdir rpms/SPECS mkdir rpms/SRPMS mkdir rpms/RPMS mkdir rpms/BUILD useradd -s /sbin/nologin mockbuild rpm -ivh kernel-2.6.32-358.el6.src.rpm cd /home/lvs/rpms/SOURCES vim config-generic 把第一行的# 改成 # x86_64,把 CONFIG_IP_VS_TAB_BITS=12 改成 CONFIG_IP_VS_TAB_BITS=20 cd /home/lvs/rpms/SPECS vim kernel.spec 把 # % define buildid .local 修改为%define buildid .ipvs_20bit rpmbuild -bp kernel.spec 会卡在下面: + gpg --homedir . --batch --gen-key /home/lvs/rpms/SOURCES/genkey gpg: WARNING: unsafe permissions on homedir `.' gpg: keyring `./secring.gpg' created gpg: keyring `./pubring.gpg' created 再打开服务器的另一个终端输入如下命令: rngd 打lvs-fullnat patch和toa path cd /home/lvs/rpms/BUILD/kernel-2.6.32-358.el6/linux-2.6.32-358.el6.ipvs_20bit.x86_64/ cp /home/lvs/lvs-fullnat-synproxy/lvs-2.6.32-220.23.1.el6.patch ./ cp /home/lvs/lvs-fullnat-synproxy/toa-2.6.32-220.23.1.el6.patch ./ cp /home/lvs/ip_vs.h /home/lvs/rpms/BUILD/kernel-2.6.32-358.el6/linux-2.6.32-358.el6.ipvs_20bit.x86_64/include/net/ cd /home/lvs/rpms/BUILD/kernel-2.6.32-358.el6/linux-2.6.32-358.el6.ipvs_20bit.x86_64/net/netfilter/ipvs/ rm -rf * cp /home/lvs/ipvs/* /home/lvs/rpms/BUILD/kernel-2.6.32-358.el6/linux-2.6.32-358.el6.ipvs_20bit.x86_64/net/netfilter/ipvs/ cd /home/lvs/rpms/BUILD/kernel-2.6.32-358.el6/linux-2.6.32-358.el6.ipvs_20bit.x86_64/ patch -p1 < ./lvs-2.6.32-220.23.1.el6.patch patch -p1 < ./toa-2.6.32-220.23.1.el6.patch cp configs/kernel-2.6.32-x86_64.config .config vim Makefile 修改EXTRAVERSION = -358.e16.lvs-fullnat make -j16 这里看你多少cpu核心就写多少就行 make modules_install make install vim /etc/grub.conf 修改内核启动参数default=0,并在kernel一行中,添加“nohz=off ”(如果不关闭nohz,大压力下CPU0可能会消耗过高,压力不均匀) reboot重启。
- 重启后加载驱动安装工具
modprobe ip_vs modprobe ip_vs_rr modprobe ip_vs_wrr modprobe ip_vs_sh modprobe iptable_filter modprobe ip_tables modprobe toa 安装工具 cd /home/lvs/lvs-fullnat-synproxy tar xzf lvs-tools.tar.gz cd tools cd keepalived/ ./configure --with-kernel-dir=”/lib/modules/`uname -r`/build” make make install cd /home/lvs/lvs-fullnat-synproxy/tools/ipvsadm/ make make install quagga可以 yum -y install quagga安装也可以编译安装 cd /home/lvs/lvs-fullnat-synproxy/tools/quagga ./configure make make install
- 性能调优
ethtool -K p4p1 gro off ethtool -K p4p1 lro off ethtool -K p4p1 rx off && sleep 1 && ethtool -K p4p1 rx on & echo 1 > /proc/sys/net/ipv4/tcp_syncookies echo 500000 > /proc/sys/net/core/netdev_max_backlog echo 500000 > /proc/sys/net/ipv4/tcp_max_syn_backlog echo 1 > /proc/sys/net/ipv4/ip_forward echo 0 > /proc/sys/net/ipv4/conf/all/send_redirects echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce echo 2000 > /proc/sys/net/unix/max_dgram_qlen 记得把以上命令加到/etc/rc.local
-
最后附上编译好的rpm内核包,没有亲测过不确定完全没问题
链接: https://pan.baidu.com/s/1jHTQT9s 密码: j4mcipvsadm的使用这里就不做赘述了。。。github上很详细的介绍。。。。。。。
总算把之前没完成的作业写完了,科科
感谢艺龙大神的方案,希望大家都能用上lvs_fullnat哈,有问题可以多讨论,有的好的方案欢迎大家多多留言
转载请注明:爱开源 » 在R730上搭建lvs-fullnat