This article aims to analyze the current situation of Jetspeed clusters. First, I introduced the background knowledge of cluster computing, and used tomcat as an example to configure a cluster. Then I analyzed jetspeed's support for the cluster and proposed a solution to these problems, finally, the operation of jetspeed to save sesson data is explained in detail, which will be helpful for the transformation of jetspeed.
1. Cluster background
1.1 Glossary
Service software is the s part of the B/s or c/s structure. It is a service software system that provides services for B or c.
Service hardware refers to the hardware that provides computing services, such as PCs and pc servers.
Service entities refer to service software and service hardware.
The client is the software or hardware that accepts the service entity service.
1.2 two key features
A cluster is a group of service entities that work collaboratively to provide a service platform that is more scalable and available than a single service entity. In the client's view, a cluster is like a service entity, but in fact the cluster is composed of a group of service entities. Compared with a single service entity, a cluster provides the following two key features:
Scalability-the cluster performance is not limited to a single service entity. New service entities can be dynamically added to the cluster to enhance the cluster performance.
High Availability-the cluster uses service entity redundancy to free the client from warnings of out of service. In a cluster, the same service can be provided by multiple service entities. If a service entity fails, the other service entity takes over the failed service entity. The function provided by the cluster to restore an error service entity to another service entity enhances the availability of the application.
1.3 two capabilities
To ensure scalability and high availability, clusters must have the following two capabilities:
Server Load balancer (SLB) distributes tasks evenly to computing and network resources in the cluster environment.
Error Recovery-for some reason, the resource that executes a task fails, and the resource that executes the same task in the other service entity completes the task. This is because resources in one entity cannot work, and the process of transparently continuing to complete tasks in other entities is called error recovery.
Both Server Load balancer and error recovery require that resources of the same task exist in each service entity, and the Information view context required to execute the task for each resource of the same task) must be the same.
1.4 two major technologies
To implement a cluster, you must have the following two technologies:
Cluster address: a cluster consists of multiple service entities. The cluster client obtains the functions of each service entity in the cluster by accessing the cluster address of the cluster. A single cluster address is also called a single image) is a basic feature of the cluster. The setting of maintaining the cluster address is called the Server Load balancer. The server Load balancer manages the addition and exit of various service entities, while the external server is responsible for switching the cluster address to the internal service entity address. Some load balancers implement real load balancing algorithms, and some only support task conversion. Server Load balancer that only implements task conversion is applicable to cluster environments that support ACTIVE-STANDBY. There, only one service entity in the cluster works. When a working service entity fails, the server Load balancer redirects subsequent tasks to another service entity.
Internal communication-in order to work collaboratively and achieve load balancing and error recovery, all entities in the cluster must communicate frequently, for example, the Server Load balancer communicates the heartbeat test information of the service entity and the context information of tasks between the service entities.
With the same cluster address, the client can access the computing services provided by the cluster. The internal addresses of various service entities are hidden under one cluster address, this allows the customer to request a computing service to be distributed among various service entities. Internal communication is the basis for the normal operation of the cluster, which enables the cluster to have load balancing and error recovery capabilities.
2. cluster configuration
A cluster consists of service entity 1, service entity 2, and Server Load balancer. Service entity 1 and service entity 2 participate in service support for the client. The Server Load balancer maintains a single image of the cluster for the client. Cluster entities exchange information through internal communication networks. This communication mechanism generally uses multicast protocols. The server Load balancer detects the heartbeat information of each service entity through the internal communication network, and the service entity transmits task resources through the internal communication network. It can be seen that the configuration cluster consists of the configuration service entity and the configuration Load balancer. This article uses tomcat 4.12 and apache 2.0.43 to configure the cluster environment. The deployment diagram of related software is as follows:
Service entity 1/2: the Server Load balancer can be deployed on different machines or on the same machine. The environment described in this article is the same machine.
2.1 prepare software
Tomcat is an open source servlet \ jsp server, download location http://jakarta.apache.org /;
Apache 2.0.43 is an open source www server, download location http://www.apache.org/dist/httpd/binaries;
JavaGroups is a communication protocol for inter-entity communication of cluster services,: http://www.javagroups.com /;
Tomcat session replication library, based on the JavaGroups communication protocol, to complete the cluster service entity task execution context replication,: http://www.filip.net/tomcat/tomcat-javagroups.jar
Jk2 module. jk is a replacement of mod_jserv. It is a Tomcat-Apache plug-in that handles communication between Tomcat and Apache and acts as a Load balancer in cluster configuration. JK2 is a new product in line with apache 2.x series: http://jakarta.apache.org/builds/jakarta-tomcat-connectors/jk2/release/v2.0.2/bin /.
2.2 Configure the server Load balancer
Configure the server Load balancer in apache in three steps. Do not forget to restart apache every time you modify httpd. conf and workers2.properties.
Step 1: Install and debug apache
The jk2 module of the Server Load balancer is a plug-in of the apache www Service. Therefore, you must install apache before configuring the Server Load balancer. In this article, we download the windows version 2.0.43. execute setup.exe and answer some simple questions to complete the apache task. It is worth noting that after apache is installed and started, if apache does not respond to http: // localhost/address, you must modify the index.html.xxfile in the htdocsdirectory under apache installation, such as changing index.html. en to index.html.
Step 2: Install jk2
Change the downloaded mod_jk2-2.0.43.dll to mod_jk2.dll to the modules directory of apache, modify httpd. conf of apache, that is, insert mod_jk2 module loading information under LoadModule foo_module modules/mod_foo.so:
# Example:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule jk2_module modules/mod_jk2.dll
Step 3: Configure jk2
Jk2 configurations are all in one configuration file named workers2.properties, which is in the same directory as apache httpd. conf. The content of this file is as follows:
# ++
# Only at beginnin. In production uncomment it out
[Logger. apache2]
Level = DEBUG
# Shm configuration required
[Shm]
File = D: \ Program Files \ Apache Group \ Apache2 \ logs \ shm. file
Size = 1048576
# The address of the First tomcat
# Example socket channel, override port and host.
[Channel. socket: 0000at1]
Port = 11009
Host = 127.0.0.1
# Define the first worker pointing to the First tomcat
# Define the worker
[Ajp13: tomcat1]
Channel = channel. socket: 0000at1
# The second tomcat address
# Example socket channel, override port and host.
[Channel. socket: tomcat2]
Port = 12009
Host = 10.1.36.123
# Define the second worker pointing to the second tomcat
# Define the worker
[Ajp13: tomcat2]
Channel = channel. socket: tomcat2
# Define a Server Load balancer so that it contains two workers
[Lb: lb1]
Worker = ajp13: tomcat2
Worker = ajp13: worker at1
# Specify the Server Load balancer to map a single address so that the uri of the apache service points to two # tomcat root Uri mapping
[Uri:/*]
Group = lb: lb1
# ++ ++
For the Server Load balancer configuration of the jk2 module, see related sites. It is worth mentioning that the Server Load balancer of jk2 also supports excellent features such as weight distribution.
2.3 configure tomcat
It belongs to two service entities in a cluster and requires the same feature. Therefore, we can install and configure the First tomcat, copy it to form the second tomcat, and configure the second tomcat.
2.3.1 install the First tomcat
Installing tomcat is very simple and will not be described in this article. Assume that the First tomcat installation path is d: \ tomcat1.
Copy the tomcat-javagroups.jar and javagroups. jar to the d: \ cmdat1 \ server \ lib path.
2.3.2 configure the First tomcat
2.3.2.1 configure jk2
The default port of jk2 ctor in tomcat is 8009. To run two tomcat servers on one machine, modify D: \ Tomcat1 \ conf \ jk2.properties and set the port of jk2 connector to 11009, the content of the entire file is as follows:
# ++
ChannelSocket. port = 11009
# ++
2.3.2.2 modify server. conf
First, modify the tomcat Stop command listening port of server. conf to run two tomcat servers on one machine:
Change
Then open JK2 AJP connector and close other connector. The following figure shows JK2 AJP 1.3. Here, we have changed its port to 11009:
Port = "11009" minProcessors = "5" maxProcessors = "75"
EnableLookups = "true" redirectPort = "8443"
AcceptCount = "10" debug = "0" connectionTimeout = "20000"
UseURIValidationHack = "false"
ProtocolHandlerClassName = "org. apache. jk. server. JkCoyoteHandler"/>
Configure the context of the webapp such as examples that requires cluster support and add the following manager:
ClassName = "org. apache. catalina. session. InMemoryReplicationManager"
ProtocolStack = "UDP (mcast_addr = 228.1.2.3; mcast_port = 45566; ip_ttl = 32): PING (timeout = 3000;
Num_initial_members = 6): FD (timeout = 5000): VERIFY_SUSPECT (timeout = 1500 ):
Pbcast. STABLE (desired_avg_gossip = 10000): pbcast. NAKACK (gc_lag = 10;
Retransmit_timeout = 3000): UNICAST (timeout = 5000; min_wait_time = 2000 ):
MERGE2: FRAG: pbcast. GMS (join_timeout = 5000; join_retry_timeout = 2000;
Shun = false; print_local_addr = false) ">
Note that the value of protocolStack must be written in one row.
2.3.3 configure the second tomcat
First, copy the first tomcat that has been configured to form the second tomcat. Assume that the path is d: \ tomcat2.
2.3.3.1 configure jk2
Modify D: \ Tomcat2 \ conf \ jk2.properties and set port 12009 of jk2 connector. The content of the entire file is as follows:
# ++
ChannelSocket. port = 12009
# ++
2.3.3.2 modify server. conf
With the First tomcat configuration, we only need to modify the tomcat Stop command listening port of server. conf:
Change
Set JK2 AJP connector port to 12009.
2.4 run the test
Start apache, tomcat1, and tomcat2.
2.4.1 test Server Load balancer
We first prepare two files, the first file is test. jsp, and copy them to the directory of the ROOT web application of the First tomcat, that is, d: \ tomcat1 \ webapps \ ROOT:
<% = Request. getSession (). getId () %>
Tomcat 1
The second file is also test. jsp. Copy it to the directory of the ROOT web application of the second tomcat, that is, under d: \ tomcat2 \ webapps \ ROOT:
<% = Request. getSession (). getId () %>
Tomcat 2
Enter the address http: // localhost/test. jsp multiple times in different browsers to see different colors, which indicates that the jk2 module in apache plays a role in Server Load balancer.