lvs可使用-p (persistent )参数对session进行保持

测试环境:
web1 : 192.168.12.160
web2 : 192.168.12.161
lvs或lvs+keepalived : 192.168.12.191
1,在没有使用keepalived状况下在脚本中加入-p 参数,默认时间300秒(/sbin/ipvsadm -A -t $VIP:8080 -s wrr -p 300)
2,在keepalived使用状况下,在配置文件虚拟服务下加入persistence_timeout 300 参数
3,测试访问页面 : http://192.168.12.100:8080/index2.jsp
 
测试过程: 1,没有加入参数状况下设置轮询机制,不停刷新和转变页面状况下,lvs会将访问转到不停的地方
2,加了参数后,不停刷新和转变页面状况下,会话会在必定时间内保持在一台机器上。
 
lvs操做流程
1.存在就根据该链接发包
2.不存在,是新链接,则开始调度

若是vs是普通服务器,则执行调度算法选择一个rs,而后建立链接,而后发送
若是vs是p服务器,则先看看是否有模板可用,若是有,则根据该模板建立链接,而后发包
若是没有模板可用,就执行调度器调度一个rs并建立模板,而后根据该模板建立链接,最后发包
 
以上是我从网上找的,我理解p服务器就是加了-P参数的设置机器,模板能够用ipvsdam -lcn来查看。在ipvsadm -L 查看链接已经断开的状况下,其实还有这个链接的模板,这样LVS在加了-p参数后时间失效状况下,还会按照模板来分配到之前访问那个地址,当模板失效不存在后,才会按照算法重新分配链接的机器。ipvsadm模板保持时间默认为15分钟,
 
 
---------------------------------------------------------------------------------------------------------------------------------------------------------------
ipvsdam会话保持参数man:
-p, --persistent [timeout]
Specify that a virtual service is persistent. If this option is specified, multiple requests from a
client are redirected to the same real server selected for the first request. Optionally, the timeout
of persistent sessions may be specified given in seconds, otherwise the default of 300 seconds will be
used. This option may be used in conjunction with protocols such as SSL or FTP where it is important
that clients consistently connect with the same real server.
 
Note: If a virtual service is to handle FTP connections then persistence must be set for the virtual
service if Direct Routing or Tunnelling is used as the forwarding mechanism. If Masquerading is used in
conjunction with an FTP service than persistence is not necessary, but the ip_vs_ftp kernel module must
be used. This module may be manually inserted into the kernel using insmod(8).
相关文章
相关标签/搜索