Search This Blog

Sunday, February 26, 2023

Dynamic Cluster Scaling with WLST

Dynamic Cluster configuration on WebLogic Domain

Prerequisites


In this exciting example 😊 new learning about how to use the dynamic cluster in the latest version of WebLogic 12c [12.1.2] and above this was introduced for WebLogic on Cloud computing. To workout this you must configure a Server template when you give the maximum number of cluster servers these managed server automatically increased. When you decrease it the number of managed servers come to SHUTDOWN state as expected. To do same task from the automation using WLST prompt you need to use the following two functions:
  1. scaleUp increase the number of managed servers in the cluster
  2. scaleDown to decrease the number of managed servers in the cluster.


Elastic scaling in Dynamic cluster in WebLogic 12c
Dynamic Cluster configuration on WebLogic Domain


now let's do the automation exercise
# Dated  : 4th Feb 2016
# ScriptName : dynamicCluster.py
# Purpose :
# This script will create server template and using that
# configures a dyanamic cluster

def createServer_Template(tmpName, basePort, sslPort, machine):
        print 'creating server tempalte for '+tmpName
        cd('/')
        cmo.createServerTemplate(''+tmpName)

        cd('/ServerTemplates/'+tmpName)
        cmo.setListenPort(int(basePort))

        cd('/ServerTemplates/'+tmpName+'/SSL/'+tmpName)
        cmo.setListenPort(int(sslPort))

        cd('/ServerTemplates/'+tmpName)
        cmo.setMachine(None)


def create_dynamicCluster(clustrName, tmpName, prefix):
        print 'Creating dynamic cluster: '+clustrName
        cd('/')
        cmo.createCluster(clustrName)

        cd('/Clusters/'+clustrName)
        cmo.setClusterMessagingMode('unicast')

        cd('/ServerTemplates/'+tmpName)
        cmo.setCluster(getMBean('/Clusters/'+clustrName))

        cd('/Clusters/'+clustrName+'/DynamicServers/'+clustrName)
        cmo.setServerTemplate(getMBean('/ServerTemplates/'+tmpName))
        cmo.setDynamicClusterSize(2)
        cmo.setMaxDynamicClusterSize(8)
        cmo.setCalculatedListenPorts(true)
        cmo.setCalculatedMachineNames(true)
        cmo.setCalculatedListenPorts(true)
        cmo.setServerNamePrefix(prefix)

def main():
        connect("weblogic","welcome1","t3://192.168.33.100:6100")
        edit()
        startEdit()

        print 'Creating server templates...'
        # creating server templates
        createServer_Template('app_tier_tmp', 7120, 8120, 'mydev')
        createServer_Template('web_tier_tmp', 6120, 9120, 'mydev') # Machine already configured

        create_dynamicCluster('app_dclustr', 'app_tier_tmp','app_server0')
        create_dynamicCluster('web_dclustr', 'web_tier_tmp','web_server0')
        print 'Dynamic cluster configuration completed...'
        activate()

main()

The above generic WLST script can be executed as shown below:

Elastic cluster configuration with WLST


You could also double confirm this from your WebLogic Admin Console work-area when you select clustser in the Environment of under your Domain .

wlst output confirm Admin console
Dynamic Cluster configuration in WebLogic 12.2.1 Domain


Suggestion for future enhancements to the above script you can do following:

  1. create a properties file and pass all the main program required arguments
  2. Cluster Message Mode can be dynamic
  3. Machine per template can be set dynamic
Elastic Cluster on-demand scale up

In the WLST prompt you can test it as :

scaleUp ("app_dclustr",1, true, true)

scaleUp execution for single server:

WLST Scalability implementation
ScaleUp in WLST Execution 

scaleDown('app_dclustr',2,true,true)

Scale down weblogic cluster

scale down in WebLogic 12.2.1 Domain
Scale Down cluster size in WLST

Hope you enjoyed this post,  Stay tune to this blog post and share with your friends techies...
Waiting for your comments and suggestions!!

2 comments:

  1. The syntax's for scaleUp and scaleDOWN are helps me.Thank you for valuable post.
    Regards,
    Weblogic Training.

    ReplyDelete
  2. QUANTUM BINARY SIGNALS

    Professional trading signals sent to your cell phone daily.

    Start following our trades today & make up to 270% per day.

    ReplyDelete

Please write your comment here

Popular Posts