LVS-学习目录
1、什么是持久化连接
lvs persistence 持久连接 ,无论使用任何调度算法,在一段时间内(默认300s),能够实现将来自同一个地址的请求始终发往同一个 RS
2、持久化连接配置
2.1、查询当前的规则
lvs ~]# ipvsadm -L -n
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.87.200:80 rr
-> 192.168.87.129:80 Route 1 0 0
-> 192.168.87.130:80 Route 1 0 0
2.2、编辑当前集群持久化连接
2.2.1、编辑【-p 30】
ipvsadm -E -t 192.168.87.200:80 -p 30
# 持久化30分钟
2.2.2、查询当前的规则
lvs ~]# ipvsadm -L -n
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.87.200:80 wlc persistent 30
-> 192.168.87.129:80 Route 1 0 0
-> 192.168.87.130:80 Route 1 0 0
3、访问测试
3.1、客户端访问
[root@route ~]# curl 192.168.87.200
rs-02
[root@route ~]# curl 192.168.87.200
rs-02
[root@route ~]# curl 192.168.87.200
rs-02
[root@route ~]# curl 192.168.87.200
rs-02
[root@route ~]# curl 192.168.87.200
rs-02
# 都是相同的rs节点的
3.2、查询持久化时效
lvs ~]# ipvsadm -L -n -c
IPVS connection entries
pro expire state source virtual destination
TCP 00:47 NONE 192.168.87.132:0 192.168.87.200:80 192.168.87.130:80
TCP 01:17 FIN_WAIT 192.168.87.132:60722 192.168.87.200:80 192.168.87.130:80