toa模塊是爲了讓後端的realserver可以看到真實的clientip而不是lvs的dip。
php
1、編譯centos6
html
一、下載http://kb.linuxvirtualserver.org/p_w_picpaths/3/34/Linux-2.6.32-220.23.1.el6.x86_64.rs.src.tar.gzlinux
二、解壓
nginx
三、編輯.config,將CONFIG_IPV6=M改爲CONFIG_IPV6=y
vim
測試的時候發現若是不改會遇到報錯,能夠看下這個帖子:http://bbs.linuxtone.org/forum.php?mod=redirect&goto=findpost&ptid=21631&pid=111599後端
四、編輯Makefile,能夠在EXTRAVERSION =處加上自定義的一些說明,將會在uname -r中顯示。好比-shanks.e11.x86_64centos
五、make -jn
bash
六、make modules_installide
七、make install
post
八、修改/boot/grub/grub.conf 用第一個內核啓動
九、reboot
十、裝個nginx,試試看能不能看見真實的clientip。
2、編譯centos5
1~4和centos6同樣
五、多是因爲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
3、打內核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
一、安裝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
二、生成內核源碼目錄
rpmbuild -bp ~/rpmbuild/SPECS/kernel.spec
三、複製一份源碼目錄
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
四、在複製出來的源碼目錄中打阿里提供的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
五、編輯.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
七、刪除原始源碼中的.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
八、生成最終的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
九、編輯KERNEL.SPEC
vim ~/rpmbuild/SPECS/kernel.spec %define distro_build rs.shanks Patch999999: toa.patch ApplyOptionalPatch toa.patch
十、打rpm包
rpmbuild -bb --with baseonly --without kabichk --with firmware --without debuginfo --target=x86_64 ~/rpmbuild/SPECS/kernel.spec
十一、加載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