C2B2 logo icon

Weblogic - Dynamic Clustering in practice


The latest version of Weblogic (12.1.2) includes support for Dynamic Clustering.



For more details on what else is new in 12.1.2 see my previous blog post:

In this blog post I will look at setting up a dynamic cluster on 2 machines with 4 managed servers (2 on each). I will then deploy an application to the cluster and show how to expand the cluster.

What is a dynamic cluster?

A dynamic cluster is any cluster that contains one or more dynamic servers. Each server in the cluster will be based upon a single shared server template. The server template allows you to configure each server the same and ensures that servers do not need to be manually configured before being added to the cluster. This allows you to easily scale up or down the number of servers in your cluster without the need for setting up each server manually. Changes made to the server template are rolled out to all servers that use that template.
When configuring your cluster you specify the maximum number of servers you expect to need at peak times. The specified number of server instances is then created, each based upon your server template. You can then start up however many you need and scale up or down over time according to your needs.


2 machines - I created 2 Ubuntu 12 VMs with 2 dual core processors and 4GB memory - somewhat overkill but I like power!  :o)
Weblogic 12.1.2 - wls_121200.jar - Available from Oracle
JDK - I used jdk-7u5-linux-x64.tar.gz - Available from Oracle



I installed Weblogic and Java on both machines and made sure the JAVA_HOME environment variable was set.

Where I use ORACLE_HOME below please replace this with wherever you installed Weblogic.


Creating the domains



First of all create a Basic Weblogic Server Domain called test_domain on Machine 1 using the config.sh script that can be found in ORACLE_HOME/wlserver/common/bin/ with the following settings:



Domain Mode - Development


JDK - The one previously installed
Node Manager Type - Per domain


Once this domain has been created we need to copy it to Machine 2. The easiest way to do this is to use the pack and unpack scripts found in the same directory as the config.sh script above.



Here is the pack command:



pack.sh -domain=ORACLE_HOME/user_projects/domains/test_domain -template=test_domain.jar -managed=true -template_name="test_domain_template"



This will create a jar file. Copy this file onto Machine 2.



Here is the unpack command:



unpack.sh -template=PATH_TO_JAR_FILE/test_domain.jar -domain=ORACLE_HOME/user_projects/domains/test_domain




Creating the dynamic cluster




Machine 1



Start Weblogic:



cd ORACLE_HOME/user_projects/domains/test_domain
Open the console:
Create 2 machines, Machine-1 and Machine-2 using your machine details. Node manager - PLAIN.
Create a new dynamic cluster:
Name - DynamicCluster
Number of servers - 4
Server Name Prefix - Server-
Create a new server template using domain defaults
Use any machine configured in this domain.
Assign each dynamic server unique listen ports



This will create 4 managed servers, 2 on each machine.



Edit the node manager properties file:





Set the following properties:
ListenAddress=IP address of Machine 1


Start the node manager:



cd ORACLE_HOME/user_projects/domains/test_domain/bin



Machine 2



First of all we will use WLST to enrol the machine with the admin server. This command creates a property file nodemanager.domains, which maps domain names to home directories, and creates the required domain configuration and security information so that the Managed Servers can communicate with the Administration Server.



To run WLST:



cd ORACLE_HOME/wlserver/common/bin



Run the following command and then enter the username and password for the admin server:






The server URL will be:






Then run the nmenroll command:






And finally exit wlst:






Edit the node manager properties file:

Set the following properties:
ListenAddress=IP address of Machine 2



Now run the node manager:



cd ORACLE_HOME/user_projects/domains/test_domain/bin



Testing the setup



You should now be able to start and stop all 4 servers from the admin console.



Deploying an application



For testing we will download a simple app used for testing clustering. This app is available here:





From the admin console go to Deployments. Click on install.



Point the path to the downloaded file. Click next.



Select 'Install this deployment as an application'. Click next



Target the deployment to DynamicCluster. All servers in the cluster. Click next.



Select 'Copy this application onto every target for me' and click finish.



The application should now be available at the following addresses:



Obviously in the real world you would set up a load balancer to balance between the 4 servers rather than pointing at each individual one but that is outside the scope of this post. If you are interested in how to do so my colleague has written a blog on just such a thing:






Adding additional servers




Now we have our dynamic cluster set up we can easily add additional servers:



Go to Environment - Clusters - DynamicCluster - Servers



Change the Maximum Number of Servers value and click Save.



The cluster will be altered to contain the new number of servers split between the two machines.





With the advent of cloud computing the ability to scale up or down according to your application needs is vital. Dynamic Clustering is a welcome addition to Weblogic and is very straightforward to configure. 


Whilst this demonstration showed how to alter the cluster at runtime using the console in reality we would look at automating resizing the cluster and starting/stopping servers. We would also load balance between the individual servers. This is something we may cover in a future blog. Watch this space....