您的位置:首页 > 运维架构 > Apache

apache mod_proxy 负载均衡

2017-05-06 15:54 176 查看
 

 

http://koda.iteye.com/blog/465061

 

http://www.cnblogs.com/xing901022/archive/2013/04/09/3248870.html

 

http://blog.csdn.net/oleichang/article/details/46930855

 

http://blog.sina.com.cn/s/blog_4550f3ca0101ruhq.html

 

http://blog.sina.com.cn/s/blog_4550f3ca0101ruhq.html

 

http://www.jb51.net/article/58988.htm

 

https://wenku.baidu.com/view/7d6c6b5e804d2b160b4ec043.html  
与下面同时好的文章
http://shiningray.cn/proxypass-directive-in-apache.html
http://www.th7.cn/system/lin/201406/59989.shtml
http://www.cnblogs.com/zhaozhan/archive/2007/08/10/849629.html

http://jingyan.baidu.com/article/1876c8529047e6890b1376e3.html
http://jingyan.baidu.com/article/1876c8529047e6890b1376e3.html

http://meiling.blog.51cto.com/6220221/1559416  好的  现在看的
http://www.cnblogs.com/luxh/archive/2012/11/25/2786475.html   
积极计好的

 成功啦:httpd-2.2.22-win32-x86-openssl-0.9.8t.msi
http://meiling.blog.51cto.com/6220221/1559416
http://www.jb51.net/article/45548.htm          
https://yq.aliyun.com/articles/38759      
http://blog.csdn.net/wangjunjun2008/article/details/38268483
 

http://blog.itpub.net/29254281/viewspace-1070221/                  
http://www.jb51.net/article/33583.htm           
http://blog.csdn.net/li5311263/article/details/52992968
 

http://blog.csdn.net/haolyj98/article/details/45823639          
http://www.cnblogs.com/gsls200808/p/4506301.html        
http://www.cnblogs.com/shark-smart/p/6510071.html

 

http://blog.csdn.net/microsoft_love/article/details/52098213

 

 
http://archive.apache.org/dist/httpd/binaries/win32/   apache 下载网址 

 

 http://blog.csdn.net/chunlongyu/article/details/52431200  分布式系统学习框架  

 

https://item.jd.com/12124492.html  分布式书籍  很好的

 

 

 

 

 

----------------------------------------------------

我的负载成功实验 1:

httpd.conf

 

Listen 80

LoadModule negotiation_module modules/mod_negotiation.so

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.so

#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so

 

ServerName localhost:80

 

 

#DocumentRoot "E:/Apache2.2/htdocs"

DocumentRoot "E:/apache-tomcat-7.0.72-2/webapps/AppServlet"

 

# Virtual hosts

Include conf/extra/httpd-vhosts.conf

 

 

#ajp

ProxyRequests Off 

<proxy balancer://cluster> 

    BalancerMember ajp://localhost:8009 loadfactor=1 route=jvm1 

    BalancerMember ajp://localhost:9009 loadfactor=1 route=jvm2 

</proxy>

 

 

----------------------------

 

 

vhost.conf

 

NameVirtualHost *:80

 

#<VirtualHost *:80>

#    ServerAdmin webmaster@dummy-host.localhost
#    DocumentRoot "E:/Apache2.2/docs/dummy-host.localhost"

#    ServerName dummy-host.localhost

#    ServerAlias www.dummy-host.localhost
#    ErrorLog "logs/dummy-host.localhost-error.log"

#    CustomLog "logs/dummy-host.localhost-access.log" common

#</VirtualHost>

#<VirtualHost *:80>

#    ServerAdmin webmaster@dummy-host2.localhost
#    DocumentRoot "E:/Apache2.2/docs/dummy-host2.localhost"

#    ServerName dummy-host2.localhost

#    ErrorLog "logs/dummy-host2.localhost-error.log"

#    CustomLog "logs/dummy-host2.localhost-access.log" common

#</VirtualHost>

 

 

#DocumentRoot "E:/apache-tomcat-7.0.72-2/webapps/AppServlet"

<VirtualHost *:80>

    ServerName localhost

    ProxyPass / balancer://cluster/ stickysession=jsessionid nofailover=On

    ProxyPassReverse / balancer://cluster/ 

</VirtualHost>

 

-----------------------------------------------------------------

tomcat servlet.xml

 

<?xml version='1.0' encoding='utf-8'?>

<!--

  Licensed to the Apache Software Foundation (ASF) under one or more

  contributor license agreements.  See the NOTICE file distributed with

  this work for additional information regarding copyright ownership.

  The ASF licenses this file to You under the Apache License, Version 2.0

  (the "License"); you may not use this file except in compliance with

  the License.  You may obtain a copy of the License at

      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.

-->

<!-- Note:  A "Server" is not itself a "Container", so you may not

     define subcomponents such as "Valves" at this level.

     Documentation at /docs/config/server.html

 -->

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

  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />

  <!-- Security listener. Documentation at /docs/config/listeners.html

  <Listener className="org.apache.catalina.security.SecurityListener" />

  -->

  <!--APR library loader. Documentation at /docs/apr.html -->

  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />

  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->

  <Listener className="org.apache.catalina.core.JasperListener" />

  <!-- Prevent memory leaks due to use of particular java/javax APIs-->

  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />

  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />

  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <!-- Global JNDI resources

       Documentation at /docs/jndi-resources-howto.html

  -->

  <GlobalNamingResources>

    <!-- Editable user database that can also be used by

         UserDatabaseRealm to authenticate users

    -->

    <Resource name="UserDatabase" auth="Container"

              type="org.apache.catalina.UserDatabase"

              description="User database that can be updated and saved"

              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"

              pathname="conf/tomcat-users.xml" />

  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share

       a single "Container" Note:  A "Service" is not itself a "Container",

       so you may not define subcomponents such as "Valves" at this level.

       Documentation at /docs/config/service.html

   -->

  <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->

    <!--

    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"

        maxThreads="150" minSpareThreads="4"/>

    -->

    <!-- A "Connector" represents an endpoint by which requests are received

         and responses are returned. Documentation at :

         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)

         Java AJP  Connector: /docs/config/ajp.html

         APR (HTTP/AJP) Connector: /docs/apr.html

         Define a non-SSL HTTP/1.1 Connector on port 8080

    -->

    <Connector port="8080" protocol="HTTP/1.1"

               connectionTimeout="20000"

               redirectPort="8443" />

    <!-- A "Connector" using the shared thread pool-->

    <!--

    <Connector executor="tomcatThreadPool"

               port="8080" protocol="HTTP/1.1"

               connectionTimeout="20000"

               redirectPort="8443" />

    -->

    <!-- Define a SSL HTTP/1.1 Connector on port 8443

         This connector uses the BIO implementation that requires the JSSE

         style configuration. When using the APR/native implementation, the

         OpenSSL style configuration is required as described in the APR/native

         documentation -->

    <!--

    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"

               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"

               clientAuth="false" sslProtocol="TLS" />

    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->

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

    <!-- An Engine represents the entry point (within Catalina) that processes

         every request.  The Engine implementation for Tomcat stand alone

         analyzes the HTTP headers included with the request, and passes them

         on to the appropriate Host (virtual host).

         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :

    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">

    -->

    <Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">

      <!--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" channelSendOptions="6">

     

        <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="5001"

                      selectorTimeout="100"

                      maxThreads="6"/>

                      <!--all seted in 5001-->

                     

            <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"/>

        </Channel>

        <Valve className="org.apache.catalina.ha.tcp.ReplicationValve"

               filter=".*/.gif;.*/.js;.*/.jpg;.*/.png;.*/.htm;.*/.html;.*/.css;.*/.txt;"/>

       

        <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.ClusterSessionListener"/>

 

</Cluster>

 

 

      <!-- Use the LockOutRealm to prevent attempts to guess user passwords

           via a brute-force attack -->

      <Realm className="org.apache.catalina.realm.LockOutRealm">

        <!-- This Realm uses the UserDatabase configured in the global JNDI

             resources under the key "UserDatabase".  Any edits

             that are performed against this UserDatabase are immediately

             available for use by the Realm.  -->

        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"

               resourceName="UserDatabase"/>

      </Realm>

      <Host name="localhost"  appBase="webapps"

            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications

             Documentation at: /docs/config/valve.html -->

        <!--

        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />

        -->

        <!-- Access log processes all example.

             Documentation at: /docs/config/valve.html

             Note: The pattern used is equivalent to using pattern="common" -->

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"

               prefix="localhost_access_log." suffix=".txt"

               pattern="%h %l %u %t "%r" %s %b" />

      </Host>

    </Engine>

  </Service>

</Server>

=============================================================

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: