企业Web高可用集群实战之Nginx+nginx(3)

修改server.xml配置文件:

192.168.8.11服务器: 1.在/usr/local/tomcat/conf/server.xml 中修改Enginx节点信息,大概在103行: 把<Engine name="Catalina" defaultHost="localhost"修改成: <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1" 2.加入Cluster节点信息,大概在110行左右处加入如下内容:  <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8"<Manager className="org.apache.catalina.ha.session.DeltaManager"              expireSessionsOnShutdown="false"              notifyListenersOnReplication="true"/>        <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"/>       <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"                 address="192.168.8.11"                 port="4000"                 autoBind="100"                 selectorTimeout="5000"                 maxThreads="6"/>          <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">         <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>       </Sender>       <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>       <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>     </Channel>        <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"            filter=""/>     <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>        <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"               tempDir="/tmp/war-temp/"             deployDir="/tmp/war-deploy/"             watchDir="/tmp/war-listen/"             watchEnabled="false"/>      <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>     <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>   </Cluster>  192.168.8.12服务器:  1.在/usr/local/tomcat/conf/server.xml 中修改Enginx节点信息,大概在103行: 把<Engine name="Catalina" defaultHost="localhost"修改成: <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm2" 2.加入Cluster节点信息,大概在110行左右处加入如下内容:  <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8"<Manager className="org.apache.catalina.ha.session.DeltaManager"              expireSessionsOnShutdown="false"              notifyListenersOnReplication="true"/>        <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"/>       <Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"                 address="192.168.8.12"                 port="4000"                 autoBind="100"                 selectorTimeout="5000"                 maxThreads="6"/>          <Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">         <Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>       </Sender>       <Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>       <Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor"/>     </Channel>        <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"            filter=""/>     <Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>        <Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"               tempDir="/tmp/war-temp/"               deployDir="/tmp/war-deploy/"               watchDir="/tmp/war-listen/"               watchEnabled="false"/>        <ClusterListener className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener"/>     <ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>   </Cluster>   3.测试目录负载均衡在11、12服务器上建立测试目录,观察负载均衡情况。 mkdir -p /data/www/ cat /data/www/test.jsp <%  System.out.println("Welcome tomcat_cluster session repication"); %> 4.启动各服务器服务 10服务器: /usr/local/nginx/sbin/nginx 11、12服务器 startup.sh 在浏览器上输入:192.168.8.10/test.jsp,然后分别在11、12服务器查看输出日志:11服务器:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3bad889e1bc31b43a50302fe72fa2d46.html