Centos install mod_jk

1、sudo yum -y install httpd-devel

2、wget http://www.apache.org/dist/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.37-src.tar.gz

3、tar -xvf tomcat-connectors-1.2.37-src.tar.gz

4、cd ~/tomcat-connectors-1.2.37-src
cd native/
./configure –with-apxs=/usr/sbin/apxs
make
sure make install
5、cd /etc/httpd/conf.d
touch mod_jk.conf

LoadModule jk_module modules/mod_jk.so

JkWorkersFile conf.d/workers.properties

JkMount /*.jsp controller

JkMount /*.do controller

JkMount /logs* controller

JkMount /manager* controller

JkMount /probe* controller

<Location /app/>

JkMount controller

</Location>

touch workers.properties

worker.list = controller,tomcat1,tomcat2,tomcat3,tomcat4

#========tomcat1========

worker.tomcat1.port=9091

worker.tomcat1.host=127.0.0.1

worker.tomcat1.type=ajp13

worker.tomcat1.lbfactor = 1

worker.tomcat1.socket_keepalive=true

#worker.tomcat1.max_packet_size=16384

#========tomcat2========

worker.tomcat2.port=9092

worker.tomcat2.host=127.0.0.1

worker.tomcat2.type=ajp13

worker.tomcat2.lbfactor = 1

worker.tomcat2.socket_keepalive=true

worker.tomcat3.port=9093

worker.tomcat3.host=127.0.0.1

worker.tomcat3.type=ajp13

worker.tomcat3.lbfactor = 1

worker.tomcat3.socket_keepalive=true

worker.tomcat4.port=8409

worker.tomcat4.host=localhost

worker.tomcat4.type=ajp13

worker.tomcat4.lbfactor = 1

worker.tomcat4.socket_keepalive=true

worker.controller.type=lb

worker.controller.balanced_workers=tomcat1,tomcat2,tomcat3

#worker.controller.balanced_workers=tomcat1,tomcat3,tomcat4

#worker.controller.balanced_workers=tomcat4

#worker.controller.balanced_workers=tomcat1

worker.controller.sticky_session=1

6、关闭selinux

vi /etc/selinux/config

SELINUX=disabled

7实现负载均衡 proxy_module方式
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

# always keep the host header
ProxyPreserveHost On

# map to cluster
ProxyPass /test balancer://my_cluster/test stickysession=JSESSIONID nofailover=On
ProxyPass /demo balancer://my_cluster/demo stickysession=JSESSIONID nofailover=On

# define the balancer, with http and/ or ajp connections
<Proxy balancer://my_cluster>
BalancerMember ajp://yourjettyhost1:8009
BalancerMember ajp://yourjettyhost2:8009
</Proxy>

8、nginx的upstream模块

参考资料

http://www.crypt.gen.nz/selinux/disable_selinux.html

https://wiki.library.ucsf.edu/display/~128507@ucsf.edu/Install+mod_jk+on+CentOS

http://docs.codehaus.org/display/JETTY/Configuring+AJP13+Using+mod_jk

http://www.tomcatexpert.com/knowledge-base/setting-modproxybalancer

原创文章,转载请注明: 转载自海波无痕

本文链接地址: Centos install mod_jk

文章的脚注信息由WordPress的wp-posturl插件自动生成

此条目发表在server分类目录,贴了, , , , , 标签。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注

评论链接可以 移除 nofollow.