TOMCAT6 cluster + SEESION Replication

Source: Internet
Author: User

In the project in charge of the TOMCAT cluster application, close up this instance.
I. System Environment 1. Use APACHE + TOMCAT to implement cluster 2. Use Centos5.6 as the Clustery host and Centos as the tomcat host), Asianux, and WIN, check the APACHE version and JDK version:

[Root @ localhost ~] # Httpd-versionServer version: Apache/2.2.3 [root @ localhost ~] # Java-versionjava version "1.6.0 _ 17" OpenJDK Runtime Environment (IcedTea6 1.7.5) (rhel-1.16.b17.el5-i386) OpenJDK Server VM (build 14.0-f8, mixed mode) # TOMCAT host JDK versions should be consistent as possible
2. The operating system time of all nodes must be consistent! Otherwise, Session synchronization between nodes will be difficult, and the website will be slow. Obtaining time from the same NTP is a good idea.
II. Specific configuration 1. APACHE configuration
[Root @ localhost ~] # Vi/etc/httpd/conf. d/mod_jk.conf <ifmodule! Jk_module> LoadModule jk_module modules/mod_jk-1.2.23-apache-2.2.x-linux-i686.so # download mod_jk put in/etc/httpd/modules, pay attention to the version, TOMCAT official website has download </ifmodule> <ifmodule jk_module> JkWorkersFile conf/workers. propertiesJkMount/* controller </ifmodule>
Create conf/workers. properties
[Root @ localhost ~] # Vi workers. propertiesworker. list = controller, tomcat01, tomcat02, tomcat03worker. tomcat01.port = 8009worker. tomcat01.host = localhostworker. tomcat01.type = ajp13worker. tomcat01.lbfactor = 1 # weight. The larger the value, the more worker the requests are sent. tomcat02.port = 8019worker. tomcat02.host = 192.168.1.20.worker.tomcat02.type = ajp13worker. tomcat02.lbfactor = 1worker. tomcat03.port = 8029worker. tomcat03.host = 192.168.1.188worker.tomcat03.type = ajp13worker. tomcat03.lbfactor = 1worker. controller. type = lbworker. controller. balanced_workers = tomcat01, tomcat02, tomcat03 # worker. controller. sticky_session = 1 # sticky_session. In this example, copy the session;
2. TOMCAT configuration 2. 1. The three tomcat AJP ports must be consistent with those in workers. properties.
<Connector port="8019" protocol="AJP/1.3" redirectPort="8443" />
2.2.Engine Configuration
[Root @ localhost ~] # Vi tomcat/conf/server. xml <Engine name = "Catalina" defaultHost = "localhost" jvmRoute = "tomcat01" >## jvmRoute is the name of tomcat in workers. properties.
2.3.configure sessions in cluster)
[Root @ localhost ~] # Vi tomcat/conf/server. xml <cluster className = "org. apache. catalina. ha. tcp. simpleTcpCluster "channelSendOptions =" 10 ">## copy and verify the Session in asynchronous mode <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. membe Rship. mcastService "address =" 228.0.0.4 "# multicast address port =" 45564 "frequency =" 500 "dropTime =" 3000 "/> <er className =" org. apache. catalina. tribes. transport. nio. nioReceiver "address =" auto "port =" 4031 "autoBind =" 100 "selectorTimeout =" 1000 "maxThreads =" 6 "/> <! -- Timeout = "60000" --> <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; "/> # filter files that do not need to be synchronized to the session to improve the response speed. <valve className =" org. apache. catalina. ha. session. jvmRouteBinderValve "/> <clusterlistener className =" org. apache. catalina. ha. session. jvmRouteSessionIDBinderListener "/> <clusterlistener className =" org. apache. catalina. ha. session. clusterSessionListener "/> </cluster>
3. The session replication configuration in the web application is added to the web. xml file in the published web application.
<Display-name> Tomcat </display> <distributable/> # Add this sentence between the two </web-app>
 

This article is from the "kras-linux" blog, please be sure to keep this source http://klinux.blog.51cto.com/2972664/691754

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.