您好,登錄后才能下訂單哦!
阿里巴巴開源LVS fullnat (內核要求2.6.32)
1、下載 fullnat LVS源碼
wget https://github.com/alibaba/LVS/tree/lvs_v2 #版本2,建議使用這個版本
wget https://github.com/alibaba/LVS/archive/master.zip
unzip aster.zip; #解壓下載的源碼,主要有以下文件目錄,其中 kernel目錄是內核源碼,tools里有ipvsadm 、keepalived、quagga(可以使用Quagga將linux機器打造成一臺功能完備的路由器)、rpm
AUTHORS CHANGES docs kernel README.md tools
2、內核編譯&安裝
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的編譯要求比較嚴格,容易在啟動時報udev: missing sysfs features; please update the kernel or disable the kernel's CONFIG_SYSFS_DEPRECATED option;出現這個錯問題也不大
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時遇錯
/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遇錯
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 /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
解答:這是因為現在運行的kernel有這些模塊,而新編譯的內核沒有這些模塊。如果不需要可直接忽視,如果需要編譯到新的內核中,請修改 .config的相關參數為=m
使用新編譯的內核vi /boot/grub/grub.conf 修改
default=0
reboot 重啟系統,uname -r查看到的版本應該是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;
最終結果:
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;
默認路徑: /usr/local
配置文件: /usr/local/etc/keepalived/keepalived.conf
自動啟動腳本模板: /usr/local/etc/rc.d/init.d/keepalived
復制安裝目錄下的 /usr/local/keepalived/etc/rc.d/init.d/keepalived 復制到 /etc/init.d/
把/etc/init.d/keepalived 文件中
. /etc/sysconfig/keepalived 改為
. /usr/local/keepalived/etc/sysconfig/keepalived
keepalived啟動時報 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遇錯
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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。