简体   繁体   中英

Howto setup Apache Web Server for clustering a Web Service on two Tomcats

I'm trying to setup an Apache Web Server, so that it balances requests of a client on two Tomcat servers. For the Web Service I uses Axis2. It is deployed on two Tomcats. When I invoke the Web Service, there is always only one Server answering, although the cluster is established. I used this tutorial, Axis2 1.6.1, Tomcat 7, Apache Web Server 2.2 and I am running it on a Windows 32 bit system. How is it possible to balance the client requests on both Tomcats? It might have something to do with the proxy configuration of the Web Server, but its just a thought. If you need screenshots or else, please let me know. And sorry for my german accent :)

Usually with load-balancing (clustering) one server will be answering first - which one will be decided by load-balancer (proxy) in it's configuration. Load-balancer (proxy) usually queries all clustered servers until it finds one that is less busy. In order to tests clustered environment you have to simulate (or create) high load or you can "slow down" (or stop completely) one of the servers.

Ok it works now. It was a configuration problem in the axis2.xml file, where I had the wrong IP. now I have the following configuration on every instance:

    <!-- The host name or IP address of this member -->
    <parameter name="localMemberHost">127.0.0.1</parameter>

Also important is the server.xml file of the Tomcat instances. Here the Shutdown port must be different for each instance:

Instance 1:

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

Instance 2:

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

The connector port must be different, too:

Instance 1:

        <!-- Define an AJP 1.3 Connector on port 8009 -->
        <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Instance 2:

        <!-- Define an AJP 1.3 Connector on port 8009 -->
        <Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />

Then I just set these adjustments in the httpd.conf file of the Apache Webserver like this:

        BalancerMember ajp://127.0.0.1:8009 min=1 max=1 route=node1 loadfactor=1
        BalancerMember ajp://127.0.0.1:8010 min=1 max=1 route=node2 loadfactor=1

and now my cluster works fine. Sometimes you have to go back some steps to understand whats wrong.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM