Search code examples
apacheload-balancingtomcat6

can i change ajp connector in place of default port 8009 in apache tomcat for load balancing?


I am using mod_jk-1.2.31-httpd-2.2.x.so for Load Balancing with Apcahe 2.2.15 and multiple instance of apache tomcat 6 on RHEL6 LINUX OS. I have create workers.properties

     worker.list=stat,balancer   
     worker.worker1.port=8019  
     worker.worker1.host=localhost   
     worker.worker1.type=ajp13  
     worker.worker1.lbfactor=1   
     worker.worker2.port=8029  
     worker.worker2.host=localhost   
     worker.worker2.type=ajp13  
     worker.worker2.lbfactor=1   
     worker.balancer.type=lb  
     worker.stat.type=status  
     worker.balancer.balance_workers=worker1,worker2  
     worker.balancer.method=B   
     worker.balancer.sticky_session=True

In httpd.conf

LoadModule jk_module modules/mod_jk-1.2.31-httpd-2.2.x.so

# Load workers files from the config directory "/etc/httpd/conf".    
JkWorkersFile /etc/httpd/conf/workers.properties
## Path to jk logs 
JkLogFile logs/mod_jk.log 
JkShmFile run/mod_jk.shm
# Jk log level [debug/error/info] 
JkLogLevel info
# Jk log format 
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions for forwarding 
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format 
JkRequestLogFormat "%w %V %T" 
JkMount /status stat 
JkMount /Oa balancer 
JkMount /Oa/* balancer

If calling Mount Webproject Oa then in log mod_jk.log

[Thu Dec 03 12:54:41 2015] [22380:140534825461728] [info]
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized

[Thu Dec 03 12:54:41 2015] [22381:140534825461728] [info]
init_jk::mod_jk.c (3198): mod_jk/1.2.31 (1026297) initialized

[Thu Dec 03 12:54:48 2015] stat newoag.iitk.ac.in 0.000353 [Thu Dec
03 12:55:52 2015] [22385:140534825461728] [info]
jk_open_socket::jk_connect.c (626): connect to 127.0.0.1:8019 failed
(errno=13)

[Thu Dec 03 12:55:52 2015] [22385:140534825461728] [info]
ajp_connect_to_endpoint::jk_ajp_common.c (959): Failed opening
socket to (127.0.0.1:8019) (errno=13)

[Thu Dec 03 12:55:52 2015] [22385:140534825461728] [error]
ajp_send_request::jk_ajp_common.c (1578): (worker1) connecting to
backend failed. Tomcat is probably not started or is listening on
the wrong port (errno=13)

[Thu Dec 03 12:55:52 2015] [22385:140534825461728] [info]
ajp_service::jk_ajp_common.c (2543): (worker1) sending request to
tomcat failed (recoverable), because of error during request sending
(attempt=1)

[Thu Dec 03 12:55:53 2015] [22385:140534825461728] [info]
jk_open_socket::jk_connect.c (626): connect to 127.0.0.1:8019 failed
(errno=13)

[Thu Dec 03 12:55:53 2015] [22385:140534825461728] [info]
ajp_connect_to_endpoint::jk_ajp_common.c (959): Failed opening
socket to (127.0.0.1:8019) (errno=13)

[Thu Dec 03 12:55:53 2015] [22385:140534825461728] [error]
ajp_send_request::jk_ajp_common.c (1578): (worker1) connecting to
backend failed. Tomcat is probably not started or is listening on
the wrong port (errno=13)

[Thu Dec 03 12:55:53 2015] [22385:140534825461728] [info]
ajp_service::jk_ajp_common.c (2543): (worker1) sending request to
tomcat failed (recoverable), because of error during request sending
(attempt=2)

[Thu Dec 03 12:55:53 2015] [22385:140534825461728] [error]
ajp_service::jk_ajp_common.c (2562): (worker1) connecting to tomcat
failed.

[Thu Dec 03 12:55:53 2015] [22385:140534825461728] [info]
service::jk_lb_worker.c (1388): service failed, worker worker1 is in
error state

[Thu Dec 03 12:55:53 2015] [22385:140534825461728] [info]
jk_open_socket::jk_connect.c (626): connect to 127.0.0.1:8029 failed
(errno=13)

[Thu Dec 03 12:55:53 2015] [22385:140534825461728] [info]
ajp_connect_to_endpoint::jk_ajp_common.c (959): Failed opening
socket to (127.0.0.1:8029) (errno=13)

[Thu Dec 03 12:55:53 2015] [22385:140534825461728] [error]
ajp_send_request::jk_ajp_common.c (1578): (worker2) connecting to
backend failed. Tomcat is probably not started or is listening on
the wrong port (errno=13)

[Thu Dec 03 12:55:53 2015] [22385:140534825461728] [info]
ajp_service::jk_ajp_common.c (2543): (worker2) sending request to
tomcat failed (recoverable), because of error during request sending
(attempt=1)

[Thu Dec 03 12:55:53 2015] [22385:140534825461728] [info]
jk_open_socket::jk_connect.c (626): connect to 127.0.0.1:8029 failed
(errno=13)

[Thu Dec 03 12:55:53 2015] [22385:140534825461728] [info]
ajp_connect_to_endpoint::jk_ajp_common.c (959): Failed opening
socket to (127.0.0.1:8029) (errno=13)

Please suggest me, Can I used ajp connector 8019,8029.. in place of default port 8009? How it is working? Please send document if any for load balacing of multiple instance of tomcat in one system.


Solution

  • In RHEL6, SELinux is enforce mode in defualt, for access port set mode Permissive for SELinux

    setenforce 0
    

    you can view mode of SELinux

    getenforce