Apache + jetty load balancing and cluster configuration (below)

Source: Internet
Author: User

Next, the article Apache + jetty Server Load balancer and cluster configuration (on) begins to write ,(~ O ~)~ Zz

Now begin !!!

Access http: // 192.168.55.229: 9009/fgw/index. jsp and http: // 192.168.55.231: 9009/fgw/index. jsp respectively.

 

Refresh will display a new page:

 

(6) Access http: // 192.168.50.50: 8051/fgw and the following page appears:

It indicates that Apache has directed access from Port 8051 to the jetty server. However, we cannot see which jetty server is used. The test page is added to the two jetty servers to make the effect more obvious.

Then let's add the test page to see the effect (we enter the following address in the browser: http: // 192.168.50.50: 8051/fgw/index. jsp)

 

 

 

 

Now, the result shows that our cluster has been successfully built. You can refer to my configuration for a test and wish you success ,(~ O ~)~ Zz

 

II. (2) mod_jk Server Load balancer Configuration

1. BecauseMod_jkFor third-party modules, need to download to the jetty official website, URL for http://mirror.bjtu.edu.cn/apache/tomcat/tomcat-connectors/jk/tomcat-connectors-1.2.32-src.tar.gz

2. Compile the JK module into Apache on Apache server:

# Tar xvfz tomcat-connectors-1.2.31-src.tar.gz

 

# Cd tomcat-connectors-1.2.31-src/Native/

 

./Configure -- With-apxs =/usr/local/apache2/bin/apxs -- With-Java-home =/usr/local/JDK

Make & make install

 

At this time, a mod_jk.so will appear under/usr/local/apache2/modules, and the compilation is successful.

3. Configure the Apache configuration file

1 VI/usr/local/apache2/CONF/httpd. confAdd the following content:

Loadmodule jk_module modules/mod_jk.so

 

<Ifmodule jk_module>

Jkworkersfile CONF/workers. Properties

Jklogfile logs/mod_jk.log

JkloglevelWarn

</Ifmodule>

 

Include CONF/app2.conf

2. Create and configure the app2.conf File

Listen 8052.

<Virtualhost *: 8052>

DocumentRoot "/usr/local/apache2/htdocs"

Servername localhost

Serveradmin app2.Admin@99bill.com

Errorlog "/usr/local/apache2/logs/app2 error_log"

Transferlog "/usr/local/apache2/logs/app2 access_log"

Jkmount/* jettybalancer

</Virtualhost>

3. Create and configure the workers. properties File

VI/usr/local/apache2/CONF/workers. properties, add the following content:

Worker. List =Jetty_a

Worker. jetty_a.port = 8009

Worker. jetty_a.host = 192.168.55.229

Worker. jetty_a.type =Ajp13

Worker. jetty_a.lbfactor = 2

 

Worker. List =Jetty_ B

Worker. jetty_ B .port = 8009

Worker. jetty_ B .host = 192.168.55.231

Worker. jetty_ B .type =Ajp13

Worker. jetty_ B .lbfactor = 1

 

Worker. List = jettybalancer

Worker. jettybalancer. type =LB

Worker. jettybalancer. balance_workers =Jetty_a, jetty_ B

 

 

Modify jetty's configuration file Jetty. xml

Jetty_a configuration file:

<! -- ===================================================== ================================ -->

<! -- Set up global session ID manager -->

<! -- ===================================================== ================================ -->

<Set name = "sessionidmanager">

<New class = "org. mortbay. Jetty. servlet. hashsessionidmanager">

<Set name = "workername">Jetty_a</Set>

</New>

</Set>

 

 

Jetty_ B configuration file:

 

<! -- ===================================================== ================================ -->

<! -- Set up global session ID manager -->

<! -- ===================================================== ================================ -->

<Set name = "sessionidmanager">

<New class = "org. mortbay. Jetty. servlet. hashsessionidmanager">

<Set name = "workername">Jetty_ B</Set>

</New>

</Set>

 

Access http: // 192.168.50.50: 8052/fgw/index. jsp. The following page appears:

 

 

 

 

Refresh but will not change, unless you re-open a new page

 

 

The probability of jetta_a appearing is twice that of jetty_ B.

 

Hi, my fellow! So far, jetty's experiment has ended. You can refer to my blog and do the experiment yourself (* ^__ ^ ...... Good luck with you!

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.