溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

LVS fullnat安裝

發(fā)布時(shí)間:2020-08-07 14:07:11 來源:網(wǎng)絡(luò) 閱讀:10983 作者:ihanxiao2100 欄目:網(wǎng)絡(luò)安全

阿里巴巴開源LVS fullnat  (內(nèi)核要求2.6.32)

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ī)器打造成一臺(tái)功能完備的路由器)、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)格,容易在啟動(dòng)時(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

自動(dòng)啟動(dòng)腳本模板: /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啟動(dòng)時(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     



向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI