Monday, June 7, 2010

End-to-end Weblogic Clustering steps with Apache Proxy Plug-in

End-to-end Weblogic Clustering steps with Apache Proxy Plug-in


Purpose


This tutorial will give you quick overview about how to create a new cluster using tow physical boxes and how to configure Apache Proxy Plug-in as a load balancer. It is assumed that person must have good knowledge of J2EE & Weblogic Server.

Topics


This tutorial covers the following topics:

1.      Overview

2.      System Requirements

3.      Creating a Cluster

4.      Monitoring the Cluster

5.      Load Balancing using Apache Web server & Proxy plug-in

6.      Create a clustered-enabled web-application for Weblogic Server

7.      Deployment on Clustered

8.      Best Practices

9.      Related Information

Overview


A WebLogic Server cluster consists of multiple WebLogic Server instances, running simultaneously and working together to provide increased scalability and reliability. A domain includes one or more WebLogic Server instances, which can be clustered, nonclustered, or a combination of clustered and nonclustered instances. A domain can include multiple clusters.

A cluster appears to clients as one WebLogic Server instance. The server instances that constitute a cluster can run on one machine or on different machines. You can increase a cluster’s capacity by adding server instances to the cluster on an existing machine, or by adding machines to the cluster to host the incremental server instances.

All server instances in a cluster use multicast or unicast to broadcast regular server heartbeat messages to other members of the cluster. Each heartbeat message contains data that uniquely identifies the server that sends the message. Servers broadcast their heartbeat messages at regular intervals. In turn, each server in a cluster monitors the multicast or unicast address to ensure that all peer servers’ heartbeat messages are being sent.

System Requirements


Make sure that your system environment meets the following requirements:

Software Requirements
  • Ms. Windows 20003
  • Oracle Weblogic Server 10.3
  • Apache Web Server 2.2

Minimum Hardware Requirements

Item Specification
Processor Type Intel Xeon
Processor Speed 2.4 GHz or higher
Number of Processor 1 or more (if required)
Memory 4 GB
Free Hard Disk Space 20 GB
Operating System MS. Windows 2003


Creating a Cluster


Perform the following steps:

1.      Install Weblogic Server in Box-A and Box-B in the same directory structure.

Box-A   Suppose IP Address is : 192.168.1.1
Box-B   Suppose IP Address is : 192.168.1.2

2.      Create a Domain (myDomain)  in Box-A then Start the AdminServer (suppose port is 7001 for Admin) of that newly created Domain

3.      Open Admin Console http://192.168.1.1:7001/console

4.       Create two Managed Servers MS3 and MS4 with following configurations.

MS3 Listen Port: 7003
MS3 Listen Address: 192.168.1.1

MS4 Listen Port: 7003
MS4 Listen Address: 192.168.1.2

5.      Create two machines (M1 and M2) with following node manager configuration and add MS3 to M1 and MS4 to M2.

M1
Nodemanager Listen Address: 192.168.1.1
Nodemanager ListenPort: 5556

M2
Nodemanager Listen Address: 192.168.1.2
Nodemanager ListenPort: 5556

6.       Now start NodeManager in Box-A and see in the admin console that its accessible from M1.

Home –>Summary of Machines –>Machine-A –>Monitoring
Make sure that the Nodemanager Status is “Reachable”.

Steps For Box-B (Second Managed Server Box)

7.      Paste the Domain from Box-A to Box-B in the Same Location where it is available in Box-A.

8.      Open the command prompt and set environment variables using setWLS.cmd.

9.      Enroll NodeManager of Box-A with myDomain created in Box-B  using following WLST command:-

nmEnroll('C:/bea/user_projects/domains/myDomain',
'C:/bea/wlserver_10.0/common/nodemanager')

10.            Start the NodeManager at Box-B and login to AdminConsole of Box-A and then check that the Machine-2 Nodemanager is showing “reachable”.

11.  Create a Cluster with following information:-

Field Value
Name myCluster
Messaging Mode Unicast
Clustered Address 192.168.1.1:7003, 192.168.1.2:7003


12.  Click myCluster. Click the Configuration > Servers tab.



Add MS3 and MS4 servers in myCluster and click Finish.

13.  Start the MS3 using following shell command:-

myDomain\bin>startManagedWebLogic.cmd MS3 192.168.1.1:7001 from Box-A

14.  Watch the server start up using the shell's standard output stream.  At some point, you should see it begin listening for cluster communication and begin waiting to synchronize with other servers in the cluster. Because the other servers have not started, there is nothing for it to synchronize with yet:

<Jun 3, 2010 5:41:36 AM CDT> <Notice> <Cluster> <BEA-000197> <Listening for announcements from cluster using unicast cluster messaging>

<Jun 3, 2010 5:41:36 AM CDT> <Notice> <Cluster> <BEA-000133> <Waiting to synchronize with other running members of Cluster_1.>

<Jun 3, 2010 5:42:06 AM CDT> <Notice> <Cluster> <BEA-000162> <Starting "async" replication service with remote cluster address "null">

15.  Repeat the previous steps to start the other managed servers from the Box-B. Once again, use the shell's standard output stream or the server log to confirm that the servers joined the cluster successfully:

myDomain\bin>startManagedWebLogic.cmd MS4 192.168.1.1:7001



<Jun 3, 2010 6:03:07 AM CDT> <Notice> <Cluster> <BEA-000197> <Listening for announcements from cluster using unicast cluster messaging>

<Jun 3, 2010 6:03:07 AM CDT> <Notice> <Cluster> <BEA-000133> <Waiting to synchronize with other running members of Cluster_1.>

<Jun 3, 2010 6:03:16 AM CDT> <Notice> <Cluster> <BEA-000142> <Trying to download cluster JNDI tree from server MS4.>

<Jun 3, 2010 6:03:16 AM CDT> <Notice> <Cluster> <BEA-000164> <Synchronized cluster JNDI tree from server MS3.>

Above information is showing that cluster has been created successfully.

Monitoring the Cluster


1.      Return to the administration console. Select Environment > Clusters from the Domain Structure panel. Then select your cluster.

2.      Click the Monitoring tab. You can see summary, health and Failover tabs. The Cluster—>Monitoring page displays how many Managed Servers are configured for the current cluster, and how many of the configured Managed Servers are currently running. For each Managed Server configured for the cluster, the monitoring table displays the current state of the server instance, and metrics about activity since the server instance was started.




Load Balancing using Apache Web server & Proxy plug-in


The Apache HTTP Server Plug-In allows requests to be proxied from an Apache HTTP Server to WebLogic Server. The plug-in will also serve as a load balancer for Weblogic Server.

Note: You can install apache server on Weblogic machine or separate machine. Assume Apache Web Server is running at http://192.168.1.3:80

The Apache plug-in is distributed as a shared object (.so) for windows.

1.    Copy the mod_wl_22.so (for Apache 2.2) from <Bea-Home>\server\plugin\win\32 to <Apache-Home>\modules\

2.    Add following lines in the httpd.config file for single clustered:-

LoadModule weblogic_module modules/mod_wl_22.so

<IfModule mod_weblogic.c>

WebLogicCluster 192.168.1.1:7003, 192.168.1.2:7003

Debug                    ON

WLLogFile             c:/tmp/global_proxy.log

WLTempDir             "c:/myTemp"

DebugConfigInfo       On

KeepAliveEnabled       ON

KeepAliveSecs         15

DynamicServerList     ON

</IfModule>

<Location /weblogic>

SetHandler weblogic-handler

Path-trim weblogic

</Location>

Note:-  Apache plug-in will treat 192.168.1.1:7003 as primary server. It mean first request will go to MS3 managed server.

3.    Restart Apache Server.

4.      Deploy the application on a cluster. For example your application context path is sessionDemo.

5.      Now, access the application using Apache Server like

http://192.168.1.3:80/weblogic/sessionDemo


Where 192.168.1.3:80 is the IP address and port of Apache Web Server.


6.     To verify the configuration of the proxy server & status of Weblogic Managed Server:-


http://192.168.1.3:80/weblogic/sessionDemo/session.jsp?__WebLogicBridgeConfig


Clustering Best Practices


  1. When creating the clustered WebLogic Server instances on a single machine, specify an unused localhost port such as 127.0.0.1 for the Listen Address. If you leave the Listen Address field blank, the server binds to all available IP addresses on the machine. If you specify "localhost" as the Listen Address, the server binds to all localhost addresses (127.0.0.x).
  2. When creating a new cluster, it is recommended that you use unicast for messaging within a cluster. For backward compatibility with previous versions, WebLogic Server you must use multicast for communications between clusters.
  3. Always specify an unused Multicast address and port number for production clusters. This ensures that only the cluster's messages are broadcast on the address/port combination.

4.      Do not install WebLogic Server on machines that have dynamically assigned IP addresses.

Related Information


  • Weblogic Clustering

http://download.oracle.com/docs/cd/E11035_01/wls100/cluster/setup.html
  • Weblogic Clustering

http://biemond.blogspot.com/2008/11/build-your-own-weblogic-103-cluster.html
  • Cluster unicast messaging mode

http://weblogic-server.blogspot.com/2010_02_01_archive.html
  • J2EE Clustering

http://www.theserverside.com/news/1364410/Under-the-Hood-of-J2EE-Clustering
  • Installing and Configuring the Apache HTTP Server Plug-In

http://download.oracle.com/docs/cd/E15051_01/wls/docs103//plugins/apache.html