How To Increase Heap Size In Websphere Cluster

IBM WebSphere Application Server

Sometimes we need to increase or decrease the memory in all instances in WebSphere a Cluster, but it is hard to do it instance per instance. Here int his article we will discuss how to increase heap size in websphere cluster environments.

Below Script can be used to modify Heap Memory in a WebSphere Cluster. Please follow below steps to complete the heap memory update.

  1. create a file named modifyHeapsPerCluster.py and add the lines bellow.

 

def showClusters():
clusters=AdminConfig.list('ServerCluster').split(java.lang.System.getProperty("line.separator"))
print "[INFO] Listing all Clusters . . ."
for clr in clusters:
cluster = clr.split('(')
print " " * 15 + "Cluster Name = " + cluster[0]

def showNodes():
cells = AdminConfig.list('Cell').split()
for cell in cells:
nodes = AdminConfig.list('Node', cell).split()
lista = ['1','2','3','4','5','6']
listaNodos = []
global listaNodos
num = 0
for node in nodes:
nombreNodo = AdminConfig.showAttribute(node, 'name')
print " " * 15 + nombreNodo + " (" + lista[num] + ")"
listaNodos.append(nombreNodo )
num = num + 1

def showClusterMems(clsName):
print "[INFO] Show Cluster Members: " + clsName
cluster = AdminConfig.getid("/ServerCluster:" +clsName+"/")
clusterName = AdminConfig.showAttribute(cluster, "name")
members = AdminConfig.showAttribute(cluster, "members")
members = AdminUtilities.convertToList(members)
global listMemembers
global listNodeMembers
listMemembers = []
listNodeMembers = []
if len(members) > 0:
AdminUtilities.infoNotice("cluster " + clusterName + " has %s members" % (len(members)))
for member in members:
mname = AdminConfig.showAttribute(member, "memberName")
nname = AdminConfig.showAttribute(member, "nodeName")
AdminUtilities.infoNotice("Cluster member: " + mname + " " + nname)
listMemembers.append(mname)
listNodeMembers.append(nname)

def modifyHeapsPerCluster():
showClusters()
clusterName = raw_input("Introduce the name of the clulster: ")
showClusterMems(clusterName)
showNodes()
nodeName = raw_input("Introduce the name of the node's Cluster: ")
if ( nodeName == "1" ):
nodeName = listaNodos[0]
else:
nodeName = listaNodos[1]

cluster = AdminConfig.getid("/ServerCluster:" +clusterName+"/")
clrtName = AdminConfig.showAttribute(cluster, "name")
members = AdminConfig.showAttribute(cluster, "members")
members = AdminUtilities.convertToList(members)
HeapMin = raw_input("\t Introduce the Heap Min: []: ")
HeapMax = raw_input("\t Introduce the Heap Max: []: ")
if len(members) > 0:
miembros = len(members)
for member in members:
mname = AdminConfig.showAttribute(member, "memberName")
print "[INFO] Changing configuration of instance: " + mname
serverJVM=AdminConfig.getid('/Node:'+nodeName+'/Server:'+mname+'/')
jvm = AdminConfig.list('JavaVirtualMachine', serverJVM)
AdminConfig.modify(jvm, [['maximumHeapSize', HeapMax]])
AdminConfig.modify(jvm, [['initialHeapSize', HeapMin]])
AdminConfig.save()

modifyHeapsPerCluster()

How to run the script:

execute: {WAS_DMGR_Profile}/bin/wsadmin.sh -lang jython -f modifyHeapsPerCluster.py

Introduce the console Username and Password.

Sample Execution Output:

/WebSphere85/AppServer/profiles/Dmgr01/bin # ./wsadmin.sh -lang jython -f modifyHEapsPerCluster.py -username wasadmin -password *********

WASX7209I: Connected to process "dmgr" on node lcwacmbanxmx02NodeManager01 using SOAP connector; The type of process is: DeploymentManager

[INFO] Listing all Clusters . . .
Cluster Name = Cluster_sire
Cluster Name = Cluster_webfocus82
Introduce the name of the clulster: Cluster_sire
[INFO] Show Cluster Members: Cluster_sire
Cluster Cluster_sire has 2 members
Cluster member: sire lcwacmbanxmx02Node01
Cluster member: sire_cl2 lcwacmbanxmx02Node01
lcwacmbanxmx02Node01 (1)
lcwacmbanxmx02NodeManager01 (2)
Introduce the name of the node's Cluster: 1
Introduce the Heap Min: []: 256
Introduce the Heap Max: []: 512
Changing configuration of instance: sire
Changing configuration of instance: sire_cl2
Change Complete

NOTE: This script can be used in WAS6.1, WAS 7, WAS 8, WAS 8.5, WAS 8.5.5.

Any doubt please contact:  takoda16(at)gmail.com

GUEST AUTHOR: Jonathan

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

3 Responses

  1. Mack says:

    thank you. All went well.

  2. Ashok says:

    Hi Jonathan,

    Thank you for your knowledge and skills.
    The script that you provided worked like a charm.

  3. Jonathan Alvarez says:

    Are you interesting in more scripts? contact me [email protected]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.