RedHat 8.0/9.0 LVS安裝手冊(2)

类别:编程语言 点击:0 评论:0 推荐:

6、给kernel的source file上Patch:

6.1、使用LVS的内核补丁

  上Linux Virtual Server的网页抓取kernel-2.4.0-20的PATCH档案下来,我是抓下面这个档案:

The IPVS Netfilter module for kernel 2.4 - Version 1.0.9 - May 21, 2003 (http://www.linuxvirtualserver.org/software/kernel-2.4/ipvs-1.0.9.tar.gz)

  取得ipvs-1.0.9.tar.gz 这个档案

  我试过抓linux-2.4.20-ipvs-1.0.9.patch.gz 这个档案,但是从来没有compile成功过,所以放弃。

6.2、将ipvs-1.09.tar.gz解开,放在/usr/src/source/ipvs-1.0.9这个目录下,然后在这个目录下,输入

# make patchkernel # make installsource

  将IPVS的Patch加载到kernel的source中

6.3、加载 "hidden"的patch

  可以到http://mail.incredimail.com/howto/lvs/install/src/ 这个目录中抓取(hidden-2.4.20pre10-1.diff)这个patch档案,放在/usr/src/linux目录下,利用:

# cat hidden-2.4.20pre10-1.diff | patch -p1

  对Kernel进行patch,非常感谢Alex提供上述Patch。

  注意:为什么这里要对kernel进行hidden的patch,因为在使用LVS中的DR与IP Tunnel的时候,会需要有一块网络卡要设定两个IP的情形,但是Linux在2.2.14之后,就将eth0:1的-NOARP这个FLAG关闭。也就是说在kernel 2.2.14以后,eth0:1就视为eth0的别名,任何对eth0:1的设定也同样作用在eth0,换句话说,我对eth0:1下-NOARP,同样也会对eth0有作用,这样会使得整张网络卡收不到封包。

  在上述两种模式下,因为我所有的机器都放在同一个网段,当该网段的Router接收到客户端(Client)对虚拟IP(Virtual IP)的TCP connection要求时,会先在网段中利用Arp request询问谁有VIP的地址,而包含Director与RealServers上所有的interface(不管Primary还是Subinterface),只要他有那个ip,都会发送arp reply回去,造成网段内所有拥有Virtual IP的interface都会reply给Router,最后结果就是看谁的速度快,Router就将该封包送给谁,如此会造成LVS的Server并无法发挥其效果,因此需要利用hidden这个pattch,将Subinterface上的Virtual IP给隐藏起来,如此他就不会对Arp Request进行Reply,如此就可以解决ARP的问题,而这个NOARP的问题,kernel发展小组认为不重要,所以以后都不会修改,要用请自行编译。事实上,解法不只一种,我这儿只使用比较简单的一种。资料来源:(http://www.linuxvirtualserver.org/Joseph.Mack/HOWTO/LVS-HOWTO.arp_problem.html)。

7、接着安装cipe 1.5.4的这个版本(如果已经安装,记得先移除后,改用下面这个rpm),http://mail.incredimail.com/howto/lvs/install/package/ 这个目录中有。cipe 1.4.5无法使用,因为1.4.5有Bug,所以一定要确定cipe的版本是1.5.4,且一定要安装cipe否则等一下无法compile ipvs的东西。

  注意:先用rpm -qa |grep cipe查查看是不是已经有cipe存在,如果存在,请用rpm -e cipe 将之移除,再用rpm -ivh cipe-xxx.rpm 安装。否则编译kernel的模块的时候会失败。

  所有准备工作到此告一段落。接着正式进入compile kernel的重要阶段。

8、开始compile kernel,

# cd /usr/src/linux # make oldconfig # (会去读取.config的资料,并会问你有关ipvs的一些设定,全部用M回答),按下Enter。 # make dep # make modules # make bzImage

  这里我顺序有点颠倒…可是无所谓…?

# make modules_install # make install

9、至于最后的make install,如果你用lilo开机,他会给你一个错误讯息,但是必要的档案已经都有了,如果是grub就没有问题。

-rw-r--r-- 1 root root 129736 7月 28 15:51 initrd-2.4.20-19.8custom.img lrwxrwxrwx 1 root root 28 7月 28 15:58 System.map -> System.map-2.4.20-19.8custom -rw-r--r-- 1 root root 519383 7月 28 15:51 System.map-2.4.20-19.8custom -rw-r--r-- 1 root root 1118581 7月 28 15:51 vmlinuz-2.4.20-19.8custom

10、如果用lilo开机,修改/etc/lilo.conf如下面格式:

prompt timeout=350 boot=/dev/hda map=/boot/map install=/boot/boot.b message=/boot/message lba32 # optional other=/dev/hda1 optional label=WinXP-Home image=/boot/vmlinuz-2.4.20-18.8 label=linux_old append="root=LABEL=/" read-only optional initrd=/boot/initrd-2.4.20-18.8.img image=/boot/vmlinuz-2.4.20-19.8custom label=linux_new root=/dev/hda5 append="devfs=mount" read-only optional initrd=/boot/initrd-2.4.20-19.8custom.img

  因为我的/是mount在/dev/hda5下,所以你只要稍加修改即可。

  如果是用grub开机,他会自动设定好/boot/grub.conf

default=1 timeout=10 splashimage=(hd0,0)/boot/grub/splash.xpm.gz title Red Hat Linux (2.4.20-19.8custom) root (hd0,0) kernel /boot/vmlinuz-2.4.20-19.8custom ro root=LABEL=/ initrd /boot/initrd-2.4.20-19.8custom.img title Red Hat Linux (2.4.20-18.8bigmem) root (hd0,0) kernel /boot/vmlinuz-2.4.20-18.8bigmem ro root=LABEL=/ initrd /boot/initrd-2.4.20-18.8bigmem.img title Red Hat Linux-smp (2.4.18-14smp) root (hd0,0) kernel /boot/vmlinuz-2.4.18-14smp ro root=LABEL=/ initrd /boot/initrd-2.4.18-14smp.img title Red Hat Linux-up (2.4.18-14) root (hd0,0) kernel /boot/vmlinuz-2.4.18-14 ro root=LABEL=/ initrd /boot/initrd-2.4.18-14.img

11、重新开机(shutdown -i 6 now)

12、选择linux_new(lilo)或Red Hat Linux (2.4.20-19.8custom)开机,看看开机过程有没有错误发生。然后检查/proc/sys/net/ipv4/conf/all/hidden是不是存在?

13、如果都没有错误,安装下列rpm

rpm -ivh ipvsadm-1.21-4.i386.rpm

14、试验一下 输入:

[root@nbaa boot]# ipvsadm IP Virtual Server version 1.0.9 (size=65536) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn

  出现上面画面就是成功啦!!!

15、后续的动作就依照你的网络状态,去作规划了,后续进行中。

本文地址:http://com.8s8s.com/it/it23432.htm