我安装了3台服务器和Ubuntu,我想配置Tomcat负载平衡。
Server A = 10.0.0.1,
Server B = 10.0.0.2,
Server C = 10.0.0.3
我已将域指向服务器A,该服务器已安装Apache和Mod_JK。服务器B和C有Apache Tomcat 8.下面是我的workers.properties文件的详细信息
workers.apache_log=/var/log/apache2 worker.list=tomcatlb,status worker.stat1.type=status worker.tomcat1.type=ajp13 worker.tomcat1.host=10.0.0.2 #put your app host here worker.tomcat1.port=8009 worker.tomcat2.type=ajp13 worker.tomcat2.host=10.0.0.3 worker.tomcat2.port=8009 worker.tomcat1.lbfactor=1 worker.tomcat2.lbfactor=1 worker.tomcatlb.type=lb worker.tomcatlb.balance_workers=tomcat1,tomcat2 worker.list=jkstatus worker.jkstatus.type=status
我还在Apache Tomcat的server.xml中使用了jvmRounte名称作为tomcat1和tomcat2。
我还在server.xml中添加了以下行
<Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat2"> <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="6"> <Channel className="org.apache.catalina.tribes.group.GroupChannel"> <Membership className="org.apache.catalina.tribes.membership.McastService" address="228.0.0.4" port="45564" frequency="500" dropTime="3000"/> <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter"> <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/> </Sender> <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver" address="auto" port="4001" autoBind="100" selectorTimeout="5000" maxThreads="6"/> <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/> <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interc eptor"/> <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/> </Channel>
context.xml如下所示
http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- The contents of this file will be loaded for each web application --> <Context> <!-- Default set of monitored resources. If one of these changes, the --> <!-- web application will be reloaded. --> <WatchedResource>WEB-INF/web.xml</WatchedResource> <WatchedResource>${catalina.base}/conf/web.xml</WatchedResource> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> <!-- Uncomment this to enable Comet connection tacking (provides events on session expiration as well as webapp lifecycle) --> <!-- <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" /> --> <Manager className="org.apache.catalina.ha.session.DeltaManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true"/> <Manager className="org.apache.catalina.ha.session.BackupManager" /> </Context>
apache配置有以下行
RewriteEngine on RewriteRule ^/$ /test [PT,L] JkMount /* tomcatlb
apache通过mod_jk将请求重定向到Tomcat并且工作正常但是当一个tomcat发生故障时,它应该将请求重定向到另一个tomcat,而不是我必须重新定位,因为它不会复制会话。
答案 0 :(得分:1)
我看到你失踪了 stickysession = JSESSIONID | jsessionid lbmethod = byrequests nofailover =关闭connectiontimeout = 5 timeout = 30
答案 1 :(得分:0)
只是为了确定:这些实际上是单独的行:
worker.tomcat1.type=ajp13 worker.tomcat1.host=10.0.0.2
答案 2 :(得分:0)
此外:是否故意,您的工作人员属性中缺少10.0.0.1?