How to configure Apache and Tomcat to realize the load balancing?
2015-07-30 17:22
691 查看
How to configure Apache and Tomcat to realize the load balancing?
1. Apache: add following to the end of httpd.conf
apache address: 10.12.22.53
ProxyRequests Off
ProxyPass / balancer://abc/ nofailover=On
<Proxy balancer://abc/>
BalancerMember ajp://10.12.22.91:8009 loadfactor=1 route=jvm91
BalancerMember ajp://10.12.22.100:8039 loadfactor=1 route=jvm100
</Proxy>
There are two tomcat servers, 10.12.22.91 and 10.12.22.100 and ajp ports 8009 and 8039 respective.
2. Tomcat server.xml
10.12.22.91
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm91">
10.12.22.100
<Connector port="8039" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm100">
Notice, AJP port and jvmRoute need be matched along with the httpd.conf.
3. http://10.12.22.53/gridserver
sometimes it cannot success for firewall, you can close the firewall, or open the ajp port at iptables.
you can see the status via "serivce iptables status"
you can add&remove the port via "vim /etc/consys/iptables"
for add ajp port 8009 via adding the line
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8009 -j ACCEPT
and if you want to reject the port via deleting the line
1. Apache: add following to the end of httpd.conf
apache address: 10.12.22.53
ProxyRequests Off
ProxyPass / balancer://abc/ nofailover=On
<Proxy balancer://abc/>
BalancerMember ajp://10.12.22.91:8009 loadfactor=1 route=jvm91
BalancerMember ajp://10.12.22.100:8039 loadfactor=1 route=jvm100
</Proxy>
There are two tomcat servers, 10.12.22.91 and 10.12.22.100 and ajp ports 8009 and 8039 respective.
2. Tomcat server.xml
10.12.22.91
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm91">
10.12.22.100
<Connector port="8039" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm100">
Notice, AJP port and jvmRoute need be matched along with the httpd.conf.
3. http://10.12.22.53/gridserver
sometimes it cannot success for firewall, you can close the firewall, or open the ajp port at iptables.
you can see the status via "serivce iptables status"
you can add&remove the port via "vim /etc/consys/iptables"
for add ajp port 8009 via adding the line
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8009 -j ACCEPT
and if you want to reject the port via deleting the line
相关文章推荐
- Tomcat中ServletContextListener监听器重复执行的有关问题,Myeclipse指定发布地址
- eclipse启动tomcat访问不到主页
- Java内存溢出详解+Tomcat配置文件中JVM的启动参数设置
- tomcat的接口设置和tomcat的中文字符集设置
- jenkins+maven+tomcat热部署问题
- Nginx + Tomcat 动静分离
- Linux部署安装JDK和Tomcat
- tomcat部署web项目的3中方法
- 在CentOS linux 正常配置 tomcat7
- tomcat服务器相关配置
- tomcat管理员密码设置
- myeclipse集成jdk、tomcat8、maven、svn
- eclipse 修改tomcat的启动限制时间
- 菜鸟遇到的第一个servlet问题(404,弹出对话框)
- CXF+Spring+Tomcat开发webservice接口,并添加SSL双向认证
- solr5.2.1+tomcat8.0.23+zookeeper3.4.6
- 生产环境下Tengine keepalived tomcat 安装和配置
- 关于Apache和Tomcat的关系说明
- Tomcat_Broken pipe
- Maven零散笔记——常用配置(tomcat-maven-plugin)