Friday, March 12, 2010

Quick hit JVM heap size change

I was tasked to change the JVM heap size in approximately 2,500 servers today. I created a quick little script that I will share for you.

#
# Update the Heap size
# Mike Huffsteder 5/5/2008
#
# ./wsadmin.sh -lang jython -f updateJVM.py
#

as = AdminConfig.getid('/Cell:YOUR_CELL_NAME/Node:YOUR_NODE_NAME/Server:YOUR_SERVER_NAME/')
jvm = AdminConfig.list('JavaVirtualMachine', as)
AdminConfig.modify(jvm, [['initialHeapSize', '512'], ['maximumHeapSize', "768"]])
AdminConfig.save()
# set the newly saved config to variables to place entries in logging
i = AdminConfig.showAttribute(jvm, "initialHeapSize")
m = AdminConfig.showAttribute(jvm, "maximumHeapSize")
print "The initial heap size is now" + i
print "The max heap size is now" + m

Of course, you can change the heap to whatever size you would like.

No comments:

Post a Comment