码迷,mamicode.com
首页 > 其他好文 > 详细

lvs fullnat+ECMP【1】内核编译

时间:2018-10-22 20:39:11      阅读:282      评论:0      收藏:0      [点我收藏+]

标签:targe   err   could not   连接   mpp   drive   evel   cache   mkdir   

0、请使用物理机安装,虚拟机没编译成功

1、先查看一下系统版本,需要是centos6,内核2.6

cat /etc/*release
uname -r

[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 ~]# 

2、从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>;

3、从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。

这时候你就能在/home/pukong/rpms/BUILD找到内核源码

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

4、添加lvs patch

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

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 

5、编译内核

make -j16 ##j是指同时作业的数量,可以不用添加此参数
make modules_install;
make install;

此时可能会报几个错

[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]# 

需要复制进来几个模块

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]# 

6、修改内核文件

vim /boot/grub/grub.conf
修改default的值为0 表示先启动
引导文件中有两个引导启动段,一个是原本内核的linux,一个是新编译的内核,新编译的内核在上面,所以把default的值设为0,即表示使用新的内核引导系统了。

7、重启

reboot

lvs fullnat+ECMP【1】内核编译

标签:targe   err   could not   连接   mpp   drive   evel   cache   mkdir   

原文地址:http://blog.51cto.com/9346709/2307280

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!