X
  • Sun
    October 19, 2015

WLST Support for Dynamic Clustering

Credits - Developed by:


Rehana Tabassum

Byron Nevins


The Value of WebLogic Dynamic Clustering



Dynamic Clusters


Today we would like to talk about a cool new feature that we added to WebLogic.You will definitely want to know all about it if you are interested in working with Dynamic Clusters but without the hassle.

Sometimes you would like to have multiple managed servers in a cluster. All of these servers can have identical configurations – other than, say, the specific host machines, port numbers and so on.It’s time-consuming to do the dull and error-prone work of adding configuration manually for identical servers.
In WebLogic 12.1.2 Dynamic Cluster capability was added to address these concerns. Dynamic Clusters allow you to specify any number of servers in a cluster with the minimum amount of individual configuration.It also added support to add servers (expand the cluster/scaleUp) and remove servers (shrink the cluster/scaleDown). This can be done in the Admin Console GUI. Servers in the Dynamic Cluster can be started and stopped just like regular servers.

Elasticity Service

A great new feature available in WebLogic 12.2.1 is the Elasticity Service.ADD LINK HERE
The Elasticity Service leverages the Dynamic Cluster Technology by expanding and shrinking the Dynamic Clusters. And it does it completely automatically based on usage or many other criteria you can choose from.

WLST Support


What we are introducing is the ability to use WLST to easily expand and shrink dynamic clusters and to start and stop servers quickly.

A Use Case

You have a Corporate App for Taxes that results in a large increase in traffic between March 31 and April 30. The rest of the year it is active but only 20% as active.

Let’s say you have a Dynamic Cluster, taxCluster, that you’ve setup for 2 managed servers. Which works fine for 11 months of the year. On March 31 you want to scaleUp the cluster to 10 servers.

  • Startup WLST and connect (see References for details)
  • Run the scaleUp command to increase from 2 to 10 servers in the dynamic cluster:
  • scaleUp(‘taxCluster’, 8, true) See Examples

The result is that the cluster is permanently scaled upfrom 2 to 10 servers. The 8 new servers are all automatically started.
On May 1 you restore the cluster to 2 servers

  • Startup WLST and connect (see References for details)
  • Run the scaleDown command to decrease from 10 to 2 servers in the dynamic cluster:
  • scaleDown(‘taxCluster’, 8, true) See Examples

New Functionality

New commands have been added to WLST that have made all of these actions easy to perform:

  • Start Servers in the Cluster
    • Start 1 or more or even all servers that are not running currently
    • Create new server(s) and start them
  • Stop Servers in the Cluster Gracefully
    • Shutdown a given number of servers
    • Shutdown a given number of servers and also permanently remove them -- i.e. shrink the cluster

WLST Commands


To do these actions two new commands were added to WLST.

note: arguments inside square brackets are optional. Defaults are noted

scaleUp (clusterName, numServers, [updateConfiguration=false], [block=true], [timeoutSeconds=600], [type='DynamicCluster'])

clusterNameName of the dynamic cluster
numServersNumber of servers to start
updateConfigurationBoolean value specifying whether WLST should increase the maximum size of the cluster if there are not enough non-running servers already configured.
blockBoolean value specifying whether WLST should block user interaction until the servers finish starting.
timeoutSecondsTime (in seconds) that WLST waits for the server(s) to start before canceling the operation
typeIf specified, the argument value must be DynamicCluster This is for future enhancements.

scaleDown(clusterName, numServers, [updateConfiguration=false], [block=true], [timeoutSeconds=300], [type='DynamicCluster'])



clusterNameName of the dynamic cluster
numServersNumber of servers to shutdown
updateConfigurationBoolean value specifying whether WLST should both stop the give number of servers and decrease the maximum size of the cluster
blockBoolean value specifying whether WLST should block user interaction until the server(s) complete shutdown
timeoutSecondsTime that WLST waits for the server(s) to shutdown before canceling the operation
typeIf specified, the argument value must be DynamicCluster. This is for future enhancements.

Examples


Below are example code snippets on how to perform scaling actions by invoking the scaleUp and scaleDown commands.
Since they are online commands you must first connect to the administration
server (see References for instructions).

Start One Existing Server

wls:/...>scaleUp('mydyncluster', 1)

Remote ScaleUp started successfully after 25 seconds.
Waiting for 1 servers to reach the running state. The timeout is 600 seconds.

All servers are now running.

Even if all the servers under the dynamic cluster are already running, you can add one or more new server(s) to the cluster and automatically start them. Thus you can expand the size of the cluster dynamically if needed. To do so you need to specify the value of updateConfiguration as true in the scaleUp command.
Important: The cluster will be expanded only if needed. In the following example if there are 2 servers configured that are not running, they will be started and the configuration won't change. On the other hand if all servers in the cluster are already running then 2 servers will be added permanently to the cluster.

Scaleup and Start 2 New Servers

wls:/...>scaleUp('mydyncluster', 2, true)

Remote ScaleUp started successfully after 25 seconds.
Waiting for 2 servers to reach the running state. The timeout is 600 seconds.

All servers are now running.

The following example shows that the scaleUp command fails when there are not enough non-running servers allocated in the configuration and the updateConfiguration attribute is set to false. In this example the scaleUp command is asking to start 2 servers, but only 1 non-running server is available in the configuration.

Not Enough Servers Available

wls:/...>state('mydyncluster')

There are 2 server(s) in cluster: mydyncluster

States of the servers are

mydyncluster-1---RUNNING

mydyncluster-2---SHUTDOWN
wls:/... > scaleUp('mydyncluster', 2)

... (stack trace removed for clarity)

WLSTException: Error occurred while performing scaleUp : There are not enough shutdown servers available in the cluster (1) to scaleUp by 2 -- rerun the command with the updateConfiguration flag set to true.

The command will succeed when updateConfiguration is set to true. The config will be expanded by the number of servers needed. In this example 1 server is added.

Expand By 1 Server

wls:/...>state('mydyncluster')

There are 2 server(s) in cluster: mydyncluster

States of the servers are

mydyncluster-1---RUNNING

mydyncluster-2---SHUTDOWN
wls:/... > scaleUp('mydyncluster', 2, true)

Remote ScaleUp started successfully after 39 seconds.Waiting for 2 servers to reach the running state. The timeout is 300 seconds.
All servers are now running.
wls:/> state('mydyncluster')

There are 3 server(s) in cluster: mydyncluster

States of the servers are

mydyncluster-1---RUNNING

mydyncluster-2---RUNNING

mydyncluster-3---RUNNING

To gracefully shutdown n servers, you can invoke the scaleDown command.
If updateConfiguration is set to false (the default), the configuration will not be changed. In that case a scaleDown command will simply shutdown servers. In this example 2 servers are shutdown gracefully.

Shutdown 2 Servers

wls:/...>state('mydyncluster')

There are 5 server(s) in cluster: mydyncluster

States of the servers are

mydyncluster-1---RUNNING

mydyncluster-3---RUNNING

mydyncluster-2---RUNNING

mydyncluster-5---RUNNING

mydyncluster-4---RUNNING
wls:/... > scaleDown('mydyncluster', 2)
Remote ScaleDown started successfully after 2 seconds.

The servers were stopped successfully.
wls:/... > state('mydyncluster')

There are 5 server(s) in cluster: mydyncluster

States of the servers are

mydyncluster-1---RUNNING

mydyncluster-3---RUNNING

mydyncluster-2---RUNNING

mydyncluster-5---SHUTDOWN

mydyncluster-4---SHUTDOWN

If you wanted to shrink the cluster in additrion to stopping 2 servers, you can make the same call except this time set updateConfiguration to true. This will shutdown the servers and remove them from the configuration. I.e. this will shrink the cluster.
Notice that 2 servers are gracefully shutdown and removed from the dynamic cluster configuration.

Shutdown 2 Servers and Shrink Cluster

wls:/...>state('mydyncluster')

There are 5 server(s) in cluster: mydyncluster

States of the servers are

mydyncluster-1---RUNNING

mydyncluster-3---RUNNING

mydyncluster-2---RUNNING

mydyncluster-5---RUNNING

mydyncluster-4---RUNNING
wls:/... > scaleDown('mydyncluster', 2)
Remote ScaleDown started successfully after 2 seconds.

The servers were stopped successfully.
wls:/... > state('mydyncluster')

There are 5 server(s) in cluster: mydyncluster

States of the servers are

mydyncluster-1---RUNNING

mydyncluster-3---RUNNING

mydyncluster-2---RUNNING

References

Start an interactive WLST session

wlst.sh

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

wls:/offline>

Connnect to an administration server using WLST

wls:/offline> connect('weblogic','welcome1234','t3://localhost:7001')
Connecting to t3://localhost:7001 with userid weblogic ...

Successfully connected to Admin Server "admin" that belongs to domain "dynClusterScalingDomain".

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.