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).
相關文章
相關標籤/搜索