阿里巴巴開源LVS fullnat (內(nèi)核要求2.6.32)
成都創(chuàng)新互聯(lián)公司服務(wù)項(xiàng)目包括余干網(wǎng)站建設(shè)、余干網(wǎng)站制作、余干網(wǎng)頁制作以及余干網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,余干網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到余干省份的部分城市,未來相信會繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
1、下載 fullnat LVS源碼
wget https://github.com/alibaba/LVS/tree/lvs_v2 #版本2,建議使用這個(gè)版本
wget https://github.com/alibaba/LVS/archive/master.zip
unzip aster.zip; #解壓下載的源碼,主要有以下文件目錄,其中 kernel目錄是內(nèi)核源碼,tools里有ipvsadm 、keepalived、quagga(可以使用Quagga將linux機(jī)器打造成一臺功能完備的路由器)、rpm
AUTHORS CHANGES docs kernel README.md tools
2、內(nèi)核編譯&安裝
cd /usr/local/src/LVS-lvs_v2/kernel
請先安裝好 perl perl-devel popt popt-devel libnl libnl-devel libssl libssl-devel openssl openssl-devel popt-static yum -y install ncurses ncurses-devel
去 掉 udev,udev的編譯要求比較嚴(yán)格,容易在啟動時(shí)報(bào)udev: missing sysfs features; please update the kernel or disable the kernel's CONFIG_SYSFS_DEPRECATED option;出現(xiàn)這個(gè)錯(cuò)問題也不大
vi .config
CONFIG_SYSFS_DEPRECATED=n
CONFIG_SYSFS_DEPRECATED_V2=n
mkdir -p /usr/src/kernels/2.6.32
make O=/usr/src/kernels/2.6.32 menuconfig; #選擇模塊需要編譯的,exit退出,選擇 YES保存
make mrproper
make O=/usr/src/kernels/2.6.32
make O=/usr/src/kernels/2.6.32 modules_install install
make時(shí)遇錯(cuò)
/bin/sh: perl: command not found
make[2]: *** [scripts/mod/empty.o] Error 127
make[1]: *** [scripts/mod] Error 2
make: *** [scripts] Error 2
解決:yum -y perl perl-devel
make install遇錯(cuò)
WARNING: Couldn't open directory /lib/modules/2.6.32: No such file or directory
解決:ln -s /lib/modules/`uname -r` /lib/modules/2.6.32
問題:make install時(shí)報(bào)
sh /usr/local/src/LVS-lvs_v2/kernel/arch/x86/boot/install.sh 2.6.32 arch/x86/boot/bzImage \
System.map "/boot"
ERROR: modinfo: could not find module sd_mod
ERROR: modinfo: could not find module crc_t10dif
解答:這是因?yàn)楝F(xiàn)在運(yùn)行的kernel有這些模塊,而新編譯的內(nèi)核沒有這些模塊。如果不需要可直接忽視,如果需要編譯到新的內(nèi)核中,請修改 .config的相關(guān)參數(shù)為=m
使用新編譯的內(nèi)核vi /boot/grub/grub.conf 修改
default=0
reboot 重啟系統(tǒng),uname -r查看到的版本應(yīng)該是2.6.32
3、安裝keepalived
要求先安裝好 openssl openssl-devel popt-static
cd /usr/local/src/master/tools/keepalived/
./configure --prefix=/usr/local/keepalived --with-kernel-dir=/usr/local/src/LVS-lvs_v2/kernel;
make;
最終結(jié)果:
Keepalived configuration
------------------------
Keepalived version : 1.2.2
Compiler : gcc
Compiler flags : -g -O2
Extra Lib : -lpopt -lssl -lcrypto -lnl
Use IPVS Framework : Yes
IPVS sync daemon support : Yes
IPVS use libnl : Yes
Use VRRP Framework : Yes
Use Debug flags : No
make install;
默認(rèn)路徑: /usr/local
配置文件: /usr/local/etc/keepalived/keepalived.conf
自動啟動腳本模板: /usr/local/etc/rc.d/init.d/keepalived
復(fù)制安裝目錄下的 /usr/local/keepalived/etc/rc.d/init.d/keepalived 復(fù)制到 /etc/init.d/
把/etc/init.d/keepalived 文件中
. /etc/sysconfig/keepalived 改為
. /usr/local/keepalived/etc/sysconfig/keepalived
keepalived啟動時(shí)報(bào) Starting keepalived: /bin/bash: keepalived: command not found
解決方法: ln -s prefix/sbin/keepalived /usr/sbin/
4、安裝ipvsadm
依賴 libnl libnl-devel libssl-devel libssl
cd /usr/local/src/LVS-lvs_v2/tools/ipvsadm/
make;
make install;
make遇錯(cuò)
gcc -Wall -Wunused -Wstrict-prototypes -g -o ipvsadm ipvsadm.o config_stream.o dynamic_array.o ../keepalived/keepalived/libipvs-2.6/libipvs.a -lpopt -lnl
/usr/bin/ld: cannot find -lnl
collect2: ld returned 1 exit status
make: *** [ipvsadm] Error 1
解決:yum -y install libnl libnl-devel libssl-devel libssl
5、安裝quagga
cd /usr/local/src/LVS-lvs_v2/tools/quagga
./configure --prefix=/usr/local/quagga
make;
make install;
接下來的配置請參照 LVS操作手冊
查看IPVS詳情
查看 /proc/net目錄下的
ip_vs ip_vs_app ip_vs_conn ip_vs_conn_sync ip_vs_ext_stats ip_vs_stats