lvs fullnat+ECMP【1】內核編譯

0、請使用物理機安裝,虛擬機沒編譯成功

一、先查看一下系統版本,須要是centos6,內核2.6

cat /etc/*release
uname -rpython

[root@lvs-fullnat-one ~]# cat /etc/*release
CentOS release 6.5 (Final)
LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
CentOS release 6.5 (Final)
CentOS release 6.5 (Final)
[root@lvs-fullnat-one ~]# uname -r
2.6.32-431.el6.x86_64
[root@lvs-fullnat-one ~]#

二、從Redhat網站下載kernel的rpm

wget ftp://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS/kernel-2.6.32-220.23.1.el6.src.rpm
若是沒法如今,請從網盤下載。鏈接:
<https://pan.baidu.com/s/1p1tkhI7Wn5eAq999E9D_xA>;linux

三、從rpm中得到kerel源碼

vim ~/.rpmmacros;
   add:
     %_topdir /home/pukong/rpms
     %_tmppath /home/pukong/rpms/tmp
     %_sourcedir /home/pukong/rpms/SOURCES
     %_specdir /home/pukong/rpms/SPECS
     %_srcrpmdir /home/pukong/rpms/SRPMS
     %_rpmdir /home/pukong/rpms/RPMS
     %_builddir /home/pukong/rpms/BUILD
  cd /home/pukong;
   mkdir rpms;
   mkdir rpms/tmp;
   mkdir rpms/SOURCES;
   mkdir rpms/SPECS;
   mkdir rpms/SRPMS;
   mkdir rpms/RPMS;
   mkdir rpms/BUILD;

useradd mockbuild
rpm -ivh kernel-2.6.32-220.23.1.el6.src.rpm
cd /home/pukong/rpms/SPECS
yum -y install rpm-build
yum -y install gcc zlib-devel patchutils xmlto asciidoc elfutils-libelf-devel  binutils-devel  newt-devel python-devel hmaccalc

yum -y install  rng-tools  openssl-devel
rngd -r /dev/urandom  ##rng-tools用於在執行rpmbuild -bb --target=`uname -m` kernel.spec的時候生成隨機數,否則會卡在那裏,可是根據卡的地方倒退回去會看到提示就執行rngd -r /dev/hwrandom,不行的話執行 rngd -r /dev/urandom,所以須要安裝此工具

rpmbuild -bp kernel.spec;

最後的rpmbuild是一個多是一個十分漫長的操做,請不要關閉xshell。 shell

這時候你就能在/home/pukong/rpms/BUILD找到內核源碼vim

[root@lvs-fullnat-one SPECS]#  cd /home/pukong/rpms/BUILD/;
[root@lvs-fullnat-one BUILD]# ls
kernel-2.6.32-220.23.1.el6

四、添加lvs patch

[Lvs-fullnat-synproxy.tar.gz]
https://pan.baidu.com/s/1sOnbGpnk7vZGoTxgEVDpAA
將文件放到服務器中 centos

tar xvf Lvs-fullnat-synproxy.tar.gz 
cd lvs-fullnat-synproxy/
cp lvs-2.6.32-220.23.1.el6.patch /home/pukong/rpms/BUILD/kernel-2.6.32-220.23.1.el6/linux-2.6.32-220.23.1.el6.x86_64/

cd /home/pukong/rpms/BUILD/;
cd kernel-2.6.32-220.23.1.el6/linux-2.6.32-220.23.1.el6.x86_64/;

patch -p1<lvs-2.6.32-220.23.1.el6.patch; // patch is in lvs-fullnat-synproxy.tar.gz 給內核打補丁    補丁不能重複打

打完補丁,修改Makefile文件,給內核版本命名:服務器

[root@lvs-fullnat-one linux-2.6.32-220.23.1.el6.x86_64]# uname -r
2.6.32-431.el6.x86_64
[root@lvs-fullnat-one linux-2.6.32-220.23.1.el6.x86_64]# vim Makefile

將Makefile中EXTRAVERSION 字段補上一個跟uname -r類似字段,以下圖微信

VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 32
EXTRAVERSION = -431.toa.el6.x86_64
NAME = Man-Eating Seals of Antiquity
RHEL_MAJOR = 6
RHEL_MINOR = 2
RHEL_RELEASE = 219

注意修改.config文件中的參數,主要是爲了擴大VS最大鏈接數,能夠增大VS的吞吐量(併發鏈接量),若是值只是本來的4096可能會丟包併發

vim .config

 CONFIG_IP_VS_TAB_BITS=22

五、編譯內核

make -j16 ##j是指同時做業的數量,能夠不用添加此參數
make modules_install;
make install;

此時可能會報幾個錯dom

[root@lvs-fullnat-one linux-2.6.32-220.23.1.el6.x86_64]# make install;
sh /home/pukong/rpms/BUILD/kernel-2.6.32-220.23.1.el6/linux-2.6.32-220.23.1.el6.x86_64/arch/x86/boot/install.sh 2.6.322.6.32-431.el6.x86_64 arch/x86/boot/bzImage \
        System.map "/boot"
ERROR: modinfo: could not find module lpc_ich
ERROR: modinfo: could not find module ptp
[root@lvs-fullnat-one linux-2.6.32-220.23.1.el6.x86_64]#

須要複製進來幾個模塊 ide

cp /lib/modules/2.6.32-431.el6.x86_64/kernel/drivers/mfd/lpc_ich.ko /lib/modules/2.6.32-431.toa.el6.x86_64/kernel/drivers/mfd/

mkdir /lib/modules/2.6.32-431.toa.el6.x86_64/kernel/drivers/ptp
cp /lib/modules/2.6.32-431.el6.x86_64/kernel/drivers/ptp/ptp.ko /lib/modules/2.6.32-431.toa.el6.x86_64/kernel/drivers/ptp/

從新安裝,會有幾個警告,忽略便可

[root@lvs-fullnat-one linux-2.6.32-220.23.1.el6.x86_64]# make install;
sh /home/pukong/rpms/BUILD/kernel-2.6.32-220.23.1.el6/linux-2.6.32-220.23.1.el6.x86_64/arch/x86/boot/install.sh 2.6.32-431.toa.el6.x86_64 arch/x86/boot/bzImage \
        System.map "/boot"
WARNING: /lib/modules/2.6.32-431.toa.el6.x86_64/kernel/drivers/ptp/ptp.ko needs unknown symbol kmem_cache_alloc_trace
WARNING: /lib/modules/2.6.32-431.toa.el6.x86_64/kernel/drivers/ptp/ptp.ko needs unknown symbol posix_clock_register
WARNING: /lib/modules/2.6.32-431.toa.el6.x86_64/kernel/drivers/ptp/ptp.ko needs unknown symbol posix_clock_unregister
[root@lvs-fullnat-one linux-2.6.32-220.23.1.el6.x86_64]#

六、修改內核文件

vim /boot/grub/grub.conf
修改default的值爲0 表示先啓動
引導文件中有兩個引導啓動段,一個是本來內核的linux,一個是新編譯的內核,新編譯的內核在上面,因此把default的值設爲0,即表示使用新的內核引導系統了。

七、重啓

reboot

lvs fullnat+ECMP【1】內核編譯微信公衆號,隨便發點有意思的東西

相關文章
相關標籤/搜索