During the last day of the holiday, configure the Apache cluster in the Linux environment and consolidate the cluster. If you do not need to use the cluster in the future, you will not be able to use the cluster. After the environment is completed, go to the blog, for later use.
Reference Source: http://www.linuxidc.com/Linux/2011-03/32859.htm
My version:
Httpd-2.2.21.tar.gz
Apache-tomcat-6.0.32.tar.gz
Jdk-6u26-linux-i586.bin
JDK, and tomcat environment configuration ignored
A. Add the apache in the/opt and copy httpd-2.2.21.tar.gz to the Change directory.
CD/OPT
Mkdir Apache
Tar zxf httpd-2.2.21.tar.gz
CD httpd-2.2.21
Configure httped prefix
./Configure -- prefix =/opt/web/apache2 -- enable-mod-shared = most # -- the red path after the prefix can be customized according to the actual situation.
A large amount of configuration information is displayed on the screen.
Make # Start Compilation
Make install # After compilation, enter the installation phase
CD/opt/solft/apache2/bin
./Apachectl-K start # Start the apache service
If the following message is displayed
Httpd: cocould not reliably determine the server's fully qualified domain name, using 127.0.1.1 for servername
Enter http: // 127.0.0.1/in the browser to view it works! B. start installing mod_proxy.so and mod_proxy_ajp.so, mod_proxy_balancer.so module CD/opt/Apache/httpd-2.2.21/modules/Proxy/opt/web/apache2/bin/apxs-I-a-c mod_proxy.c proxy_util.c/opt/web/apache2/bin/ apxs-I-a-c mod_proxy_ajp.c AJP *. c/opt/web/apache2/bin/apxs-I-a-c mod_proxy_balancer.cc. configure httpd. confvim/opt/web/apache2/CONF/httpd. confproxypass/images! Proxypass/CSS! Proxypass/JS!
Proxyrequests off
Proxypass/examples balancer: // mycluster/stickysession = JSESSIONID
Proxypassreverse/examples balancer: // mycluster/stickysession = JSESSIONID
<Proxy balancer: // mycluster>
Balancermember AJP: // 192.168.1.102: 8009/examples/route = worker1 loadfactor = 1
Balancermember AJP: // 192.168.1.102: 8909/examples/route = worker2 loadfactor = 1
</Proxy>
Sethandler balancer-Manager
# The red part of the IP port above is consistent with the port in the apache-tomcat-x.x.x/config/server. xml <connector Port = "8009" protocol = "AJP/1.3" redirectport = "8443"/>
D. Edit tomcat1/Apache-Tomcat-6.0.32/config/server. xml.
Server. xml file. If Tomcat is on different machines, you do not need to modify it. My environment is tested on the local machine. Therefore, one of the Tomcat ports must be modified.
Location to be modified (red part)
<Connector Port = "8080" protocol = "HTTP/1.1"
Connectiontimeout = "20000"
Redirectport = "8443" type = "regxph" text = "yourobjectname"/>
<Server port = "8005" shutdown = "shutdown">
<Connector Port = "8009" protocol = "AJP/1.3" redirectport = "8443"/>
<Engine name = "Catalina" defaulthost = "localhost"/>
Overwrite with the following configuration information. If the red port needs to be modified on the local machine, the jvmroute parameter cannot be the same
<Engine name = "Catalina" defaulthost = "localhost" jvmroute = "worker1"/>
<Cluster classname = "org. Apache. Catalina. Ha. tcp. simpletcpcluster" channelsendoptions = "8">
<Manager classname = "org. Apache. Catalina. Ha. session. deltamanager"
Expiresessionsonshutdown = "false"
Notifylistenersonreplication = "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" type = "codeph" text = "codeph"/>
<Cycler classname = "org. Apache. Catalina. tribes. Transport. NiO. nioreceiver"
Address = "192.168.1.102"
Port = "4000"
Autobind = "100"
Selectortimeout = "5000"
Maxthreads = "6"/>
<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"/>
</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>
E. Configure tomcat. x/webapps/examples/WEB-INF/Web. XML with red to support seesion Replication
In the <webapp>
...........
.........
<Distributable/>
</Webapp>
Finally, copy the files in webapps under tomcat to/opt/web/apache2/htdocs.
CP-r/opt/web/tomcat1/Apache-Tomcat-6.0.32/webapps/*/opt/web/apache2/htdocs
Server Load balancer and session configuration have been completed.
Start apache2
CD/opt/web/apache2/bin
./Apachectl-K start
Start two Tomcat servers
CD/opt/web/tomcat2/Apache-Tomcat-6.0.32/bin
./Start. Sh
CD/opt/web/tomcat1/Apache-Tomcat-6.0.32/bin
./Start. Sh
Test session replication
Http: // 192.168.1.102/examples/Servlets/servlet/sessionexample
View Server Load balancer
Http: // 192.168.1.102/balancer-Manager
But there is a problem. If the session has many objects and the objects keep changing, this will cause the seesion to consume a lot of performance.
After checking on the Internet, you can use memcached to cache the application. You can sort it out later.
From: http://www.cnblogs.com/montya/archive/2011/10/07/2190688.html