Loadbalancing 3 tomcat 7 instances with mod_jk gives 'Could not find worker' - apache

I'm posting this after checking out several other posts that seem to have the same issue but I can't solve my problem with the help of any of these.
Situation:
-I am using Windows 8 Professional
-I installed 3 tomcat instances on my localhost
-I installed Apache 2.4 with mod_jk to be used as my loadbalancer
What I'm trying to achieve is:
-Goto localhost/APPNAME (which is the Apache 2.4), Apache will now redirect my call to one of the 3 Tomcat 7 instances and give me the requested page.
This is the first time I'm doing this so probably I'm forgetting something somewhere. What I have now is this:
The Tomcat 7 server.xml's look like this:
1st Tomcat has:
<Connector port="8081" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">
2nd Tomcat has:
<Connector port="8082" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8444" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8444" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2">
3rd Tomcat has:
<Connector port="8083" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8445" />
<Connector port="8011" protocol="AJP/1.3" redirectPort="8445" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat3">
For the Apache server I added to the httpd.conf:
LoadModule jk_module modules/mod_jk.so
<IfModule jk_module>
Include conf/extra/mod_jk.conf
</IfModule>
The mod_jk.conf looks like this:
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkShmFile logs/jk-runtime-status
JkLogStampFormat "[%b %d %Y - %H:%M:%S] "
JkRequestLogFormat "%w %V %T"
JkMountCopy All
JkMount /* balancer
#JkMount /* tomcat1
#JkMount /* tomcat2
#JkMount /* tomcat3
And finally my workers.properties file looks like this:
worker.tomcat1.type=ajp13
worker.tomcat1.port=8009
worker.tomcat1.host=localhost
worker.tomcat1.lbfactor=1
worker.tomcat2.type=ajp13
worker.tomcat2.port=8010
worker.tomcat2.host=localhost
worker.tomcat2.lbfactor=1
worker.tomcat3.type=ajp13
worker.tomcat3.port=8011
worker.tomcat3.host=localhost
worker.tomcat3.lbfactor=1
#configure the loadbalancer
worker.balancer.type=lb
worker.balancer.balance_workers=tomcat1,tomcat2,tomcat3
worker.balancer.method=B
worker.balancer.sticky_session=True
worker.stat.type=status
Now I have started all mu tomcat instances first, then I start my Apache. It will now give me the following message in the mod_jk.log:
[Dec 12 2014 - 12:23:58] [3180:8452] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized
[Dec 12 2014 - 12:23:58] [3180:8452] [error] extension_fix::jk_uri_worker_map.c (578): Could not find worker with name 'balancer' in uri map post processing.
[Dec 12 2014 - 12:23:58] [3180:8452] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized
[Dec 12 2014 - 12:23:58] [3180:8452] [error] extension_fix::jk_uri_worker_map.c (578): Could not find worker with name 'balancer' in uri map post processing.
[Dec 12 2014 - 12:23:58] [9912:8284] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized
[Dec 12 2014 - 12:23:58] [9912:8284] [error] extension_fix::jk_uri_worker_map.c (578): Could not find worker with name 'balancer' in uri map post processing.
[Dec 12 2014 - 12:23:59] [9912:8284] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized
[Dec 12 2014 - 12:23:59] [9912:8284] [error] extension_fix::jk_uri_worker_map.c (578): Could not find worker with name 'balancer' in uri map post processing.
Which of course means that I doesn't work. Can anyone please help me and give me an idea what I'm doing wrong?

Okay, I got it to work. It seems that I used an Apache Server which causes the problem.
I was searching a bit more and more specific on this forum and found this post:
httpd AND Tomcat with mod_jk on Port 80 test fails
Thanks to this answer I decided to try a different Apache download too.
From the Apache site I used download to the Apache Haus version of Apache for Windows. I could not get it to work. However, I downloaded another version from the website, copied all my settings, and now it works!

Related

Mod_Jk Load balancing

I tried everything possible to make Mod_jk work with no success. I tried multiple Apache downloads, tried every recommendation I could find including checking for special characters... both Apache and Tomcat are working as anticipated but still no load balancing and I keep getting these error messages. Any idea?
[1640:3636] [info] init_jk::mod_jk.c (3383): mod_jk/1.2.40 initialized
[1640:3636] [error] extension_fix::jk_uri_worker_map.c (578): Could not find worker with name 'LoadBalancer' in uri map post processing.
[1640:3636] [error] extension_fix::jk_uri_worker_map.c (578): Could not find worker with name 'jk-status' in uri map post processing.
I am using Apache 2.4.23 and Mod_Jk 1.2.4 both for Windows 32 bit.
in Httpd.conf:
Listen 10.x.x.x:80
LoadModule jk_module modules/mod_jk.so
<IfModule jk_module>
JkWorkersFile conf/workers.properties
JkShmFile logs/mod_jk.shm
JkLogFile logs/mod_jk.log
JkLogLevel info
JkWatchdogInterval 60
<Location /jk-status>
JkMount jk-status
Order deny,allow
Deny from all
Allow from 10.4.81.62
</Location>
<Location /jk-manager>
JkMount jk-manager
Order deny,allow
Deny from all
Allow from 10.4.81.62
</Location>
# Configure applications
JkMount /Geoserver/* LoadBalancer
</IfModule>
in workers.properties:
workers.list=jk-status
worker.jk-status.type=status
worker.list=jk-manager
worker.jk-manager.type=status
workers.list=LoadBalancer
worker.LoadBalancer.type=lb
worker.balancer.error_escalation_time=0
worker.balancer.max_reply_timeouts=10
worker.worker1.type=ajp13
worker.worker1.host=10.x.x.x
worker.worker1.port=8009
worker.worker1.lbfactor=1
worker.worker1.activation=A
worker.worker1.socket_connect_timeout=5000
worker.worker1.socket_keepalive=true
worker.worker2.type=ajp13
worker.worker2.host=10.x.x.x
worker.worker2.port=8010
worker.worker2.lbfactor=1
worker.worker2.activation=A
worker.worker2.socket_connect_timeout=5000
worker.worker2.socket_keepalive=true
worker.LoadBalancer.balance_workers=worker1,worker2
in Tomcat-1 server.xml:
<Engine name="Catalina" defaultHost="10.x.x.x" jvmRoute="worker1">
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
in Tomcat-2 server.xml:
<Engine name="Catalina" defaultHost="10.x.x.x" jvmRoute="worker2">
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
You have a single-character error in your workers.properties file:
workers.list=LoadBalancer
should be:
worker.list=LoadBalancer
You have the same problem with the jk-status worker.
(Sorry you've been killing yourself over this.)

Tomcat worker not working

This is on CentOS 7 system, apache 2.4.6, java jdk1.8.0_77, tomcat 7
http://www.example.com:8080/manager/html shows tomcat application manager and my_application running.
httpd.conf includes:
IncludeOptional conf.d/*.conf
in conf.d folder, the file gau.conf contains:
LoadModule jk_module modules/mod_jk.so
LoadModule proxy_ajp_module /usr/lib64/httpd/modules/mod_proxy_ajp.so
JkWorkersFile /etc/httpd/conf/workers.properties
JkShmFile /var/log/httpd/mod_jk.shm
JkLogFile /var/log/httpd/mod_jk_log
JkLogLevel info
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
RewriteEngine On
RewriteRule ^/servlet.gupld(.*)$ /path_to_detect/servlet.gupld [PT,QSA,L]
JkMount /path_to_detect worker1
JkMount /path_to_detect/* worker1
workers.properties file is:
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=1
server.xml contains:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" address="0.0.0.0" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
The js file can be accessed on tomcat port:
http://www.example.com:8080/path_to_detect/file.js
I expect this file to be accessed on 80 port (but served by tomcat):
http://www.example.com/path_to_detect/file.js
But a 404 Not Found error is shown.
java -version:
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
nmap -6 ::1 -p 8009:
Starting Nmap 6.40 ( http://nmap.org ) at 2016-04-10 14:20 UTC
Nmap scan report for localhost.localdomain (::1)
Host is up (-1100s latency).
PORT STATE SERVICE
8009/tcp open ajp13
log files are not showing any error.
Please help.
The solution is:
change JkLogLevel from "info" to "debug" and restart apache,
try to access using the worker and check mod_jk_log
mod_jk_log shows "jk_translate::mod_jk.c (3855): missing uri map for"
add "JkMountCopy all" in my conf file (gau.conf)
restart.
Thanks.

Load balancer not forwarding request to second tomcat instance

I am running 2 instance of tomcat on my machine with following entries in server.xml in both tomcat :
Tomcat 1::
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8444" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the BIO implementation that requires the JSSE
style configuration. When using the APR/native implementation, the
OpenSSL style configuration is required as described in the APR/native
documentation -->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThrea="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8010" protocol="AJP/1.3" redirectPort="8444" />
Tomcat2 : server.xml::
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the BIO implementation that requires the JSSE
style configuration. When using the APR/native implementation, the
OpenSSL style configuration is required as described in the APR/native
documentation -->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
Both tomcat instances are running parallel.
Now i introduced load balancer with following entries in /etc/httpd/httpd.conf file at last
#
# Load mod_jk
#
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkLogLevel debug
JkLogLevel warn
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkMount / loadbalancer
JkMount /* loadbalancer
And with workers.properties file as::
worker.list=loadbalancer
worker.jvm1.port=8009
worker.jvm1.host=127.0.0.1
worker.jvm1.type=ajp13
worker.jvm1.lbfactor=1
worker.jvm1.max_packet_size=65536
#worker.jvm1.socket_timeout=60
#worker.jvm1.connection_pool_timeout=60
worker.jvm2.port=8010
worker.jvm2.host=127.0.0.1
worker.jvm2.type=ajp13
worker.jvm2.lbfactor=1
worker.jvm2.max_packet_size=65536
#worker.jvm2.socket_timeout=60
#worker.jvm2.connection_pool_timeout=60
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=jvm1,jvm2
worker.loadbalancer.sticky_session=0
worker.jvm1.socket_keepalive=1
worker.jvm2.socket_keepalive=1
worker.loadbalancer.method=B
Now on restarting the httpd services and then restaring the tomcat and performing testing , i found that load balancer is only forwarding re
quest to tomcat1 and not to tomcat2. I increased the request rate to 1000 request per second , still no forwarding to tomcat2.
In worker.properties , i disabled jvm1 and then restarted httpd and tomcat2. I am getting following error::
==> error_log <==
[Fri Jul 04 15:44:52 2014] [error] (111)Connection refused: proxy: HTTP: attempt to connect to 127.0.0.1:8080 (paisa-tomcat) failed
[Fri Jul 04 15:44:52 2014] [error] ap_proxy_connect_backend disabling worker for (paisa-tomcat)
==> error_log <==
[Fri Jul 04 15:44:52 2014] [error] proxy: HTTP: disabled connection for (paisa-tomcat)
==> error_log <==
[Fri Jul 04 15:44:52 2014] [error] proxy: AJP: disabled connection for (paisa-tomcat)
I think its "worker.loadbalancer.method=B":
If set to B[usyness] the balancer will pick the worker with the lowest current load, based on how many requests the worker is currently serving. This number is divided by the workers lbfactor, and the lowest value (least busy) worker is picked. This method is especially interesting, if your request take a long time to process, like for a download application.
Try to set it to "N" for round-robin, and i.e. use two different browsers, to test.

Apache 2.4 Tomcat7 and mod_jk

I want to connect apache2.4 with tomcat7
My configuration is:
workers.properties
workers.tomcat_home=/var/lib/tomcat7
workers.java_home=/usr/lib/jvm/java-7-oracle
worker.list=worker1
worker.worker1.type=ajp13
worker.worker1.host=domain.com
worker.worker1.port=8009
in jk.conf:
JkWorkersFile /etc/apache2/workers.properties
JkLogStampFormat "[%b %d %Y - %H:%M:%S] "
JkRequestLogFormat "%w %V %T"
#JkAutoAlias /var/lib/tomcat7/webapps
#JkMountCopy All
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkMount /ROOT/ worker1
JkMount /ROOT/* worker1
When i resterting apache i have an error:
[Jun 13 2014 - 11:32:50] [23256:140183177717632] [info] init_jk::mod_jk.c (3365): mod_jk/1.2.37 initialized
[Jun 13 2014 - 11:32:50] [23256:140183177717632] [error] extension_fix::jk_uri_worker_map.c (564): Could not find worker with name 'jk-manager' in uri map post processing.
[Jun 13 2014 - 11:32:50] [23256:140183177717632] [error] extension_fix::jk_uri_worker_map.c (564): Could not find worker with name 'jk-status' in uri map post processing.
[Jun 13 2014 - 11:32:50] [23257:140183177717632] [info] init_jk::mod_jk.c (3365): mod_jk/1.2.37 initialized
[Jun 13 2014 - 11:32:50] [23257:140183177717632] [error] extension_fix::jk_uri_worker_map.c (564): Could not find worker with name 'jk-manager' in uri map post processing.
[Jun 13 2014 - 11:32:50] [23257:140183177717632] [error] extension_fix::jk_uri_worker_map.c (564): Could not find worker with name 'jk-status' in uri map post processing.
Do you know what is wrong ?
I cannot open application, i have empty page.
You can ignore those errors referencing 'jk-manager' and 'jk-status' unless you want to enable management of the mod.
You need to move the JK mount directive in to the VirtualHost section of your website. You can add the following to /etc/apache2/sites-available/default
<VirtualHost *:80>
...
# Send everything for /* to worker1
JkMount /* worker1
...
</VirtualHost>
It looks like maybe you're missing a configuration for jk-manager and jk-status. You just need to write them into your workers.properties file. (And if you don't have the tomcat admin package, I believe you need it. If you don't want to install anything, just check out the 'Alternatively' section at the bottom of this post.)
If you can't find workers.properties file, have a look at your apache config, for example: grep -r JkWorkersFile /etc/apache2. The config should contain something like the following, which indicates the path of the workers.properties file:
<IfModule jk_module>
JkWorkersFile /etc/libapache2-mod-jk/workers.properties
# ...
</IfModule>
In your workers.properties file:
Make sure you have the following or something like it:
# configure jk-status
worker.list=jk-status
worker.jk-status.type=status
worker.jk-status.read_only=true
# configure jk-manager
worker.list=jk-manager
worker.jk-manager.type=status
Alternatively
Alternatively, you can just remove the XML elements that define jk-manager and jk-status from your Apache config.

Apache httpd 2.2.x + mod_jk 1.2.30 + tomcat 6 Error: Could not find worker with name 'XXXXX' in uri map post processing

I am getting the following error while setting up the load balancer with two Tomcat instances:
[info] mod_jk.c (3189): mod_jk/1.2.30 initialized
[error] jk_uri_worker_map.c (506): Could not find worker with name 'loadmanager' in uri map post processing.
Following are my configuration settings:
httpd.conf changes
# Include mod_jk configuration file
Include conf/mod_jk.conf
mod_jk.conf
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMount /TestLB1/ loadmanager
JkMount /TestLB1/* loadmanager
JkShmFile logs/jk.shm
workers.properties
worker.list=loadmanager
worker.tomcat1.port=18081
worker.tomcat1.host=localhost
worker.tomcat1.type=ajp13
worker.tomcat1.lbfactor=1
worker.tomcat2.port=28081
worker.tomcat2.host=localhost
worker.tomcat2.type=ajp13
worker.tomcat2.lbfactor=1
worker.loadmanager.type=lb
worker.loadmanager.balance_workers=tomcat1,tomcat2
worker.loadmanager.sticky_session=True
In Tomcat's server.xml I have set the jvmRoute attribute to Engine also
<Engine defaultHost="localhost" name="Catalina" jvmRoute="tomcat1">
<Engine defaultHost="localhost" name="Catalina" jvmRoute="tomcat2">
Both the Tomcat instances are up and running fine with AJP ports 18081 & 28081 respectively.
But while starting the Apache httpd.exe the mod_jk log files always shows the above error, and when I try to access my web app through http://localhost/TestLB1 nothing comes up.
Any Solution?
Got the problem....
Issues is with the text editor in which i was editing my worker.properties file , it adds few special chars to files.
I found them when i opend the files in notepad only.
After removing all unwanted chars everythings works perfect.
Create your worker.properties file with a good text editor like notepad++. Not doing so may add some unseen special characters and workers.properties file wont parse by mod_jk.