JBoss Series II: High-availability clustered environments using Apache httpd (mod_cluster) and JBoss architecture

Source: Internet
Author: User
Tags infinispan jboss using git git clone
What is an enterprise application cluster

Cluster refers to the aggregation of different servers together, a collection of servers, which provides the client with a virtual platform, so that clients do not know the structure of the server collection can be deployed to the server collection of applications, access to services and other operations. Clustering is a key feature of enterprise applications, and it can provide:

High scalability: You can add as many servers as you want to the cluster high availability: Use transparent load balancing and fault tolerant mechanisms to hide errors inside the cluster for clients

Whether you are expanding the number of nodes in your cluster, or configuring load balancing, fault tolerance, the state of each node in the cluster must be consistent, and the state in the cluster needs to be implemented with a caching mechanism (JBoss uses jgroups,infinispan, which we describe later in the series). The following figure is a traditional enterprise application cluster mode:

Figure-1 traditional enterprise application clusters
The steps in the diagram are described below:

1. The client browser sends the request

2. Load Balancer forwards requests to Node 1

3. Exception occurred while node 1 was processing the business

4. Load Balancer switch request to Node 2

5. Node 2 complete the business request to return the results to the client request

The client does not know that the server-side node 1 exception occurred during the completion of the above business request. At the core of the business is the real-time state replication between the two nodes, and the need for state replication with the help of the caching framework and the product (JBoss uses Jgroups,infinispan, which we'll cover later in the series). High-availability clustered environments using Apache httpd and JBoss Architecture

Apache httpd as a load balancer and background middleware server to build a high-availability enterprise application cluster is a very common way, currently the main three middleware Jboss,weblogic,websphere support Apache httpd as a load balancer. JBoss's Open source product is the most widely used middleware, and JBoss has launched the Enterprise EAP (Enterpriseapplication Platform) after being acquired by Red Hat, making JBoss available in many core business areas. For example, the bottom of the Indian railway system is JBoss, and the 2012 London Olympic system is the base of 4 JBoss clusters. Below we will use JBoss and Apache httpd to give a solution to build a high-availability enterprise application cluster.
Introduction and purpose of the program

This scenario uses the products of the open source JBoss community to build a highly available enterprise cluster environment, with the load balancer on top of the cluster nodes. Through this scheme, we can realize that the high availability of enterprise application is mainly due to the synchronization of state between cluster nodes, that is, session Replication, and how to copy the session is the main topic of this book. Let's start with the architecture diagram for this scenario:

Figure-2 Scheme design architecture

As above, using JBoss AS7 as a cluster node, for simplicity we only use two JBoss, that is, there are two nodes in a cluster. Apache httpd and Mod_cluster do load balancers, mod_cluster as an Apache plug-in module that connects Apache and JBoss, distributes and requests to back-end JBoss based on load balancing policies, so we can put Apache HTTPD plus mod_cluster as a load balancer.

Session replication for this program is done through the JBoss Community product jgroups and the second generation Jbosscache product Infinispan, but we do not have any discussion of jgroups and Infinispan, We will discuss jgroups and Infinispan in detail later in the series.

In addition, this scenario is done on the open source Linux operating system Fedora 15, we list the hardware and software used in this scenario, three physical machines, memory 4GB or above, install Fedora 15 After the IP address is 10.66.192.48,10.66.192.231,10.66.192.232, we respectively to the three physical machines to do the corresponding installation of the following:

10.66.192.231– Installing JDK 1.6,jboss 7,jboss node name is Node1
10.66.192.232– Installing JDK 1.6,jboss 7,jboss node name is Node2
10.66.192.48– Installing Apache Httpd,mod_cluster

Next we will discuss this scenario from the scenario configuration, the installation of the test application, and the analysis of the results. Scenario Configuration download Mod_cluster related installation package

On the JBoss Community mod_cluster page (http://www.jboss.org/mod_cluster) Select Download (Downloads), the appropriate version (1-2-0-final) is selected, and the popup page lists the relevant Java Modules (primarily for cluster configuration with JBoss as 6 and earlier), compiled apachehttpd, Apache httpd-side dynamic module packages. Depending on your platform select the relevant package for download we will get the following file:

Mod_cluster-1.2.0.final-bin.tar.gz
Mod_cluster-1.2.0.final-linux2-x86-so.tar.gz
Mod_cluster-1.2.0.final-linux2-x86-ssl.tar.gz

Unzip mod_cluster-1.2.0.final-bin.tar.gz We'll get some Java components and test examples for JBoss as 6 and earlier.

Unzip mod-cluster-1.0.0-linux2-x86-ssl.tar.gz we will get a setup configuration complete httpd located in the Opt/jboss directory. We do not use this installation here, we use the installation package from the operating system level, as shown in the following article. Unzip the mod_cluster-1.2.0.final-linux2-x86-so.tar.gz and we will get the following package:

Mod_advertise.so
Mod_manager.so
Mod_proxy_cluster.so
Mod_slotmem.so

As shown below, we need to copy these dynamic packages to the modules directory of Apache httpd to maintain and manage the connection between Apache httpd and back-end JBoss, and communicate. Installing Apache httpd

Please refer to series one Apache httpd installation (http://blog.csdn.net/kylinsoong/article/details/12291173)
Apache httpd terminal configuration

Edit the httpd/conf/httpd.conf and let httpd listen on the 10.66.192.48:80:

Listen 10.66.192.48:80
Copy mod_cluster all. So files (mod_advertise.so, mod_manager.so, mod_proxy_cluster.so,mod_slotmem.so) to the Httpd/modules directory:

CP *.so  /etc/httpd/modules
Edit the httpd/conf/httpd.conf and comment out the Mod_proxy_balancer module to be incompatible with mod_cluster-related modules for this module:

# LoadModule Proxy_balancer_module modules/mod_proxy_balancer.so
Create the jboss_http.conf file under the HTTPD/CONF.D directory and add the following to this file:

# Add Mod_cluster Reference module
LoadModule slotmem_module modules/mod_slotmem.so LoadModule
manager_module modules/mod_manager.so
LoadModule proxy_cluster_module modules/mod_proxy_cluster.so
LoadModule advertise_ Module modules/mod_advertise.so

Listen 10.66.192.48:6666
<virtualhost 10.66.192.48:6666>
    < Directory/>
        Order deny,allow allow from all
    </Directory>
    <location/mod_ cluster-manager>
        SetHandler mod_cluster-manager
        Order deny,allow allow from all
    </ location>
          keepalivetimeout
          maxkeepaliverequests 0
          advertisefrequency 5
          Managerbalancername kylincluster
          serveradvertise Off
          enablemcpmreceive on
</VirtualHost>

After configuration is complete reboot Apache httpd, if the boot display succeeds indicates the configuration is correct.

JBoss Port Configuration

There are three ways we can add Proxy-list,balancer to complete the JBoss-side cluster configuration:

1. Modify the configuration file

Edit the/standalone/configuration/standalone-ha.xml file, locate the Urn:jboss:domain:modcluster section, and modify the properties of the Mod-cluster-config as follows:

<mod-cluster-config advertise-socket= "Modcluster" proxy-list= "10.66.192.48:6666" balancer= "KylinBalancer" Sticky-session= "true" connector= "AJP" >
The configuration is completed by saving the modified file.

2. Through the Web management interface

Start the JBoss post-Login Management interface (http://localhost:9990/console) in Standalone-ha.xml mode (./standalone.sh-c standalone-ha.xml), Select Profile,web,mod_cluster, click the relevant button in the popup screen, edit the balancer value to kylinbalancer,proxy-list value to 10.66.192.48 : 6666,sticky-session value is true, click the Save button to complete the configuration.

3. Manage Windows from the command line

After starting JBoss in Standalone-ha.xml mode (./standalone.sh-c standalone-ha.xml), go to the command line interface and execute the following command in turn:

/subsystem=modcluster/mod-cluster-config=configuration/:write-attribute (Name=balancer,value=kylinbalancer)
/subsystem=modcluster/mod-cluster-config=configuration/:write-attribute (name=sticky-session,value=true)
/subsystem=modcluster/mod-cluster-config=configuration/:write-attribute (name=proxy-list,value= 10.66.192.48:6666)

Note: The value of the proxy-list,balancer mentioned in the above three steps needs to correspond to the Apache httpd side configuration, we should configure the two nodes in turn


Start complete cluster scenario configuration 1. Launch Apache httpd

Under Linux operating system, use the following command to complete the boot Apache httpd:

Service httpd Start
2. Start JBoss Two nodes in turn using the following command

./standalone.sh-c standalone-ha.xml-b 10.66.192.231-bmanagement 10.66.192.231-u 239.255.100.100-djboss.node.name= Node1-djboss.mod_cluster.jvmroute=node1

./standalone.sh-c standalone-ha.xml-b 10.66.192.232-bmanagement 10.66.192.232-u 239.255.100.100-djboss.node.name= Node2-djboss.mod_cluster.jvmroute=node2

3. Detection of startup conditions

Start to complete the following interface tests:

Login Http://10.66.192.48:6666/mod_cluster-manager Display Mod_cluster interface login http://10.66.192.231:9990/console display node 1 management interface
Login http://10.66.192.232:9990/console Display Node 2 admin interface
deployment test Application and Results analysis

This section includes deployment of test applications, fault tolerance and high availability testing, and results analysis of three aspects to illustrate. deploy a test app

Using git clone our test code required for this series (Reference frame column A GitHub client Installation section), clone completed after the completion of the series two directory, is also our use of the test project, specifically:

CD csdn/2/
In this directory, perform maven (Maven install reference Series one maven install section) to compile the series two project:

MVN clean Install
After compilation, the Webcluster-session-replication.war is generated and the path is Csdn/2/target/webcluster-session-replication.war, respectively.

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.