Detailed configuration of Apache + Tomcat clusters in Linux

Source: Internet
Author: User
Environment: the operating system is centos 5.1 apache2.x server: IP address 192.168.232.4; installation path:/usr/local/Apache; tomcat6 server: IP address 192.168.232.5; installation path:/usr/local/tomcat; tomcat6 server: IP address 192.168.232.6; installation path:/usr/local/tomcat; configuration: Apache installation :#. /configure -- prefix =/usr/local/Apache -- enable-modules = so -- enable-mods-shared = all -- enable-proxy-connect -- enable-proxy- FTP -- enable-proxy-HTTP -- enable-proxy-AJP -- enable-proxy-balancer -- Enable-Rewrite: Enable-proxy, enable-proxy-HTTP, enable-proxy-connect, enable-proxy-AJP, and enable-proxy-balancer required to activate the Tomcat cluster, the proxy-AJP and proxy-balancer must depend on the proxy. For custom compilation, mod_status must be compiled in addition to the preceding modules. Enable-proxy-FTP can not be compiled. # Make; make install: # cp support/apachectl/etc/rc. d/init. d/httpd # vi/etc/rc. d/init. d/httpd Add the following content: (including #) # STARTUP script for the Apache Web Server # chkconfig: 2345 85 15 # Description: Apache is a World Wide Web server. it is used to server # HTML files and CGI. # processname: httpd # pidfile:/usr/local/Apache/log/httpd. pid # config:/usr/local/Apache/CONF/httpd. add a service item in conf # chkconfig -- add HTTP D # chmod 755/etc/rc. d/init. d/httpd # chkconfig -- level 345 httpd on JDK installation: # chmod A + x jdk-6u4-linux-i586-rpm.bin #. /jdk-6u4-linux-i586-rpm.bin Java environment variable settings: # vi/etc/profile Add the following content at the end of the file: java_home =/usr/Java/jdk1.6.0 _ 04 classpath =.: $ java_home/lib/tools. jar: $ java_home/lib/DT. jarpath = $ java_home/bin: $ pathcatalina_home =/usr/local/tomcatexport java_home classpath path catalina_home execute the following command to make the environment variable take effect: Source/etc/profi Le test configuration successful: Java-version tomcat installation: # wget [url] unzip zxvf apache-tomcat-6.0.16.tar.gz # mv APACHE-Tomcat-6.0.16/usr/local/tomcat Tomcat random start: # vi/etc/rc. add the following content to local:/usr/local/tomcat/bin/startup. sh tomcat6 configuration file server. XML: Set <! -- You shoshould set jvmroute to support load-balancing via AJP ie: <engine name = "standalone" defaulthost = "localhost" jvmroute = "jvm1"> --> <engine name = "Catalina" defaulthost = "localhost"> changed to <! -- You shoshould set jvmroute to support load-balancing via AJP ie: --> <engine name = "standalone" defaulthost = "localhost" jvmroute = "tomcatx"> <! -- <Engine name = "Catalina" defaulthost = "localhost"> --> description: for the first Tomcat server, set jvmroute = "tomcat1" and for the second Tomcat server, set jvmroute = "tomcat2" <! -- <Cluster classname = "org. apache. catalina. ha. TCP. simpletcpcluster "/> --> remove the comment and change it to <cluster classname =" org. apache. catalina. ha. TCP. simpletcpcluster "/> *** detailed cluster configuration *** <cluster classname =" org. apache. catalina. ha. TCP. simpletcpcluster "channelsendoptions =" 8 "> <manager classname =" org. apache. catalina. ha. session. deltamanager "expiresessionsonshutdown =" false "yylistenersonreplication =" 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 "/> <Cycler classname =" org. apache. catalina. tribes. transport. NIO. nioreceiver "address =" Auto "Port =" 4000 "autobind =" 100 "selectortimeout =" 5000 "maxthreads =" 6 "/> <sender classname =" org. apache. catalina. tribes. transport. replicationt Ransmitter "> <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> Configure the web. XML: In each webapps, modify the Web configuration file. add an element to the XML file <distributable/> on the web. add the following content to the <web-app> element of the XML file: <! -- This application will copy the session with the cluster server --> <distributable/> the specific modification is as follows: before modification: <? XML version = "1.0" encoding = "ISO-8859-1"?> <Web-app xmlns = "[url] http://java.sun.com/xml/ns/javaee#/url]" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation = "http://java.sun.com/xml/ns/javaee [url] http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd#/url]" version = "2.5"> </Web-app> after modification: <? XML version = "1.0" encoding = "ISO-8859-1"?> <Web-app xmlns = "[url] http://java.sun.com/xml/ns/javaee#/url]" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation = "http://java.sun.com/xml/ns/javaee [url] Author" version = "2.5"> <! -- This application copies the session with the cluster server --> <distributable/> </Web-app> to configure Apache's AJP load balancing function: ensure that the following module annotations are removed from loadmodule proxy_module modules/mod_proxy.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 modules/mod_pr Oxygen _balancer.so loadmodule status_module modules/mod_status.so Add the following content: # proxypass configinclude CONF/extra/httpd-modproxy.conf Build File httpd-modproxy.conf inputs: <location/Server-status> sethandler server-status order deny, allow deny from all allow from all </location> <location/balancer-Manager> sethandler balancer-manager order deny, allow deny from all allow from all </location> proxyrequests off proxy Pass/balancer: // tomcatcluster stickysession = JSESSIONID nofailover = on <proxy balancer: // tomcatcluster> balancermember [url] http: // 192.168.232.5: 8080 [/url] loadfactor = 1 balancermember [url] http: // 192.168.232.6: 8080 [/url] loadfactor = 2 </Proxy> Note: proxyrequests off indicates that reverse proxy is enabled, must be enabled. proxypass is the proxy forwarding URL, which forwards all access/requests to the cluster balancer: // tomcatcluster. Here,/forwards all access/requests to the cluster balancer: // The/test directory of tomcatcluster; balancerme The mber is a member of the cluster, that is, the Cluster Server 1 or 2. The Server Load balancer server forwards requests to the balancermember according to the balancing rules. debug the Server Load balancer Cluster System: access the Web Service of the Apache server: [url] http: // 192.168.232.4/balancer-manager [/url] If the Server Load balancer information is displayed, the operation is successful. Then, you can access [url] HTTP: // 192.168.232.4/[/url] indicates that the Tomcat application is accessed. *** you must start the Tomcat service and then start the apache service! * ** Reference: [url] http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html#/url] [url] #[ url] #[ url] #[ url] #

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.