首 页文章中心

Linux学习网

您的位置Linux学习网 > Linux综合 > 文章内容

给Linux内核补IPVS补丁

作者:佚名  来源:不详  发布时间:2007-12-21 16:51:00
 安装

    首先在安装Red Hat 7.2的时候,要将所有编译内核的库文件和编译工具都选上。如果系统安装后,发现不能编译内核,请重新安装安装光盘中以Kernel开头的RPM包。关闭一些不常用的服务后,再重新启动。

    然后解压下载的内核,将其放在/usr/src/目录下,命令如下:

# tar xzvf linux-2.4.21.tar.gz -C /usr/src# cd /usr/src# ln -s ./linux-2.4.21 linux


    用户在/usr/src目录下,给新内核打上IPVS的补丁,命令如下:
    # gunzip linux-2.4.21-ipvs-1.0.10.patch.gz |patch -p0 //将IPVS的Patch加载到内核的代码中

    如果是利用Direct Routing或IP TUN模式,还需要加载“hidden”的patch (hidden-2.4.20pre10-1.diff)档案,将其放在/usr/src目录下,利用下面的命令:
    # cat hidden-2.4.20pre10-1.diff | patch -p0

    内核配置

    开始编译前,内核的配置工作很重要,命令如下:

# cd linux //进入编译目录下# make mrproper //删掉上次编译产生的.o文件等# make menuconfig


    在内核的配置过程中,最重要的就是网卡的驱动。如果不能很好地把网卡驱动起来,那么所有的工作都是徒劳的。接着只需注意编译选项中的如下几项:

Code maturity level options --->    [*] Prompt for development and/or incomplete code/drivers#### 请选择代码的成熟性Networking options --->    [*] Network packet filtering (replaces ipchains)    [ ]   Network packet filtering debugging    ...      IP: Netfilter Configuration  --->


    其中“IP: Virtual Server Configuration”的配置参见图1。


图1 IP: Virtual Server Configuration设置界面


    编译内核

    在用户保存了各种配置,退出后,系统会提示用户运行“make dep”命令。具体过程如下:

# make dep  //确保所有的相依关系,会花一点时间# make clean  //清除一些已经无用的中间代码# make bzImage  //开始编译内核,屏幕上出现很多编译内容,大概20分钟左右,视系统强壮而定# make modules  //编译模块# make modules_install  //安装模块#cp arch/i386/boot/bzImage  /boot/ vmlinuz-2.4.21-lvs#cp System.map  /boot/System.map.2.4.21-lvs


    修改LILO

    如果使用LILO引导开机,那么需要照下面的格式修改/etc/lilo.conf:

#vi /etc/lilo.conf  prompt  timeout=50 boot=/dev/hda  map=/boot/map  install=/boot/boot.blinearimage=/boot/vmlinuz-2.4.7-10  label=linux  root=/dev/hda5  read-onlyimage=/boot/vmlinuz-2.4.21-lvs  label=lvs  root=/dev/hda5  read-only  #添加以上这一段other=/dev/hda1  label=win  table=/dev/had  # 结束编辑退出# lilo  //重新运行LILO生效


    如果是用GRUB引导,需要设定好/boot/grub.conf

default=1timeout=10splashimage=(hd0,0)/boot/grub/splash.xpm.gztitle Linux (2.4.7-10)      root (hd0,0)      kernel /boot/vmlinuz-2.4.7-10 ro       root=LABEL=/initrd /boot/initrd-2.4.7-10.imgtitle LVS (2.4.21-lvs)      root (hd0,0)      kernel /boot/vmlinuz-2.4.21-lvs ro       root=LABEL=/initrd /boot/initrd-2.4.21-lvs.imgtitle Windows       map (hd0) (hd1)       map (hd1) (hd0)       root (hd1,0)       chainloader (hd1,0)+1 makeactive boot


    重新开机,选择LVS内核启动机器,查看开机过程有无错误发生,然后检查/proc/sys/net/ipv4/conf/all/hidden是否存在。如果不存在,说明编译中有问题,建议用户重新再编译。如果一切顺利,那么可以安装ipvsadm的二进制软件包。安装后可以用下面的命令检验,如果出现以下提示,说明安装成功:

# ipvsadm // IPVS的管理软件IP Virtual Server version 1.0.9 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn

收藏本页到: 365Key | del.icio.us | | 添加到雅虎收藏+
  • 网站帮助 - 广告合作 - 网站地图