简体   繁体   中英

Configuring Apache in front of Jboss as load balancer

I have my web application deployed in JBoss AS 7.1. After writing middleware code in Java, when I started writing user interface. I thought of using Apache httpd for accessing static resources like css, js and html. Hence I installed httpd 2.4.23 and made configuration changes to access the directory in which I have my static resources. Then I wanted to use httpd as load balancer. For that I installed mod_jk 1.2.41. I created workers.property with following details:

# for mapping requests 
# The configuration directives are valid 
# for the mod_jk version 1.2.18 and later 
worker.list=loadbalancer,status 
# Define node 
# modify the host as your host IP or DNS name. 
worker.node.port=8009
worker.node.host=127.0.0.1 
#(IP or DNS name of the server on which Jboss is running) 
worker.node.type=ajp13 
worker.node.lbfactor=1 
# Load-balancing behaviour 
worker.loadbalancer.type=lb 
worker.loadbalancer.balance_workers=node 
worker.loadbalancer.sticky_session=1 
worker.status.type=status

Here is my mod-jk.conf

LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkShmFile logs/mod_jk.shm
JkLogFile logs/mod_jk.log
JkLogLevel info
JkMount /sb/* loadbalancer
JkMount /sb.web/* loadbalancer

I added this configuration file at the end of httpd.conf:

Include C:/Apache24/conf/mod-jk.conf

I checked my JBoss configuration refering following:

https://docs.jboss.org/author/display/AS71/Using+mod_jk+with+JBoss+AS7#Usingmod_jkwithJBossAS7-Compile%26InstallApacheHttpd

I am not able to acccess my JBoss application using httpd URL. It gives following error log:

::1 - - [01/Aug/2016:01:26:58 +0530] "GET /sb/v1/sc/m/2/ HTTP/1.1" 503 299

mod-jk logs:

 [7132:1928] [info] jk_open_socket::jk_connect.c (817): connect to 127.0.0.1:8009 failed (errno=61)
 [7132:1928] [info] ajp_connect_to_endpoint::jk_ajp_common.c (1068): (node) Failed opening socket to (127.0.0.1:8009) (errno=61)
 [7132:1928] [error] ajp_send_request::jk_ajp_common.c (1728): (node) connecting to backend failed. Tomcat is probably not started or is listening on the wrong port (errno=61)
 [7132:1928] [info] ajp_service::jk_ajp_common.c (2773): (node) sending request to tomcat failed (recoverable), because of error during request sending (attempt=2)
 [7132:1928] [error] ajp_service::jk_ajp_common.c (2794): (node) connecting to tomcat failed (rc=-3, errors=4, client_errors=0).
 [7132:1928] [info] service::jk_lb_worker.c (1595): service failed, worker node is in error state
 [7132:1928] [info] service::jk_lb_worker.c (1675): All tomcat instances are busy or in error state
 [7132:1928] [error] service::jk_lb_worker.c (1680): All tomcat instances failed, no more workers left
 [7132:1928] [info] jk_handler::mod_jk.c (2991): Service error=0 for worker=loadbalancer

I am able to access JBoss application by its own URL and can access static content using httpd URL means both of these servers are running perfectly. Please help.

Make sure Tomcat is running and connecting to port 8009. Please confirm port 8009 is open and listening

Sorry you are working with JBoss but I had same problem with Tomcat that's why I written Tomcat instead of JBoss.

JBoss uses tomcat container only and the mod_jk log showing the below error :

[7132:1928] [info] service::jk_lb_worker.c (1595): service failed, worker node is in error state
 [7132:1928] [info] service::jk_lb_worker.c (1675): All tomcat instances are busy or in error state
 [7132:1928] [error] service::jk_lb_worker.c (1680): All tomcat instances failed, no more workers left

So,it simply means either your backend jboss node is down or is not reachable from the apache.So,see if you are able to 'telnet to jboss ajp port' from the apache machine.If your apache and jboss instance are running on same machine then there should not be any n/w issue.So in such case look for the server.log for same timestamp ie the timestamp when you are getting the error "All tomcat instances are busy or in error state".

But why tomcat. I have JBoss behind Apache https. Why Tomcat is in picture here?

  • You can use any Server as a Backend server.So,it doesn't matter if you are using JBoss or tomcat on backend.As I said earlier; the log contains word as 'tomcat' is just because Jboss uses tomcat container internally.So,in your case you just have to worry about the AJP port listening on 8009 or not;becuase mod_jk uses only AJP protocol.So,make sure you are able to telnet from your Apache to backend Jboss instance. AS you said;your both JBoss and apache is running on same machine;So,make sure you have used the correct port and ip address.Also,see if you are using any port-offset.If yes then change the value accordingly.

    [7132:1928] [error] service::jk_lb_worker.c (1680): All tomcat instances failed, no more workers left

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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