本人想配置虚拟主机,可是弄了好久都没弄清楚是怎么弄的
1.apache2.2  + tomcat 和当中的 mod_proxy_ajp模块
2.只有一个IP
3.怎么实现那种虚拟主机的效果,比如说客户上传到tomcat/webapp下的东西要重启才可以正确访问,但是怎么来控制tomcat呢,如果重启tomcat其他的客户的不是都停了吗?怎么实现的停止自己注册的那个tomcat呢,还是每注册一个用户给他分配一个tomcat?
4.要动态的,也就是说添加虚拟主机的话不用apache重启,要是重启的话又影响其他客户了这些问题搞了好久了,谁来帮帮我啊 ?

解决方案 »

  1.   

    1 如果你用一个tomcat服务多个应用,那么重启肯定要影响别的用户,这是你自己的选择
    2 你可以每个用户单独启动一个tomcat,服务于不同的端口,比如 8009,8019,8029.
    总之不同就可以,在apache里面配置虚拟主机,然后用分别映射过去就行了。
      

  2.   

    关注,老紫ZHU给我解决方案出来吧
      

  3.   

    直接设定多个主机就可以了
    <Proxy balancer://MyWebApp>
      BalancerMember ajp://server:8009/MyWebApp
    </Proxy>
    <Proxy balancer://MyWebApp>
      BalancerMember ajp://server:8019/MyWebApp
    </Proxy>
      

  4.   

    刚搞完 就说说吧~http://topic.csdn.net/u/20090123/16/a0cccb97-2365-4522-bdf2-7bc77d8f0f17.html1,APACHE代理配置。conf/httpd.conf
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
    LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
    LoadModule proxy_connect_module modules/mod_proxy_connect.so
    LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
    LoadModule proxy_http_module modules/mod_proxy_http.soProxyRequests Off 
    #
    ProxyPass / balancer://tomcatcluster/ lbmethod=byrequests stickysession=JSESSIONID nofailover=Off timeout=3 maxattempts=3  ################################################################################
    #
    # IBmethod:
    # Balancer load-balance method. Select the load-balancing scheduler method to use. Either #byrequests, to perform weighted request counting or bytraffic, to # perform weighted traffic byte #count balancing. Default is byrequests. 
    #
    # stickysession:
    # Balancer sticky session name. The value is usually set to something like JSESSIONID or #PHPSESSIONID, and it depends on the backend application server that # support sessions.
    #
    # nofailover:
    # If set to On the session will break if the worker is in error state or disabled. Set this value #to On if backend servers do not support session # replication.  
    #
    # timeout:
    # Balancer timeout in seconds. If set this will be the maximum time to wait for a free worker. #Default is not to wait. 
    #
    # maxattempts:
    # Maximum number of failover attempts before giving up. 
    #
    ###################################################################################ProxyPassReverse / balancer://tomcatcluster/   
      
    <Proxy balancer://tomcatcluster>  
    BalancerMember ajp://localhost:8109 smax=10 route=jvm2
    BalancerMember ajp://localhost:8209 smax=10 route=jvm3
    BalancerMember ajp://localhost:8309 smax=10 route=jvm4
    BalancerMember ajp://localhost:8409 smax=10 route=jvm5
    BalancerMember ajp://localhost:8509 smax=10 route=jvm1
    </Proxy> 
    # smax:
    # Upto the Soft Maximum number of connections will be created on demand. Any connections above smax are subject to a time to live or ttl. 
    # route:
    # Route of the worker when used inside load balancer. The route is a value appended to seesion id. 我是在本地弄了5个TOMCAT,如果是其他服务器 相应改掉上面的localhost就好了 2,TOMCAT设置
        conf/Server.xml文件  1,注意所有的端口不要重复
      2,设置<Engine>标签
      3,设置session同步:          <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
                     channelSendOptions="4">          <Manager className="org.apache.catalina.ha.session.DeltaManager"
                       expireSessionsOnShutdown="false"
                       notifyListenersOnReplication="true"/>      <!--For clustering, please take a look at documentation at:
              /docs/cluster-howto.html  (simple how to)
              /docs/config/cluster.html (reference documentation) -->
          <!--
          <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
          -->                  <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"
                          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>   
    上面的红4代表 SESSION的同步传输 红4001是TCP recieve 端口号,注意保持一致。
    3,项目设置
        Make sure your web.xml has the <distributable/> element or set at your <Context distributable="true" /> 要注意的问题:
       1,TOMCAT用ZIP版本,不要用安装版本,并设置好每个TOMCAT的JDK等环境变量。
       2,注意好端口的唯一性。

       3,如下:
    All your session attributes must implement java.io.Serializable 
    Uncomment the Cluster element in server.xml 
    If you have defined custom cluster valves, make sure you have the ReplicationValve defined as well under the Cluster element in server.xml 
    If your Tomcat instances are running on the same machine, make sure the tcpListenPort attribute is unique for each instance, in most cases Tomcat is smart enough to resolve this on it's own by autodetecting available ports in the range 4000-4100 
    Make sure your web.xml has the <distributable/> element or set at your <Context distributable="true" /> 
    If you are using mod_jk, make sure that jvmRoute attribute is set at your Engine <Engine name="Catalina" jvmRoute="node01" > and that the jvmRoute attribute value matches your worker name in workers.properties 
    Make sure that all nodes have the same time and sync with NTP service! 
    Make sure that your loadbalancer is configured for sticky session mode. 
      

  5.   

    上传到tomcat/webapp下的东西
    估计得做共享文件服务器我所了解的CLUSTER只保持了SESSION同步~