您的位置:首页 > 其它

ipvsadm 命令积累

2015-06-29 09:10 232 查看
查看内核是否支持 ipvsadm
[test@LVS ~]$ /sbin/modprobe -l|grep ipvs
/lib/modules/2.6.18-308.el5/kernel/net/ipv4/ipvs/ip_vs.ko
/lib/modules/2.6.18-308.el5/kernel/net/ipv4/ipvs/ip_vs_dh.ko
/lib/modules/2.6.18-308.el5/kernel/net/ipv4/ipvs/ip_vs_ftp.ko
/lib/modules/2.6.18-308.el5/kernel/net/ipv4/ipvs/ip_vs_lblc.ko
/lib/modules/2.6.18-308.el5/kernel/net/ipv4/ipvs/ip_vs_lblcr.ko
/lib/modules/2.6.18-308.el5/kernel/net/ipv4/ipvs/ip_vs_lc.ko
/lib/modules/2.6.18-308.el5/kernel/net/ipv4/ipvs/ip_vs_nq.ko
/lib/modules/2.6.18-308.el5/kernel/net/ipv4/ipvs/ip_vs_rr.ko
/lib/modules/2.6.18-308.el5/kernel/net/ipv4/ipvs/ip_vs_sed.ko
/lib/modules/2.6.18-308.el5/kernel/net/ipv4/ipvs/ip_vs_sh.ko
/lib/modules/2.6.18-308.el5/kernel/net/ipv4/ipvs/ip_vs_wlc.ko
/lib/modules/2.6.18-308.el5/kernel/net/ipv4/ipvs/ip_vs_wrr.ko
如果不支持,就安装 ipvsadm
yum -y install ipvsadm
ipvsadm 参数详解:
-C 清除表中所有的记录-A --add-service在服务器列表中新添加一条新的虚拟服务器记录-t 表示为tcp服务-u 表示为udp服务-s --scheduler 使用的调度算法, rr | wrr | lc | wlc | lblb | lblcr | dh | sh | sed | nq 默认调度算法是 wlcipvsadm -a -t 192.168.3.187:80 -r 192.168.200.10:80 -m -w 1-a --add-server 在服务器表中添加一条新的真实主机记录-t --tcp-service 说明虚拟服务器提供tcp服务-u --udp-service 说明虚拟服务器提供udp服务-r --real-server 真实服务器地址-m --masquerading 指定LVS工作模式为NAT模式-w --weight 真实服务器的权值-g --gatewaying 指定LVS工作模式为直接路由器模式(也是LVS默认的模式)-i --ipip 指定LVS的工作模式为隧道模式-p 会话保持时间,定义流量呗转到同一个realserver的会话存留时间
[test@LVS ~]$ sudo /sbin/ipvsadm -l
IP Virtual Server version 1.2.1 (size=4096)Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port           Forward Weight ActiveConn InActConnTCP  192.1.17.10:http wlc
-> 10.2.4.35:http            Route   100    25095      18542
-> 10.2.4.31:http            Route   100    25097      17657
-> 10.2.4.30:http            Route   100    25123      18953
-> 10.2.4.29:http            Route   100    25091      18727
-> 10.2.4.24:http            Route   100    25075      17703
-> 10.2.4.23:http            Route   100    25086      17465
-> 10.2.4.22:http            Route   100    25124      17628
InActConn 指非活跃连接数,我们将处于 TCP ESTABLISH 状态以外的连接都称为不活跃连接。例如处于 SYN_RECV 状态的连接,处于 TIME_WAIT 状态的连接等。
[test@LVS ~]$ sudo /sbin/ipvsadm -l --rate
IP Virtual Server version 1.2.1 (size=4096)Prot LocalAddress:Port                 CPS    InPPS   OutPPS    InBPS   OutBPS
-> RemoteAddress:PortTCP  192.1.17.10:http               2438    16241        0  6385560        0
-> 10.2.4.35:http                 146      965        0   372714        0
-> 10.2.4.34:http                 164     1089        0   423347        0
-> 10.2.4.28:http                 152     1035        0   406658        0
-> 10.2.4.27:http                 157     1031        0   411744        0
-> 10.2.4.22:http                 160     1078        0   425447        0
-> 10.2.4.21:http                 159     1078        0   423759        0
--rate选项是显示速率信息
CPS      (current connection rate)   每秒连接数
InPPS    (current in packet rate)  每秒的入包个数
OutPPS   (current out packet rate)   每秒的出包个数
InBPS    (current in byte rate)      每秒入流量(字节)
OutBPS   (current out byte rate)     每秒入流量(字节)
[test@LVS ~]$ sudo /sbin/ipvsadm -l --statsIP Virtual Server version 1.2.1 (size=4096)Prot LocalAddress:Port               Conns   InPkts  OutPkts  InBytes OutBytes
-> RemoteAddress:PortTCP 192.1.17.10:http            326629K    3588M        0   22517G        0
-> 10.2.4.23:http             584349K    3896M        0    1469G        0
-> 10.2.4.34:http             597422K    3956M        0    1501G        0
-> 10.2.4.28:http             631106K    4198M        0    1592G        0
-> 10.2.4.27:http             578297K    3850M        0    1459G        0
-> 10.2.4.22:http             580208K    3859M        0    1463G        0
-> 10.2.4.21:http             685758K  283146K        0    1737G        0
--stats
选项是统计自该条转发规则生效以来的
Conns (connections scheduled) 已经转发过的连接数

InPkts (incoming packets) 入包个数

OutPkts (outgoing packets) 出包个数

InBytes (incoming bytes) 入流量(字节)

OutBytes (outgoing bytes) 出流量(字节)

修改 LVS 表中的 fin_timeout 使用指令如下
ipvsadm --set 900 60 300
中间的 60 就是 tcp 的 fin_timeout 时间
查看默认的值使用如下命令:
$ sudo /sbin/ipvsadm -Ln --timeout Timeout (tcp tcpfin udp): 900 60 300
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  命令积累