91. RX bytes:57811094(55.1MiB) TX bytes:82626323(78.7MiB) 92. 93. lo Link encap:LocalLoopback 94. inet addr:127.0.0.1Mask:255.0.0.0 95. UP LOOPBACK RUNNING MTU:16436Metric:1 96. RX packets:6365 errors:0 dropped:0 overruns:0 frame:0 97. TX packets:6365 errors:0 dropped:0 overruns:0 carrier:0 98. collisions:0 txqueuelen:0 99. RX bytes:8360694(7.9MiB) TX bytes:8360694(7.9MiB) 100. 101. lo:0Link encap:LocalLoopback 102. inet addr:132.96.138.36Mask:255.255.255.255 103. UP LOOPBACK RUNNING MTU:16436Metric:1 104. [root@rserver2 ~]#route add -host 132.96.138.36 dev lo:0 105. [root@rserver2 ~]#route 106. Kernel IP routing table 107. DestinationGatewayGenmaskFlagsMetricRefUseIface 108. 132.96.138.36*255.255.255.255 UH 000 lo 109. 132.96.138.0*255.255.255.128 U 000 eth0 110. 169.254.0.0*255.255.0.0 U 000 eth0 111. default 132.96.138.1260.0.0.0 UG 000 eth0
配置好后在132.96.138.19 上ping 132.96.138.36, 然后用arp 到的MAC地址是【lvs】Director 的MAC地址00:50:56:A3:1F:54 -a 达
1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
[root@lvs ~]#ipvsadm -C
[root@lvs ~]#ipvsadm -A -t 132.96.138.36:80-s wlc
[root@lvs ~]#ipvsadm -a -t 132.96.138.36:80-r 132.96.138.34-g -w 3 [root@lvs ~]#ipvsadm -a -t 132.96.138.36:80-r 132.96.138.35-g -w 1 [root@lvs ~]#ipvsadm -L -n
IP VirtualServer version 1.2.1(size=4096) ProtLocalAddress:PortSchedulerFlags
->RemoteAddress:PortForwardWeightActiveConnInActConn TCP 132.96.138.36:80 wlc
11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54.
->132.96.138.35:80Route100 ->132.96.138.34:80Route300 [root@lvs ~]#ipvsadm -L -n --stats IP VirtualServer version 1.2.1(size=4096)
ProtLocalAddress:PortConnsInPktsOutPktsInBytesOutBytes ->RemoteAddress:Port
TCP 132.96.138.36:80282935003430366394330 ->132.96.138.35:8097911764790129221870 ->132.96.138.34:80185023238640237172460
[root@mysql ~]#ab -n 100000-c 100 http://132.96.138.36/index.html This is ApacheBench,Version2.0.40-dev <$Revision:1.146 $> apache-2.0 Copyright1996AdamTwiss,ZeusTechnologyLtd, http://www.zeustech.net/ Copyright2006TheApacheSoftwareFoundation, http://www.apache.org/
Benchmarking132.96.138.36(be patient) Completed10000 requests Completed20000 requests Completed30000 requests Completed40000 requests Completed50000 requests Completed60000 requests Completed70000 requests Completed80000 requests Completed90000 requests Finished100000 requests
ServerSoftware:Apache/2.2.3 ServerHostname:132.96.138.36 ServerPort:80
DocumentPath:/index.html DocumentLength:22 bytes
ConcurrencyLevel:100
Time taken for tests:8.341010 seconds Complete requests:100000 Failed requests:35280
(Connect:0,Length:35280,Exceptions:0) Write errors:0
Total transferred:29141120 bytes
55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77.
LVS 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19.
HTML transferred:2341120 bytes
Requests per second:11988.96[#/sec](mean) Time per request:8.341[ms](mean)
Time per request:0.083[ms](mean, across all concurrent requests) Transfer rate:3411.82[Kbytes/sec] received
ConnectionTimes(ms)
min mean[+/-sd] median max Connect:0175.303000 Processing:057.0555 Waiting:057.0554 Total:0775.653008
Percentage of the requests served within a certain time (ms) 50%5 66%7 75%8 80%9 90 95 986 998
100008(longest request)
Director
[root@lvs ~]# cat director.sh #!/bin/bash #
# LVS Scripts For VS/DR # chkconfig: - 90 10 #
./etc/rc.d/init.d/functions #
VIP=132.96.138.36 DIP=132.96.138.33 RIP1=132.96.138.34 RIP2=132.96.138.35 PORT=80 RSW1=2 RSW2=5
#
case\in start)
20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55.
/sbin/ifconfig eth0:0 $VIP broadcast $VIP netmask 255.255.255.255 up /sbin/route add -host $VIP dev eth0:0 echo 1>/proc/sys/net/ipv4/ip_forward /sbin/iptables -F /sbin/iptables -Z /sbin/ipvsadm -C
/sbin/ipvsadm -A -t $VIP:80-s wlc
/sbin/ipvsadm -a -t $VIP:80-r $RIP1 -g -w $RSW1 /sbin/ipvsadm -a -t $VIP:80-r $RIP2 -g -w $RSW2 /bin/touch /var/lock/subsys/ipvsadm &>/dev/null echo \ ;;
stop)
echo 0>/proc/sys/net/ipv4/ip_forward /sbin/ipvsadm -C
/sbin/ifconfig eth0:0 down
/bin/rm -f /var/lock/subsys/ipvsadm echo \ ;; status)
if[!-e /var/lock/subsys/ipvsadm ];then fi ;; *)
echo \ ;; esac
echo \ echo \ echo
echo \ ipvsadm -L -n echo
ipvsadm -L -n --stats else
LVS RealServer
1. 2. 3. 4. 5. 6.
[root@rserver2 ~]# cat realserver.sh #!/bin/bash #
# Script to start LVS DR real server. # chkconfig: - 90 10
# description: LVS DR real server