toa模塊是爲了讓後端的realserver能夠看到真實的clientip而不是lvs的dip。
一、編譯centos6
1、下載http://kb.linuxvirtualserver.org/p_w_picpaths/3/34/Linux-2.6.32-220.23.1.el6.x86_64.rs.src.tar.gz
2、解壓
3、編輯.config,將CONFIG_IPV6=M改成CONFIG_IPV6=y
測試的時候發現如果不改會遇到報錯,可以看下這個帖子:http://bbs.linuxtone.org/forum.php?mod=redirect&goto=findpost&ptid=21631&pid=111599
4、編輯Makefile,可以在EXTRAVERSION =處加上自定義的一些說明,將會在uname -r中顯示。比如-shanks.e11.x86_64
5、make -jn
6、make modules_install
7、make install
8、修改/boot/grub/grub.conf 用第一個內核啓動
9、reboot
10、裝個nginx,試試看能不能看見真實的clientip。
二、編譯centos5
1~4和centos6一樣
5、可能是由於centos5和6的區別還是很大的,所以在centos5上編譯2.6.32的時候,需要讓內核還是用舊的sysfs,否則會kernel panic。
在.config中添加這兩行,有的話就直接改,沒有添上
CONFIG_SYSFS_DEPRECATED=y
CONFIG_SYSFS_DEPRECATED_V2=y
之後的操作就和centos6的一樣了(5~10)
參考:http://kb.linuxvirtualserver.org/wiki/IPVS_FULLNAT_and_SYNPROXY
http://ssmax.net/archives/1198.html
三、打內核rpm包(適用於centos6)
事先準備:
下載Linux-2.6.32-220.23.1.el6.x86_64.rs.src.tar.gz和kernel-2.6.32-220.23.1.el6.src.rpm到/usr/local/src
1、安裝kernel-2.6.32-220.23.1.el6.src.rpm
rpm -ivh /usr/local/src/kernel-2.6.32-220.23.1.el6.src.rpm
2、生成內核源碼目錄
rpmbuild -bp ~/rpmbuild/SPECS/kernel.spec
3、複製一份源碼目錄
cd ~/rpmbuild/BUILD/kernel-2.6.32-220.23.1.el6/ cp -a linux-2.6.32-220.23.1.el6.x86_64/ linux-2.6.32-220.23.1.el6.x86_64_new
4、在複製出來的源碼目錄中打阿里提供的toa補丁
cd ~/rpmbuild/BUILD/kernel-2.6.32-220.23.1.el6/linux-2.6.32-220.23.1.el6.x86_64_new/ patch -p1 < /usr/local/src/linux-2.6.32-220.23.1.el6.x86_64.rs/toa-2.6.32-220.23.1.el6.patch
5、編輯.config
#在linux-2.6.32-220.23.1.el6.x86_64_new中 sed -i 's/CONFIG_IPV6=m/CONFIG_IPV6=y/g' .config echo -e '\n# toa\nCONFIG_TOA=m' >> .config
6、拷貝.config至SOURCE
#在linux-2.6.32-220.23.1.el6.x86_64_new中,會提示覆蓋,直接覆蓋即可 cp .config ~/rpmbuild/SOURCES/config-x86_64-generic
7、刪除原始源碼中的.config
cd ~/rpmbuild/BUILD/kernel-2.6.32-220.23.1.el6/linux-2.6.32-220.23.1.el6.x86_64 rm -rf .config
8、生成最終的patch
cd ~/rpmbuild/BUILD/kernel-2.6.32-220.23.1.el6/ diff -uNr linux-2.6.32-220.23.1.el6.x86_64 linux-2.6.32-220.23.1.el6.x86_64_new/ > ~/rpmbuild/SOURCES/toa.patch
9、編輯KERNEL.SPEC
vim ~/rpmbuild/SPECS/kernel.spec %define distro_build rs.shanks Patch999999: toa.patch ApplyOptionalPatch toa.patch
10、打rpm包
rpmbuild -bb --with baseonly --without kabichk --with firmware --without debuginfo --target=x86_64 ~/rpmbuild/SPECS/kernel.spec
11、加載toa模塊
vim /etc/sysconfig/modules/toa.modules #!/bin/bash modprobe toa >/dev/null 2>&1 chmod u+x /etc/sysconfig/modules/toa.modules reboot [root@localhost ~]# lsmod |grep toa toa 4203 0
done