1.下载ipvsadm
http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz
$ tar vzxf ipvsadm-1.24.tar.gz
$ sudo ln -s /usr/src/kernels/2.6.18-8.el5-x86_64/ /usr/src/linux
$ cd ipvsadm-1.24
$ make
$ sudo make install
检查:$ sudo ipvsadm -v
ipvsadm v1.24 2005/12/10 (compiled with popt and IPVS v1.2.1)
2.配置
a. echo "1" >/proc/sys/net/ipv4/ip_forward
echo "0" >/proc/sys/net/ipv4/conf/all/send_redirects
echo "0" >/proc/sys/net/ipv4/conf/default/send_redirects
echo "0" >/proc/sys/net/ipv4/conf/eth0/send_redirects
echo "0" >/proc/sys/net/ipv4/conf/eth1/send_redirects
b. 清除ipvsadm表
$ sudo ipvsadm -C
c. 使用ipvsadm安装LVS服务
$ sudo ipvsadm -A -t 192.168.192.168:80 -s rr ##192.168.192.168是虚拟IP
d. 增加realserver
$ sudo ipvsadm -a -t 192.168.192.168:80 -r 192.168.1.11:80 -m -w 1
$ sudo ipvsadm -a -t 192.168.192.168:80 -r 192.168.1.128:80 -m -w 1
e. 测试
browser open 192.168.192.168,同时ipvsadm打开。
$ sudo ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.192.168:http rr
-> 192.168.1.128:http Masq 1 0 0
-> 192.168.1.11:http Masq 1 0 0
http://www.linuxvirtualserver.org/software/kernel-2.6/ipvsadm-1.24.tar.gz
$ tar vzxf ipvsadm-1.24.tar.gz
$ sudo ln -s /usr/src/kernels/2.6.18-8.el5-x86_64/ /usr/src/linux
$ cd ipvsadm-1.24
$ make
$ sudo make install
检查:$ sudo ipvsadm -v
ipvsadm v1.24 2005/12/10 (compiled with popt and IPVS v1.2.1)
2.配置
a. echo "1" >/proc/sys/net/ipv4/ip_forward
echo "0" >/proc/sys/net/ipv4/conf/all/send_redirects
echo "0" >/proc/sys/net/ipv4/conf/default/send_redirects
echo "0" >/proc/sys/net/ipv4/conf/eth0/send_redirects
echo "0" >/proc/sys/net/ipv4/conf/eth1/send_redirects
b. 清除ipvsadm表
$ sudo ipvsadm -C
c. 使用ipvsadm安装LVS服务
$ sudo ipvsadm -A -t 192.168.192.168:80 -s rr ##192.168.192.168是虚拟IP
d. 增加realserver
$ sudo ipvsadm -a -t 192.168.192.168:80 -r 192.168.1.11:80 -m -w 1
$ sudo ipvsadm -a -t 192.168.192.168:80 -r 192.168.1.128:80 -m -w 1
e. 测试
browser open 192.168.192.168,同时ipvsadm打开。
$ sudo ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.192.168:http rr
-> 192.168.1.128:http Masq 1 0 0
-> 192.168.1.11:http Masq 1 0 0
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/2723/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
评论列表