Apache 和 Tomcat 通过 Mod_jk 进行负载平衡的问题

Apache 和 Tomcat 通过 Mod_jk 进行负载平衡的问题

希望大家身体健康,精神饱满。我的新设置有问题,目前我在 RHEL 上安装了 1 个 APACHE 2.2.15 和 Tomcat 6.0.14。Mod_JK 版本 1.2.30。当它开始工作时,我会添加第二个 Tomcat。

因此,当我尝试将浏览器指向 apache-host:port 时,它工作正常,但如果将浏览器指向 host: port //examples/jsp/,我得到 404....apache 不会将请求转发到 Tomcat Tomcat 工作正常,我可以浏览到 JSP 示例页面并运行程序。我只是无法通过 apache 做到这一点。非常感谢任何帮助...请帮忙!!!!!

这是我的配置....没有配置虚拟主机...

HTTPD.CONF 
Include conf/jk/mod_jk.conf 
LoadModule jk_module modules/mod_jk.so 

MOD_JK.CONF 
JkWorkersFile conf/jk/workers.properties 
JkShmFile logs/mod_jk.shm 
JkLogFile logs/mod_jk.log 
JkLogLevel info 
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " 

WORKERS.PROPERTIES 
worker.list=loadbalancer,status 

# Node #1 properties 
worker.worker1.type=ajp13 
worker.worker1.host=localhost 
worker.worker1.port=8009 
worker.worker1.lbfactor=1 

# Node #2 properties(will be configured later when apache and node 1 start working) 
worker.worker2.type=ajp13 
worker.worker2.host=localhost 
worker.worker2.port=001 
worker.worker2.lbfactor=1 

# Load-balancing behaviour 
worker.loadbalancer.type=lb 
worker.loadbalancer.balance_workers=worker1,worker2 

# Status worker for managing load balancer 
worker.status.type=status 

#JkMount /* loadbalancer 
JkMount /examples/jsp lb 
JkMount /examples/jsp/* lb 


tomcat server.xml has this 
<Service name="Catalina"> 
... 
<!-- Define an AJP 1.3 Connector on port 8009 --> 
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> 
... 
</Service>

答案1

工人属性

# Load-balancing behaviour 
worker.loadbalancer.type=lb 
worker.loadbalancer.balance_workers=worker1,worker2 

#JkMount /* loadbalancer 
JkMount /examples/jsp lb 
JkMount /examples/jsp/* lb

这是错误的。将JkMount指令移至mod_jk.conf,如下所示:

JkWorkersFile conf/jk/workers.properties 
JkShmFile logs/mod_jk.shm 
JkLogFile logs/mod_jk.log 
JkLogLevel info 
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " 

JkMount /examples/jsp loadbalancer
JkMount /examples/jsp/* loadbalancer

请注意,Tomcat 工作程序应该loadbalancer按照您在 中定义的方式workers.properties,而不是lb

答案2

修复了这两个问题...现在我只得到一个空白页....它确实在 mod_jk 日志中抱怨第二个工作器主机已关闭,但我想这没关系,因为我没有配置工作器 2。它应该将请求路由到工作器 1,对吗?

当我尝试主机:port/examples/jsp 时,我在访问日志中收到此信息

172.31.118.231 - - [22/Feb/2013:09:27:09 -0600] "GET /examples/jsp HTTP/1.1" 200 -
172.31.118.231 - - [22/Feb/2013:09:27:21 -0600] "GET /examples/jsp HTTP/1.1" 200 -
172.31.118.231 - - [22/Feb/2013:09:27:21 -0600] "GET /favicon.ico HTTP/1.1" 404 209
172.31.118.231 - - [22/Feb/2013:09:28:06 -0600] "GET /examples/jsp HTTP/1.1" 200 -
172.31.118.231 - - [22/Feb/2013:09:28:07 -0600] "GET /favicon.ico HTTP/1.1" 404 209

在错误日志中

[Fri Feb 22 09:26:00 2013] [error] [client 172.31.118.231] File does not exist: /opt/fas/loader/tomproj/apache2.2.15/htdocs/examples

在 mod_jklogs 中

[Fri Feb 22 09:25:27 2013] [5773:47624974852416] [info] init_jk::mod_jk.c (3189): mod_jk/1.2.30 initialized
[Fri Feb 22 09:26:45 2013] [5777:1119607104] [info] jk_open_socket::jk_connect.c (622): connect to 127.0.0.1:1 failed (errno=111)
[Fri Feb 22 09:26:45 2013] [5777:1119607104] [info] ajp_connect_to_endpoint::jk_ajp_common.c (959): Failed opening socket to (127.0.0.1:1) (errno=111)
[Fri Feb 22 09:26:45 2013] [5777:1119607104] [error] ajp_send_request::jk_ajp_common.c (1585): (worker2) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111)
[Fri Feb 22 09:26:45 2013] [5777:1119607104] [info] ajp_service::jk_ajp_common.c (2540): (worker2) sending request to tomcat failed (recoverable), because of error during request sending (attempt=1)
[Fri Feb 22 09:26:45 2013] [5777:1119607104] [info] jk_open_socket::jk_connect.c (622): connect to 127.0.0.1:1 failed (errno=111)
[Fri Feb 22 09:26:45 2013] [5777:1119607104] [info] ajp_connect_to_endpoint::jk_ajp_common.c (959): Failed opening socket to (127.0.0.1:1) (errno=111)
[Fri Feb 22 09:26:45 2013] [5777:1119607104] [error] ajp_send_request::jk_ajp_common.c (1585): (worker2) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=111)
[Fri Feb 22 09:26:45 2013] [5777:1119607104] [info] ajp_service::jk_ajp_common.c (2540): (worker2) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
[Fri Feb 22 09:26:45 2013] [5777:1119607104] [error] ajp_service::jk_ajp_common.c (2559): (worker2) connecting to tomcat failed.
[Fri Feb 22 09:26:45 2013] [5777:1119607104] [info] service::jk_lb_worker.c (1388): service failed, worker worker2 is in error state

它的

相关内容