请在使用Apache HTTPD 2.4和Tomcat 7配置Load Balancer时需要帮助。我已经看过很多关于此主题的帖子,并设法在一定程度上进行配置。
我面临的一个奇怪问题是,如果我启动2个tomcat实例并尝试浏览APP URL,我会“此网页不可用”。如果我停止一个实例,我可以浏览应用程序。 Apache HTTPD和Tomcat服务器在同一台机器上运行。
workers.properties
worker.list=router,status
worker.worker1.port=8109
worker.worker1.host=172.16.0.79
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
worker.worker1.local_worker=1
worker.worker1.sticky_session=0
worker.worker2.port=8209
worker.worker2.host=172.16.0.79
worker.worker2.type=ajp13
worker.worker2.lbfactor=1
worker.worker2.local_worker=0
worker.worker2.sticky_session=0
worker.router.type=lb
worker.router.balanced_workers=worker1,worker2
worker.router.local_worker_only=1
worker.status.type=status
在httpd.conf
<IfModule mod_proxy.c>
<IfModule mod_proxy_ajp.c>
Include "conf/extra/httpd-ajp.conf"
</IfModule>
</IfModule>
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/jk.log
JkLogLevel debug
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkMount /jk_status status
JkMount /APP/* router
的Server.xml
<Connector port="8109" protocol="AJP/1.3" redirectPort="8443" tomcatAuthentication="false"/>
<Connector port="8209" protocol="AJP/1.3" redirectPort="8443" tomcatAuthentication="false"/>
error.log中
[Fri Aug 29 14:49:49.245851 2014] [ssl:warn] [pid 4312:tid 420] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Aug 29 14:49:49.698251 2014] [ssl:warn] [pid 4312:tid 420] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Aug 29 14:49:49.745051 2014] [mpm_winnt:notice] [pid 4312:tid 420] AH00455: Apache/2.4.9 (Win32) OpenSSL/1.0.1g PHP/5.5.11 mod_jk/1.2.39 configured -- resuming normal operations
[Fri Aug 29 14:49:49.745051 2014] [mpm_winnt:notice] [pid 4312:tid 420] AH00456: Apache Lounge VC11 Server built: Mar 16 2014 12:13:13
[Fri Aug 29 14:49:49.745051 2014] [core:notice] [pid 4312:tid 420] AH00094: Command line: 'C:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Fri Aug 29 14:49:49.745051 2014] [mpm_winnt:notice] [pid 4312:tid 420] AH00418: Parent: Created child process 4156
[Fri Aug 29 14:49:50.571853 2014] [ssl:warn] [pid 4156:tid 296] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Aug 29 14:49:51.008654 2014] [ssl:warn] [pid 4156:tid 296] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Fri Aug 29 14:49:51.055454 2014] [mpm_winnt:notice] [pid 4156:tid 296] AH00354: Child: Starting 150 worker threads.
HTTPD.log
172.17.0.41 - - [29/Aug/2014:14:50:53 -0700] "GET /APP/ HTTP/1.1" 200 1105 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
172.17.0.41 - - [29/Aug/2014:14:50:53 -0700] "GET /APP/index.jsp HTTP/1.1" 401 272 "http://172.16.0.79:8080/APP/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
172.17.0.41 - - [29/Aug/2014:14:50:53 -0700] "GET /APP/index.jsp HTTP/1.1" 401 272 "http://172.16.0.79:8080/APP/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
172.17.0.41 - - [29/Aug/2014:14:50:53 -0700] "GET /APP/index.jsp HTTP/1.1" 401 272 "http://172.16.0.79:8080/APP/" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36"
如果配置有任何问题,请纠正我。提前谢谢。
答案 0 :(得分:0)
Please send your virtualhost mapping also.
I think that httpd is not deciding to whom ajp connector, it should connect.
For simplicity take 2 different router
worker.list=router,router1,status
worker.worker1.port=8109
worker.worker1.host=172.16.0.79
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
worker.worker1.local_worker=1
worker.worker1.sticky_session=0
worker.worker2.port=8209
worker.worker2.host=172.16.0.79
worker.worker2.type=ajp13
worker.worker2.lbfactor=1
worker.worker2.local_worker=0
worker.worker2.sticky_session=0
worker.router.type=lb
worker.router.balanced_workers=worker1
worker.router.local_worker_only=1
worker.router1.type=lb
worker.router1.balanced_workers=worker2
worker.router1.local_worker_only=1
worker.status.type=status
ex:- jkMount /xyz/* router
jkMount /abc/* router1
you can also make 2 virtualhost mapping for different domain or subdomain