Tuesday, November 23, 2010

FAQ #30 - How to setup a WebLogic cluster load balancer using Apache and the Apache HTTP Server Plug-In


Load balancing refers to obtaining high availability and better performance by dispatching incoming user requests to different servers on a clustered setup. A load balancer can be anything from a simple servlet or plug-in, to expensive hardware. In this FAQ we will take a look at the Apache HTTP Server Plug-In and how it can be configured to proxy requests to the WebLogic cluster that we setup in FAQ #27 and FAQ #28.

Main Theme

"The Apache HTTP Server Plug-In allows requests to be proxied from an Apache HTTP Server to WebLogic Server. The plug-in enhances an Apache installation by allowing WebLogic Server to handle requests that require the dynamic functionality of WebLogic Server.

The plug-in is intended for use in an environment where an Apache Server serves static pages, and another part of the document tree (dynamic pages best generated by HTTP Servlets or JavaServer Pages) is delegated to WebLogic Server, which may be operating in a different process, possibly on a different host. To the end user—the browser—the HTTP requests delegated to WebLogic Server still appear to be coming from the same source.

The Apache HTTP Server Plug-In operates as an Apache module within an Apache HTTP Server. An Apache module is loaded by Apache Server at startup, and then certain HTTP requests are delegated to it. Apache modules are similar to HTTP servlets, except that an Apache module is written in code native to the platform."

In this example we will be installing the Apache HTTP Server on a separate Linux box. If you have followed the two previous FAQs (FAQ #27 and FAQ #28), we have setup a WebLogic cluster comprised of two Managed Servers running on two separate Linux machines.

Briefly the steps involved are:

1. Install the Apache HTTP Server
2. Install and configure the Apache HTTP Server Plug-In
3. Verify the load balancer

So, let's get started.

1. Install the Apache HTTP Server

We will be installing Apache on an openSUSE Linux distribution. Start by opening a terminal window and as root install Apache by typing: yast2 --install apache2. This will initiate YaST2 to download and install Apache.

Verify that the installation is successful by typing rcapache2 status in the terminal window. It should respond with status unused.

To test the installation we will need to create an index.html file in /srv/www/htdocs and start Apache by typing rcapache2 start.

Finally open a browser window and verify that the server is accessible.

For administration purposes it is recommended that you create an Apache administrator user account and give it ownership of the /srv/www, /srv/ftp and /etc/apache2 directories, the apache startup script /etc/init.d/apache2 and the log directory /var/log/apache2. Also add /usr/sbin to the account's path to get access to the rcapache2 start-up link.

The process of installing Apache is similar for other Linux distributions. For Windows you will have to  download the Apache binary installation package from the Apache HTTP Server Project web site -  http://httpd.apache.org/ at the time of this writing - and run the installation yourself.

2. Install and configure the Apache HTTP Server Plug-In

To download the Apache HTTP Server Plug-In go to the Oracle WebLogic downloads site - currently http://www.oracle.com/technetwork/middleware/ias/downloads/wls-main-097127.html - and click Oracle WebLogic Server Web Server Plugins 1.1 All versions under the Additional Fusion Middleware Downloads section. You will have to first click See All under the Oracle WebLogic Server 11g Rel 1 (10.3.3) Installers section to see the Additional Fusion Middleware Downloads.

This will download a cumulative archive - called WLSPlugin1.1-11gR1PS2.zip - which contains all WebLogic plug-ins.  Open the archive and extract the archive appropriate for your Operating System, for this example - a 64-bit Linux distribution - it is called WLSPlugin1.1-64bitApache2.2-linux64-x86_64.zip.

To install the WebLogic Plug-In first extract the contents of the appropriate zip file - for this example we logged-in using the apache administrator account and extracted the WebLogic Plug-in into the  /home/apache/WLSPlugin1.1-64bitApache2.2-linux64-x86_64 directory. Then edit the httpd.conf file in /etc/apache2 and add the following section:

# WebLogic load balancer add-in configuration
LoadModule weblogic_module /home/apache/WLSPlugin1.1-64bitApache2.2-linux64-x86_64/lib/mod_wl.so
<ifModule mod_weblogic.c>
  Debug             ON
  WLLogFile         /home/apache/WLSPlugin1.1-64bitApache2.2-linux64-x86_64/log/mod_wl.log
  WLTempDir         /home/apache/WLSPlugin1.1-64bitApache2.2-linux64-x86_64/tmp
  DebugConfigInfo   ON
  KeepAliveEnabled  ON
  KeepAliveSecs     15
  DynamicServerList ON

<Location /cluster>
    SetHandler weblogic-handler

Change the cluster IP addresses and ports appropriately for your setup. Also ensure that the log and temporary directories that you specify exist - for this example we have created a log and a tmp directory inside the directory where we originally extracted the plug-in. Lastly, make sure that the plug-in library directory is listed in the LD_LIBRARY_PATH environment variable.

Now restart Apache and observe that there are no errors. For complete installation instructions refer to the file README.txt included in the compressed archive.

3. Verify the load balancer

To verify the load balancer installation you need to send a request to a http://apache-host:apache-port/cluster/  URL, where apache-host is the host running Apache, apache-port is the Apache HTTP port, cluster is the configurable context path we specified above with the <Location> tag when configuring the plug-in. Because of the /cluster context in the URL path, Apache will forward the request via the WebLogic Plug-In to the WebLogic cluster. Any requests that do not contain the /cluster context in the URL will be served normally by Apache. 

So, let's start JDeveloper and create a simple ADF application. On the Edit WAR Deployment Profile Properties dialog make sure that cluster is specified as the Java EE Web Context Root.

Ensure that the cluster is up and running, create an Application Server connection to the WebLogic cluster, an application deployment profile and deploy the application on the cluster.

Observe at the log window that the deployment is successful for all managed server nodes that make up the cluster.

You can test the load balancer by sending the following request http://apache-host:apache-port/cluster/faces/TestLoadBalancer.jspx, for this example the IP address of the Apache server is, so the complete URL is Apache recognizes the /cluster context path in the URL and forwards the request to WebLogic via the WebLogic Plug-In!

Any requests that do not contain the /cluster context in the URL are served normally by Apache.

For the Apache WebLog Plug-In logs refer to the log file defined during the configuration earlier.


In this post we 've seen how a software Load Balancer based on Apache and the Apache WebLogic Plug-In could be setup to work along with a cluster setup.

Until the next time, keep on JDeveloping!

Sunday, November 7, 2010

FAQ #29 - How to deploy the ADF runtime libraries to a WebLogic cluster


In FAQ #27 and FAQ #28 we went through a WebLogic cluster setup comprised of two WebLogic Managed Servers running on separate physical machines each. In this FAQ we will take a look at how to extend the clustered domain with the ADF runtime libraries.

Main Theme

The steps involved for extending a clustered domain are:

1. Backup the Middleware Home that contains the domain about to be extended
2. Install the ADF Runtime
3. Extend the WebLogic domain
4. Verify that the cluster is operating as expected

Note that steps 1 through 3 must be repeated for each physical machine that is part of the cluster setup.

Let's follow these steps then to extend the clustered domain that we setup in FAQ #27 and FAQ #28.

1. Backup the Middleware Home that contains the domain about to be extended

Before backing up the Middleware Home directory ensure that the domain is shutdown and that the node manager is not running on the specific machine. We will use tar and gzip to create and compress the Middleware Home archive, so change directory to your Middleware Home and type tar cvf hostname.date.middlewarehome.tar middlewareHomeDirectory, where hostname.date.middlewarehome.tar is the tar file that we will create and  middlewareHomeDirectory is the Middleware Home directory to archive, for example: tar cvf kvvm0007.20101107.middlewarehome.tar Oracle/

Once tar completes, compress the archive by typing gzip hostname.date.middlewarehome.tar

Keep the resulting tar.gz file just in case we need to restore the Middleware Home to its last configuration. 

2. Install the ADF Runtime

The ADF Runtime is distributed - among others - along with the JDeveloper installation package. So we will be using the JDeveloper installation to install it on our domain. Download the appropriate JDeveloper installation package for your operating system and start the JDeveloper installation. For installing on Linux you may refer to FAQ #26 - How to Install JDeveloper on Linux. Click Next on the Welcome screen and on the Choose Middleware Home Directory make sure that you select Use an existing Middleware Home. Verify that the Middleware Home selected is the one that contains the clustered domain to be extended.

On the Choose Products and Components page make sure that you select only the Application Development Framework Runtime - do not select JDeveloper Studio.

Click Next on the JDK Selection page. Verify that you have selected the correct Middleware Home on the Confirm Product Installation Directories page and click Next. On the Installation Summary page click Next to proceed with the installation. Ensure that only the Application Development Framework Runtime is included on the products to be installed.

The installation should proceed with no problems and complete. Uncheck the Run Quickstart and click Done to finish.

3. Extend the WebLogic domain

To extend the domain with the ADF libraries installed run the configuration script called config in wlserver_10.3/common/bin under the Middleware Home.

On the Welcome screen choose Extend an existing WebLogic domain and click Next. On the Select a WebLogic Domain Directory select the appropriate domain for the cluster and click Next.

On the Select Extension Source page select Oracle JRF - [oracle_common] and click Next.

On the Select Optional Configuration select Deployments and Services and click Next.

On the Target Deployments to Clusters or Servers ensure that all Libraries are targeted to both the Administration Server and the Cluster while the Applications are targeted only to the Administration Server. The page should look like the one below:

On the Target Services to Clusters or Servers make sure that all services are targeted to both the cluster and the Administration Server.

On the Configuration Summary page verify your selections and press Extend to extend the domain. The domain should be extended without any errors reported.

This concludes the process of extending the domain with ADF runtime. Remember that you will have to repeat the steps above for all the machines in the cluster.

4. Verify that the cluster is operating as expected

This step should be performed once you gone through steps 1 through 3 above for all the machines on the cluster. Start the domain Administration Server and the node managers for all machines and log in into the Administration Console. Using the Domain Structure tree click on Deployments and on the Summary of Deployments page verify that all the ADF libraries are on Active State.

This being the case, you can now proceed to start the Managed Servers. Click on Environment and then on Servers on the Domain Structure tree and on the Summary of Servers click on the Control tab. In the servers table select all the Managed Servers that comprise the cluster and click on the Start button to start them. Once started all servers should be in RUNNING State. The Health of the server should be indicated as OK.

This concludes the installation of the ADF runtime to the cluster.


Installing the ADF runtime on a clustered WebLogic domain involves the extension of the domain on each physical server machine. The ADF runtime can be installed using the JDeveloper installation package.

Until the next time, keep on JDeveloping (on a cluster)!

Friday, November 5, 2010

FAQ #28 - How to setup a WebLogic cluster, Pt. 2


In this second part of setting up a WebLogic cluster we will continue where we left of in part one and complete our cluster installation. We will also do some monitoring on the cluster setup to ensure that is configured and working properly.

Main Theme

Just to recap what we 've done so far:

1. we have installed WebLogic on both physical machines that make up the cluster,
2. we have created a WebLogic Domain in one of the physical machines, and
3. we have configured the domain: we created two WebLogic Managed Servers and two WebLogic Machines, we assigned the Managed Servers to WebLogic Machines and verified that the node manager running on the physical machines is reachable.

We will complete the setup by following these steps:

4. Copy the domain file structure to the other physical machine and enroll it to the WebLogic Domain
5. Ensure that both WebLogic Machines are operational
6. Create and configure the WebLogic Cluster
7. Ensure that the Cluster is operational

Let's get on with it!

4. Copy the domain file structure to the other physical machine and enroll it to the WebLogic Domain

WebLogic comes with a pack utility that allows you to pack a domain and move it from one place to another. We will instead use plain old Linux tar and gzip to pack our WebLogic domain directory file structure and move it from one physical machine - the one that we have done steps 2 and 3 so far - to the other. Before doing so, we will shutdown the domain and node manager if they are still running on the first machine. Once the packing is done, we will re-start them.

To shutdown the domain, simply press Ctrl-C within the console running the domain. Alternatively, you could shutdown the  domain by shutting down the Administration Server using the Administration Console. Once the  domain is shutdown, go to the Middleware Home directory and issue the following tar command to pack the domain directory file structure and contents, i.e. the user_projects directory: tar cvf user_projects.tar user_projects

When the tar command is done, zip the archive by typing: gzip user_projects.tar. The file that needs to be moved and unpacked on the other machine is called user_projects.tar.gz

The compressed archive of the user_projects domain file structure should be moved to the Middleware Home on the other physical machine - remember that the Middleware Home directories on both physical machines should be exactly the same - and uncompress by typing gunzip user_projects.tar.gz

Finally extract the archive by typing tar xvf user_projects.tar. This will create the user_projects directory structure on the second physical machine.

Now you need to re-start the domain - on the first (original) machine - and use the  WebLogic Scripting Tool - on the second machine - to enroll the domain structure - the one we just extracted - to the WebLogic Domain. So, after making sure that the domain is started and is in RUNNING state, issue the following commands on the second machine - the one we are now setting up - to enroll it to the WebLogic Domain:

Start the WebLogic Scripting Tool by changing to the wlserver_10.3/common/bin directory and typing wlst. On the wlst prompt issue the following command to connect to the WebLogic Domain running on the other machine: connect('weblogic','weblogic1','t3://')

Verify that the connection was successful and then issue the following command to enroll this machine to the WebLogic Domain

nmEnroll('/home/weblogic/Oracle/Middleware/user_projects/domains/clusteredDomain', '/home/weblogic/Oracle/Middleware/wlserver_10.3/common/nodemanager')

Verify that the machine was successfully enrolled into the Domain.

5. Ensure that both WebLogic Machines are operational

Now that the second machine was successfully enrolled into the WebLogic Domain, we can start the node manager on the second machine and verify that it is Reachable by the WebLogic Machine. We have already verified that the node manager on the first machine is Reachable back in step 3.

You can start the node manager by running the startNodeManager.sh script in the wlserver_10.3/server/bin directory. Again, ensure that the node manager is not started in SSL mode by setting the SecureListener parameter to false in the nodemanager.properties configuration file in wlserver_10.3/common/nodemanager. Note that nodemanager.properties might not exist until you first run startNodeManager.sh.

Now, with the node managers running on both physical machines return to the Administration Console and verify that the node managers are Reachable for both Machines.

6. Create and configure the WebLogic Cluster

To create a WebLogic Cluster use the Administration Console and via the Domain Structure tree navigate to Environment and then Clusters. On the Summary of Clusters table click the New button to create a new WebLogic Cluster.

On the Create a New Cluster page enter the Name of the Cluster, select Unicast for the Messaging Mode and click OK.

Ensure that the WebLogic Cluster is created successfully by observing the messages on the top Messages area and the new Cluster appearing in the Clusters table. Now, click on the newly created Cluster to go to the Settings for Cluster page. On the Configuration General tab on the Cluster Address field enter the IP addresses of the physical machines separated by comma(s) supplying 7003 as the cluster listen port, e.g., in this example. Click Save to save the changes.

While still on the Settings for Cluster page, go to the Configuration Servers tab and click Add on the Servers table to assign the Managed Servers to the Cluster.

On the Add a Server to Cluster page select the Managed Servers - one at a time - to add to the Cluster using the Select a server drop down and click Finish.

Repeat this step for both Managed Servers. In the end both Managed Servers should be shown on the Servers table for the Cluster.

7. Ensure that the Cluster is operational

Now that the Cluster is setup we can start the Managed Servers and do some monitoring on the Cluster to ensure its proper operation. You can start the Managed Servers either by running the startManagedWebLogic.sh script in the user_projects/domains/clusteredDomain/bin directory - for each physical machine - or from within the Administration Console. We will use the Administration Console to do so, which will at the same time validate our setup. So, go to the Summary of Servers page - via the Domain Structure tree by clicking on Environment and then Servers - and click on the Control tab. Click on the  checkboxes to select both Managed Servers - notice that they are both in SHUTDOWN state - and click the Start button to start them.

The Administration Console will delegate the start-up process to the node managers running on both machines. Each node manager will start the Managed Server assigned to the Machine controlled by the node manager. The process might take a minute or so to complete and once done both Managed Servers should be displayed on the Servers table with a RUNNING state. The Status of Last Action should be TASK COMPLETED. You will need to periodically refresh the page to see the final start-up status.

Now with both Managed Servers running, let's take a look at our Cluster status. Return to the Summary of Clusters page - via Environment and then Clusters on the navigation tree - and click on the Cluster in the Clusters table. Then click on the Monitoring tab and observe the Cluster Server status on the Summary tab.

Click on the Health and Failover tabs to see other monitoring information and status.

This concludes our Cluster setup.


In this two-part post we went through a basic two physical machine WebLogic cluster setup and configuration. Following the seven-step-process outlined on part one of this post, we first installed WebLogic on both machines (step 1), we created and initially configured the domain on one of the machines (steps 2 and 3), we copied the domain to the other machine (step 4), we verified that both machines are accessible by the domain (step 5), we created the WebLogic cluster (step 6) and finally verified that the cluster is operational (step 7).

Until then keep on JDeveloping!

Related Posts Plugin for WordPress, Blogger...