我用Apache 2.2通过设置负载均衡器 mod_proxy
和 mod_proxy_balancer
。负载平衡工作正常,但有一种情况我无法找到任何配置选项,即使用到后端服务器的持久连接,当其中一个死亡(关闭,崩溃等)时,现有的连接到它仍然试图访问它。
有没有办法配置apache Load Balancer,以便它退出或重新创建与死后端服务器的连接?在LVS世界中,Ldirector在Proc FS下有一个选项,它可以控制:
/proc/sys/net/ipv4/vs/expire_quiescent_template
设置此项时,将刷新持久会话/连接或死后端服务器,以便在下一个客户端请求时可以重新创建它们。
在Apache世界中有类似的东西吗?
附: Apache以什么方式检查后端服务器的状态?它是否尝试连接到某个端口或类似的东西?如果有人能够对此有所了解,那将是很棒的!
这是我的虚拟主机配置文件:
ServerAdmin admin@mysite.com ServerName myapp.mysite.com
DocumentRoot /srv/www/vhosts/myapp.mysite.com
ErrorLog /var/log/apache2/myapp.mysite.com-error_log
CustomLog /var/log/apache2/myapp.mysite.com-access_log combined
HostnameLookups Off
UseCanonicalName Off
ServerSignature On
ScriptAlias /cgi-bin/ "/srv/www/vhosts/myapp.mysite.com/cgi-bin/"
<Location /balancer-manager>
SetHandler balancer-manager
Order Deny,Allow
Deny from all
Allow from all
</Location>
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from bmf.intern.netz
</Location>
Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
<Proxy balancer://myapp>
BalancerMember http://172.22.1.133:777/ loadfactor=10 route=1 connectiontimeout=200ms
BalancerMember http://172.22.1.134:777/ loadfactor=10 route=2 connectiontimeout=200ms
ProxySet stickysession=ROUTEID
ProxySet lbmethod=byrequests
</Proxy>
ProxyPass /balancer-manager !
ProxyPass /server-status !
ProxyPass / balancer://myapp/ lbmethod=byrequests
ProxyPassReverse / balancer://myapp/
<Directory "/srv/www/vhosts/myapp.mysite.com/cgi-bin">
AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
</Directory>
<IfModule mod_userdir.c>
UserDir public_html
Include /etc/apache2/mod_userdir.conf
</IfModule>
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/srv/www/vhosts/myapp.mysite.com">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>