Author |
|
kingakoopa
Joined: 21 Feb 2013 Posts: 7 Location: US,TX
|
Posted: Thu 21 Feb '13 21:06 Post subject: Apache & Tomcat Load balancing via Mod_jk issue.... |
|
|
Hello all experts,
I hope this finds you all in the best of your health and spirits.
I have an issue with a new setup where I currently have 1 APACHE 2.2.15 & Tomcat 6.0.14 on RHEL. Mod_JK version 1.2.30.
Ill add the second Tomcat when this starts working.
So when I try to point my browser to apache-host: port i get IT WORKS , but if point browser to host: port //examples/jsp/
i get a 404....apache isnt forwarding requests to Tomcat
Tomcat works fine , i can browse to the JSP examples page and run stuff.
I just cannot do it through the apache.
Any help is very much appreciated...please help!!!!!
Here are my configs....
no virtual hosts configured...
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> |
|
Back to top |
|
kingakoopa
Joined: 21 Feb 2013 Posts: 7 Location: US,TX
|
Posted: Fri 22 Feb '13 6:39 Post subject: |
|
|
anyone?
please? |
|
Back to top |
|
Qmpeltaty
Joined: 06 Feb 2008 Posts: 182 Location: Poland
|
Posted: Fri 22 Feb '13 11:47 Post subject: |
|
|
This config part is misconfigured :
#JkMount /* loadbalancer
JkMount /examples/jsp lb
JkMount /examples/jsp/* lb
Change it to :
#JkMount /* loadbalancer
JkMount /examples/jsp loadbalancer
JkMount /examples/jsp/* loadbalancer
In such cases you should always check mod_jk.log - i'm sure that you would find such error like "can't find worker lb" there. |
|
Back to top |
|
kingakoopa
Joined: 21 Feb 2013 Posts: 7 Location: US,TX
|
Posted: Fri 22 Feb '13 17:22 Post subject: |
|
|
Qmpeltaty,
Thanks for the response.
I fixed it but still nothing...
what else can we look at?
i tried host: port/examples/servlets to view tomcat via apache and i got a 404...
i get this in my mod_jk log
[Fri Feb 22 09:18:47 2013] [5266:47492145348928] [info] init_jk::mod_jk.c (3189): mod_jk/1.2.30 initialized
and this in my error log
[Fri Feb 22 09:20:17 2013] [error] [client 172.31.118.231] File does not exist: /opt/usi/portal/tcpoc/apache2.2.15/htdocs/favicon.ico
[Fri Feb 22 09:20:22 2013] [error] [client 172.31.118.231] File does not exist: /opt/usi/portal/tcpoc/apache2.2.15/htdocs/examples
[Fri Feb 22 09:20:22 2013] [error] [client 172.31.118.231] File does not exist: /opt/usi/portal/tcpoc/apache2.2.15/htdocs/favicon.ico
please help!!! |
|
Back to top |
|
kingakoopa
Joined: 21 Feb 2013 Posts: 7 Location: US,TX
|
Posted: Fri 22 Feb '13 17:54 Post subject: |
|
|
I also moved JkMounts to mod_jk.conf
...now i just get a blank page....it does complain about second worker in mod_jk logs about host is down but i guess thats OK since i dont have worker 2 configured. It should route requests to worker 1 right?
i get this in access logs when i try host: 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
this in error logs
[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
this in 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
i think we are going somewhere.....please help |
|
Back to top |
|
Qmpeltaty
Joined: 06 Feb 2008 Posts: 182 Location: Poland
|
Posted: Sat 23 Feb '13 23:39 Post subject: |
|
|
Your mod_jk.log claims that it can't connect with worker2. Based on lbfactor value half of requests to /examples/jsp should be redirected to worker1 and another half to worker2. It means that at least worker1 should response, so every second request should be successful - but it's not. It means than NONE of the request hits tomcat - let's work to fix that.
I suggest to :
1. Check what is the port of AJP for worker1, check if worker1 really listening on port 8009 and if firewall allows to connect on that port.
2. Fix worker.worker2.port=001 to worker.worker2.port=1 (i know you don't have worker2 but it should be fixed anyway)
3. Add worker1 and worker2 to worker.list :
worker.list=loadbalancer,status,worker1,worker2
You can try to move the JkMount to VHost section f.x. (i always put JkMount directives to virtualhost section).
<Virtualhost localhost:80>
ServerName mydomain.com
JkMount /examples/jsp loadbalancer
JkMount /examples/jsp/* loadbalancer
</Virtualhost> |
|
Back to top |
|
kingakoopa
Joined: 21 Feb 2013 Posts: 7 Location: US,TX
|
Posted: Sun 24 Feb '13 3:37 Post subject: |
|
|
point one helped me....
ajp port had issues in tomcat.syntax error.
and i also moved the JkMounts from workers.props to mod_jk.conf...
works now !!!
Thank you so much....
Appreciate it !!! |
|
Back to top |
|
Qmpeltaty
Joined: 06 Feb 2008 Posts: 182 Location: Poland
|
Posted: Mon 25 Feb '13 14:26 Post subject: |
|
|
Great to hear that i'm happy that i could help.
If i could make a comment I suggest to remove JkMounts from mod_jk.conf - there is two gentle ways to do this :
1. separate file dedicated for that - uriworkermap.properties, which should be included to mod_jk.conf - then you have 3 files in total :
mod_jk - for general configuration
workers.properties - workers configuration
uriworkermap.properties - application mounts
2. JkMount directive within virtualhost block in httpd.conf. If you choose that option then uriworkermap.properties file is not needed. This is the solution i recommend, especially that when your apache holds more than one domain it's the one and only proper solution. |
|
Back to top |
|