ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 给Linux内核补IPVS补丁(转)

给Linux内核补IPVS补丁(转)

原创 Linux操作系统 作者:BSDLite 时间:2007-08-12 13:37:05 0 删除 编辑
给Linux内核补IPVS补丁(转)[@more@]本文仅做参考

安装

首先在安装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。




    400) {this.resized=true; this.width=400; this.alt='Click here to open new window';}" border=0>

    图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.b
    linear
    image=/boot/vmlinuz-2.4.7-10
    label=linux
    root=/dev/hda5
    read-only
    image=/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=1
    timeout=10
    splashimage=(hd0,0)/boot/grub/splash.xpm.gz
    title 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.img
    title 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.img
    title 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
  • 来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10617542/viewspace-949765/ ,如需转载,请注明出处,否则将追究法律责任。

    请登录后发表评论 登录
    全部评论
    • 博文量
      1872
    • 访问量
      4074352