Apache,Tomcat:显示空白页面的负载平衡和故障转移配置。

时间:2016-01-11 13:16:29

标签: java apache tomcat load-balancing failover

我正在使用mod_jk为现有的Apache tomcat设置添加负载平衡和故障转移功能。为此,我设置了2个Tomcat实例。我做了一些改变,并将粘贴它们。我没有在httpd或tomcat的日志中收到任何错误,我只看到一个空白页面。我做错了什么?

Apache webserver config:

workers.properties:

worker.list=loadbalancer
 worker.server1.port=8010
 worker.server1.host=localhost
 worker.server1.lbfactor=1
 worker.server1.type=ajp13


 worker.server2.port=8011
 worker.server2.host=localhost
 worker.server2.type=ajp13
 worker.server2.lbfactor=1


 worker.loadbalancer.type=lb
 worker.loadbalancer.balance_workers=server1,server2

worker.loadbalancer.sticky_session=true
worker.myworker.sticky_session_force=True

apache2.conf / httpd.conf:

Include sites-enabled/

LoadModule jk_module modules/mod_jk.so
JkWorkersFile /etc/apache2/workers.properties
JkLogFile   /etc/apache2/mod_jk.log
JkMount /* loadbalancer

sites-enabled / 000-default:仅包含:

 JkMountCopy On

第一个tomcat的server.xml:

<Server port="8005" shutdown="SHUTDOWN">

 <Connector port="8081" protocol="org.apache.coyote.http11.Http11NioProtocol" connectionTimeout="20000"/>

  <Connector port="8010" protocol="AJP/1.3" redirectPort="8081" URIEncoding="utf-8"
 compressableMimeType="text/html,text/xml,text/plain,text/css,text/ javascript,application/x-javascript,application/javascript"
/>
<Engine name="Catalina" defaultHost="localhost" jvmRoute="server1">
         <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster">
</Cluster>
    </Engine>

第二个Tomcat的server.xml:

<Server port="8006" shutdown="SHUTDOWN">

 <Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol" connectionTimeout="20000"/>
 <Connector port="8011" protocol="AJP/1.3" redirectPort="8080" URIEncoding="utf-8"
 compressableMimeType="text/html,text/xml,text/plain,text/css,text/ javascript,application/x-javascript,application/javascript"
/>
  <Engine name="Catalina" defaultHost="localhost" jvmRoute="server2">
     <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster">
  </Cluster>
        </Engine>

即使我关闭任何tomcat,我看到的只是一个空白页面。我究竟做错了什么?请告诉我。非常感谢..: - )

1 个答案:

答案 0 :(得分:0)

JkMount之外指定任何VirtualHost指令通常不值得。您应该具体并将它们映射到每个VH。

JkMountCopy应该适合你。我怀疑其他一些配置正在干扰它。