ipvsadm 常用命令

1.查看是否支持ipvs

 modprobe -l|grep ipvs

2.ipvsadm 命令详解

-C 清除表中所有的记录
-A --add-service在服务器列表中新添加一条新的虚拟服务器记录
-t 表示为tcp服务
-u 表示为udp服务
-s --scheduler 使用的调度算法, rr | wrr | lc | wlc | lblb | lblcr | dh | sh | sed | nq 默认调度算法是 wlc
ipvsadm -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的会话存留时间

3. ipvsadm -ln

IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.182.140:8141 wrr
  -> 192.168.183.27:8141          Route   1      171        2153      
  -> 192.168.183.28:8141          Route   1      150        2148      
  -> 192.168.183.29:8141          Route   1      154        2150     

InActConn 指非活跃连接数,我们将处于 TCP ESTABLISH 状态以外的连接都称为不活跃连接。例如处于 SYN_RECV 状态的连接,处于 TIME_WAIT 状态的连接等。

4. ipvsadm -ln  --rate   

IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port                 CPS    InPPS   OutPPS    InBPS   OutBPS
  -> RemoteAddress:Port
TCP  192.168.182.140:8141               54      288        0    31825        0
  -> 192.168.183.27:8141                18       95        0    10384        0
  -> 192.168.183.28:8141                18       96        0    10884        0
  -> 192.168.183.29:8141                18       97        0    10556        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) 每秒入流量(字节)

5. ipvsadm -l --stats

IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port               Conns   InPkts  OutPkts  InBytes OutBytes
  -> RemoteAddress:Port
TCP  192.168.184.140:8141          236321K    1284M        0     141G        0
  -> 192.168.183.27:8141          78774050  428108K        0   47298M        0
  -> 192.168.183.28:8141          26222992  143000K        0   16249M        0
  -> 192.168.183.29:8141          26222982  143012K        0   16252M        0

--stats 选项是统计自该条转发规则生效以来的

  • Conns (connections scheduled) 已经转发过的连接数
  • InPkts (incoming packets) 入包个数
  • OutPkts (outgoing packets) 出包个数
  • InBytes (incoming bytes) 入流量(字节)
  • OutBytes (outgoing bytes) 出流量(字节)

6.修改 LVS 表中的 fin_timeout 使用指令如下  

ipvsadm --set  900 60 300

中间的 60 就是 tcp 的 fin_timeout 时间  

查看默认的值使用如下命令:

ipvsadm -ln --timeout

Timeout (tcp tcpfin udp): 900 120 300

 

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值