ubuntu lvs配置
系統:全部都是 ubuntu 12.04
ip:
負載服務器:192.168.1.164
vip:192.168.1.166
真實服務器1:192.168.1.164
真實服務器2:192.168.1.163
(實驗時負載服務器也作為真實服務器使用)
負載服務器:
sudo apt-get install ipvsadm
sudo ifconfig eth0:0 192.168.1.166 netmask 255.255.255.0 broadcast 192.168.1.166
sudo route add -host 192.168.1.166 dev eth0:0
sudo echo "1">/proc/sys/net/ipv4/ip_forward
sudo ipvsadm -A -t 192.168.1.166:5222 -s rr
sudo ipvsadm -a -t 192.168.1.166:5222 -r 192.168.1.164:5222 -g
sudo ipvsadm -a -t 192.168.1.166:5222 -r 192.168.1.163:5222 -g
真實服務器:
sudo ifconfig lo:0 192.168.1.166 netmask 255.255.255.255 broadcast 192.168.1.166 up
sudo route add -host 192.168.1.166 dev lo:0
sudo echo "1">/proc/sys/net/ipv4/ip_forward
說明:以上配置系統重啟以後無效,需重新配置一遍