Load balancing with Tomcat combined with Apache2 in SOLARIS10

Source: Internet
Author: User
Tags mkdir relative java web tomcat
Load balancing with Apache2 in Solaris10 and Tomcat first,        said that some ISVs were found in the SOLARIS10 porting process for ISVs The app is a Java web app that uses Apache and TOMCAT in conjunction to achieve load balancing. So how does this load-balancing method be implemented in SOLARIS10? This article will give a reference implementation. Most of the operations in this article are performed under the Solaris10 B Shell. B.        topology diagram for load balancing in this article        this topology diagram is just the implementation in this article, These can also be simplified without such a condition. Install Apache and two Tomcat on a single host. You can also use a host to divide multiple zones to simulate multiple hosts using the Zone function provided by SOLARIS10. Iii.        steps to implement the load 1.      Verify that the Apache2 is working properly. 1.1 Generating the initial configuration file httpd.conf             #cp/etc/apache2/ HTTPD.CONF-EXAMPLE/ETC/APACHE2/HTTPD.CONF 1.2 First launch Apache              #/usr/apache2/bin/apachectl start 1.3 to see if the Apache process has started              #ps –ef|grep httpd    If the following occurs, Apache does not start successfully.    1.4 View reasons for not starting successfully               #more/var/apache2/logs/error_log   found below    As can be seen because Apache at the start of the time to write the PID information to a file httpd.pid when the problem occurs, because/var/run/apache2 this directory does not exist. Now use the following command to set up this directory.    #mkdir –p/var/run/apache2 1.5 second launch of Apache    in order to see the error generated in this startup, first delete the original error _ Log file    # Rm/var/apache2/logs/error_log    then start Apache    #/usr/apache2/bin/apachectl start    1.6 The second time to view the Apache boot situation #ps –ef|grep httpd If the following conditions occur, the boot succeeds. The browser can also be used to verify whether Apache is successful, and if the browser appears with the following information, it has started successfully.               Otherwise no Apache did not start successfully, Repeat 1.4-1.6 until successful. Go to Error_log to see what the message is.               #more/var/apache2/logs/error_log         can see that there has been no error generated. 2.      installation MOD_JK MOD_JK is the interface that connects Apache to Tomcat. It works as follows:        apache in receiving the user request JSP and servlet will transfer them to Tomcat via MOD_JK, and after the Tomcat processing is completed, the results are returned to Apache via MOD_JK. Apache then renders the results to the user.    2.1 Get MOD_JK       There are two types of downloads available on the Tomcat official website, a compiled binary ". dll" or ". So". The other is the source code download, need to compile locally. Because you do not see a SOLARIS10 version of the ". So" file, use its source code here to compile.       Source code Download address: http://www.apache.org/dist/tomcat/tomcat-connectors/jk/source/jk-1.2.15/ jakarta-tomcat-connectors-1.2.15-src.tar.gz        binary Download Address: http://www.apache.org/ dist/tomcat/tomcat-connectors/jk/binaries/   2.2 Compiling mod_jk       because the Solaris is being used Compiler tool, so install Sun Studio11 first. Sun Studio 11 Setup and installation manuals are available for free download on Sun's website and are installed in the "next" type, which is not much to say. Next, unzip the downloaded file:                    #gunzip jakarta-tomcat-connectors-1.2.15-src.tar.gz              #tar XVF Jakarta-tomcat-connectors-1.2.15-src.tar             #cd jakarta-tomcat-connectors-1.2.15-src        Set Environment variables: Path,ld_library_path              # Export path= $PATH:/usr/ucb:/usr/ccs/bin        (contains compilation tools and make)             #export ld_library_path= $LD _library_path:/usr/lib:/etc/lib (contains libraries that may be used)          Start compiling mod_jk             #cd jk/native      relative to Jakarta-tomcat-connectors-1.2.15-src             #./configure–with-apxs=/usr/apache2/bin/apxs             #make       generated the following error message during make, due to the mod_jk.so An error occurred while the file was being copied to a specific path to Apache. No matter, the most useful mod_jk.so have been generated. stored in the Jk/nativ relative to the JAKARTA-TOMCAT-CONNECTORS-1.2.15-SRC directoryThe E/apache-2.0/.libs directory.        compiling mod_jk is cumbersome and prone to problems, now put the compiled files online. Friends who need it can be downloaded directly (but not guaranteed to be used by any machine). For Solaris10 sparc:http://www.cublog.cn/u/15296/upfile/060316125507.gz for Solaris10 x86:http://www.cublog.cn/u/ 15296/upfile/060316121254.gz 3.      configuration mod_jk to Apache 3.1 first mod_jk.so (in Jk/native/apache-2. 0/.libs directory) files are copied to the Apache libexec directory. #cp mod_jk.so/usr/apache2/libexec/. 3.2 Then modify the Apache configuration file to enable Apache to forward files that require Tomcat processing through MOD_JK. There are three needs to be modified, see figure.     #vi/etc/apache2/httpd.conf and add a line at the end of the LoadModule module LoadModule jk_module libexec/mod_jk.so   & nbsp;    Find a suitable location (anywhere), add the following information        also configure the file types and paths that need to be forwarded. The specific location is under the documentroot indicator. The two lines that begin with Jkmount are shown below.        3.3 Writing workers.properties file        This file is defined forcefully with Apache interacts with the configuration information of Tomcat. As follows:        can see Worker1 and worker2 used to configure Tomcat Information, Loaderbalancer is used to configure load balancing information. The following table describes the properties that are involved. More property descriptions can be found in the worker file's documentation.
Properties description
W Orker.list define worker list
worker.<workername>.type define Wo Type of Rker, Ajp13,ajp14,jni,lb,status, etc.
worker.<workername>.host define Wo Rker host IP
worker.<workername>.port define worker Service listener Port
Worker.<workername>.lbfactor defines the load share required for each worker who completes load balancing
worker.<workername>.balanced_workers specify a worker to join the load Balancer
       3.4 Verify that Apache is still available after installing MOD_JK.        follow the 1.5,1.6 method to verify. 4.      Configure TOMCAT to achieve load balancing 4. 1Tomcat Acquisition and installation               This document was used from Tomcat The binary files provided on the official website are packaged http://apache.roweboat.net/tomcat/tomcat-5/v5.5.16/bin/apache-tomcat-5.5.16.tar.gz. Copy the installation directory of each worker host and do the following, even if the installation is complete.                         #gunzip apache-tomcat-5.5.16.tar.gz              #tar xvf Apache-tomcat-5.5.16.tar             # MV apache-tomcat-5.5.16 tomcat551        4.2 Create an empty test Web app and create a file test JSP page under it:  & nbsp;           #mkdir –p $TOMCAT _home/webapps/testload  of which $ Tomcat_hoME is the installation directory for Tomcat.  &n

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.