日期:2014-05-17  浏览次数:21099 次

配置Apache+Tomcat集群

操作系统:Debian6.0 (192.168.225.129 虚拟机1台)

软件版本:Apache-2.2.16, Tomcat-6.0.35

1.安装软件

    >apt-get install update

    *安装Apache

    >apt-get install apache2

    *安装Tomcat

    >wget http://apache.etoak.com/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz

    >tar zxvf apache-tomcat-6.0.35.tar.gz

    >mv apache-tomcat-6.0.35 /user/local/tomcat

    >cp /usr/local/tomcat  /usr/local/tomcat2

    *安装mod_jk

    >apt-get install libapache2-mod-jk

2.配置2个Tomcat

    现在/usr/local目录中已经有2个tomcat目录了,需要更改tomcat2的端口,防止端口冲突。

    >nano /usr/local/tomcat/conf/server.xml

    有3处的默认端口需要更改:

    1.<Server port="8004" shutdown="SHUTDOWN"> 我更改为8003

    2.<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

        更改为7080

    3.<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

        更改为7009,其中redirectPort 8443不需要更改

    o.另外还需要在<Engine>配置中加入<Cluster>配置

<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="auto" 
			port="4001" 
			selectorTimeout="5000" 
			maxThreads="6"/>  
        <!-- timeout="60000"-->  
        <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"/>  
        <Interceptor className="org.apache.catalina.tribes.group.interceptors.ThroughputInterceptor"/>  
  &nbs