简体   繁体   English

负载平衡Apache Httpd,Mod_Jk 32位,Tomcat 7,Windows 2008 R2

[英]Load Balance Apache Httpd, Mod_Jk 32bit, Tomcat 7, Windows 2008 R2

Please need help in configuring the Load Balancer with Apache HTTPD 2.4 and Tomcat 7. I have seen many posts on this topic and managed to configure to an extent. 在使用Apache HTTPD 2.4和Tomcat 7配置Load Balancer时,需要帮助。我已经看过很多关于此主题的文章,并设法进行了一定程度的配置。

The strange problem i am facing is if I start 2 instances of tomcat and try to browse the APP URL, I get "This webpage is not available" . 我面临的一个奇怪的问题是,如果我启动了2个tomcat实例并尝试浏览APP URL, 则会显示“此网页不可用” If I stop one instance, I am able browse the App. 如果我停止一个实例,则可以浏览该应用程序。 Apache HTTPD and Tomcat servers are running on the same machine. Apache HTTPD和Tomcat服务器在同一台计算机上运行。

workers.properties worker.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 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 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 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"

Please correct me if any issues in configuration. 如果配置中有任何问题,请纠正我。 Thanks in advance. 提前致谢。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM