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 K 1284M 0 141G 0 -> 192.168.183.27:8141 K 0 47298M 0 -> 192.168.183.28:8141 K 0 16249M 0 -> 192.168.183.29:8141 K 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
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/218197.html原文链接:https://javaforall.net
