Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | Email

第 121 章 Linux Virtual Server

目錄

121.1. 環境配置
121.2. VS/NAT
121.3. VS/TUN
121.4. VS/DR
121.4.1. 配置檔案
121.4.1.1. Director
121.4.1.2. RealServer
121.5. ipvsadm script
121.6. Timeout
121.7. debug
121.8. ipvsadm monitor

Session

當選用持久服務(-p選項)支持HTTP session時,來自同一IP地址的請求將被送到同一台伺服器。所以在這種狀況下,一個ab生成的請求都會被調度到一台伺服器,達不到性能測試的目的。在真實系統使用中,持久服務時間一般設置好幾個小時。 當ldirectord監測到並且在列表中刪除一台應用伺服器時,之前有建立連接的,繼續轉發到這台機上,確實是這樣。因為IPVS並不立即淘汰剛刪除的伺服器,考慮到伺服器太忙被刪除,可能很快會被加回來。如果你需要馬上淘汰已刪除伺服器的連接,可以用 echo 1 > /proc/sys/net/ipv4/vs/expire_nodest_conn 不用擔心記錄連接所消耗的內存,因為一個連接只占用128個位元組,所以512M可用內存可以支持四百萬條連接數。 可以考慮用分散式的測試工具,或者多台機器一起跑ab。

121.1. 環境配置

ssh

neo@ubuntu:~$ sudo apt-get install ssh
		

network

neo@ubuntu:~$ sudo ifconfig eth0 172.16.0.250
neo@ubuntu:~$ sudo route add default gw 172.16.0.254
		

install ipvsadm

neo@ubuntu:~$ apt-cache search ipvsadm
ipvsadm - Linux Virtual Server support programs
neo@ubuntu:~$ sudo apt-get install ipvsadm
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
  heartbeat keepalived ldirectord
The following NEW packages will be installed:
  ipvsadm
0 upgraded, 1 newly installed, 0 to remove and 30 not upgraded.
Need to get 0B/43.9kB of archives.
After unpacking 238kB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously deselected package ipvsadm.
(Reading database ... 16572 files and directories currently installed.)
Unpacking ipvsadm (from .../ipvsadm_1.24+1.21-1.1ubuntu3_i386.deb) ...
Setting up ipvsadm (1.24+1.21-1.1ubuntu3) ...

neo@ubuntu:~$
		

test

neo@ubuntu:~$ sudo ipvsadm
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
neo@ubuntu:~$