安装命令行工具:yum install ipvsadm

使用ipvsadm应打开linux的转发功能以及关闭iptables

  lvsadm:

     1.管理集群服务

                      添加:-A  -t|u|f  service-add [-s 调度算法]

                                    -t:tcp协议的集群

                                    -u:udp协议的集群

                                            server-address: ip:port

                                    -f: firewallMark 防火请标记

                                            server-address: Mark Number

                      修改:-E

                      删除:-D -t|u|l    server-address

                  例如添加集群服务:ipvsadm -A -t 172.16.100.1:80 -s rr

     2.管理集群服务中的RS:

                      添加:-a -t|u|f  service-add -r server-add  [-g| l |m] [-w -weight]   

                               -t|u|f  service-add 实现定义好的某集群服务

                                -r server-add 某RS的地址,在NAT模型中,可使用IP:port实现端口映射                                                [-g| l |m]:LVS模型

                                            -g :DR

                                            -i:TUN

                                            -m:NAT

                       修改:-e

                       删除:-d

                         例如添加RS:  ipvsadm -a -t 172.16.100.1:80 -r 192.168.10.10 -m

                                              ipvsadm -a -t 172.16.100.1:80 -r 192.168.10.11 -m

      3.查看

                            -L|l

                                    -n:数字显示主机地址和端口

                                    --stats:统计数据

                                    --rate:显示速率

                                    --timeout: 显示tcp.tcpfin的回话超时时长

                                    -c : 显示当前的ipvs连接状况

       4.删除所有集群服务:

                                -C :清空ipvs规则

       5.保存规则:

                            -S    ipvsadm -S > /root/filename

       6.载入此前规则:

                            -R  ipvsadm -R < /root/filename