標題: [分享] 安裝 LVS NAT 於 RHEL v4.0 [打印本頁]
作者: adj 時間: 2007-11-30 13:16 標題: 安裝 LVS NAT 於 RHEL v4.0
RHEL 的各版本已經將IPVS Module 化了...所以只要下指令...就可以知道有沒有支援:
# grep "CONFIG_IP_VS" /boot/config-`uname -r`複製內容到剪貼板
代碼:
CONFIG_IP_VS=m <= 看到這個就代表已經Module 化
# CONFIG_IP_VS_DEBUG is not set
CONFIG_IP_VS_TAB_BITS=12
CONFIG_IP_VS_PROTO_TCP=y
CONFIG_IP_VS_PROTO_UDP=y
CONFIG_IP_VS_PROTO_ESP=y
CONFIG_IP_VS_PROTO_AH=y
CONFIG_IP_VS_RR=m
CONFIG_IP_VS_WRR=m
CONFIG_IP_VS_LC=m
CONFIG_IP_VS_WLC=m
CONFIG_IP_VS_LBLC=m
CONFIG_IP_VS_LBLCR=m
CONFIG_IP_VS_DH=m
CONFIG_IP_VS_SH=m
CONFIG_IP_VS_SED=m
CONFIG_IP_VS_NQ=m
CONFIG_IP_VS_FTP=m
(1)安裝前要先執行兩個動作...先將底下個行載入模組寫入 /etc/modules
echo ip_vs_dh >> /etc/modules
echo ip_vs_ftp >> /etc/modules
echo ip_vs >> /etc/modules
echo ip_vs_lblc >> /etc/modules
echo ip_vs_lblcr >> /etc/modules
echo ip_vs_lc >> /etc/modules
echo ip_vs_nq >> /etc/modules
echo ip_vs_rr >> /etc/modules
echo ip_vs_sed >> /etc/modules
echo ip_vs_sh >> /etc/modules
echo ip_vs_wlc >> /etc/modules
echo ip_vs_wrr >> /etc/modules
(2)載入模組
modprobe ip_vs_dh
modprobe ip_vs_ftp
modprobe ip_vs
modprobe ip_vs_lblc
modprobe ip_vs_lblcr
modprobe ip_vs_lc
modprobe ip_vs_nq
modprobe ip_vs_rr
modprobe ip_vs_sed
modprobe ip_vs_sh
modprobe ip_vs_wlc
modprobe ip_vs_wrr
If you get errors, then most probably your kernel wasn't compiled with IPVS support, and you need to compile a new kernel with IPVS support (or install a kernel image with IPVS support) now.
(3)ipvsadm 檔案下載:
ftp://ftp.isu.edu.tw/pub/Linux/C ... adm-1.24-6.i386.rpm
執行安裝:
#rpm -Uvh ipvsadm-1.24-6.i386.rpm
(4)記得要設定 iptables NAT
#vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
#iptables -A POSTROUTING -t nat -s 192.168.0.0/255.255.255.0 -j MASQUERADE
(5)增加一個 rr 模式於 LVS-NAT
#ipvsadm -A -t 203.204.26.149:80 -s rr
#ipvsadm -a -t 203.204.26.149:80 -r 192.168.0.2 -m
#ipvsadm -a -t 203.204.26.149:80 -r 192.168.0.3 -m
PS: "-m 表 LVS-NAT" "-g 表 VS-DR" "-i 表 VS-TUN"
這樣就已經產生一個 LVS-NAT...觀看方式
#ipvsadm
IP Virtual Server version 1.2.0 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 203.204.26.149:http rr
-> 192.168.0.2:http Masq 1 0 0
-> 192.168.0.3:http Masq 1 0 0
PS: "ActiveConn 表 正連線至該真實伺服器的數目"
"InActConn 表 已轉送至該真實伺服器的總連線數"
(6)寫入檔案
#ipvsadm-save > /etc/sysconfig/ipvsadm
以後要重新起動...只需要執行
#service ipvsadm restart
日後機器重新開機...要自動載入...
#chkconfig ipvsadm on
做到這邊大致上已經大功告成囉...
參考文章:
http://www.debianhelp.co.uk/ultramonkey.htm
歡迎光臨 ADJ網路實驗室 (http://dz.adj.idv.tw/) |
Powered by Discuz! 6.0.0 |