Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Search | About

第 125 章 Linux Virtual Server

目录

125.1. 环境配置
125.2. VS/NAT
125.3. VS/TUN
125.4. VS/DR
125.4.1. 配置文件
125.4.1.1. Director
125.4.1.2. RealServer
125.5. ipvsadm script
125.6. Timeout
125.7. debug
125.8. ipvsadm monitor

Session

当选用持久服务(-p选项)支持HTTP session时,来自同一IP地址的请求将被送到同一台服务器。所以在这种状况下,一个ab生成的请求都会被调度到一台服务器,达不到性能测试的目的。在真实系统使用中,持久服务时间一般设置好几个小时。 当ldirectord监测到并且在列表中删除一台应用服务器时,之前有建立连接的,继续转发到这台机上,确实是这样。因为IPVS并不立即淘汰刚删除的服务器,考虑到服务器太忙被删除,可能很快会被加回来。如果你需要马上淘汰已删除服务器的连接,可以用 echo 1 > /proc/sys/net/ipv4/vs/expire_nodest_conn 不用担心记录连接所消耗的内存,因为一个连接只占用128个字节,所以512M可用内存可以支持四百万条连接数。 可以考虑用分布式的测试工具,或者多台机器一起跑ab。

125.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:~$