星期二, 12月 19, 2017

如何使用WAS下的scriptLibraries來簡化wsadmin操作

WAS下的scriptLibraries下有一些IBM提供給管理者簡化wsadmin 命令的Library (提供額外的命令來包裝原先複雜的wsadmin 命令), 讓管理可以方便使用。

其使用方法如下﹕(以設定WebContainer thread Pool 為例)

(1)./wsadmin.sh -lang jython -username admin_id -password admin_password

(2)進入wsadmin介面後, 使用execfile來載入擴充的Libraries。
wsadmin>execfile('<WAS-install-root>/scriptLibraries/servers/V70/AdminServerManagement.py')

(3)之後便能使用擴充的指令(至於有哪些指令, 可以自行參考那個.py 檔案的內容說明)
以AdminServerManagement.py 來說其設定Thread Pool的擴充指令為:configureThreadPool
=========================
  Ex40: configureThreadPool
# Example 40: Configure thread pool
def configureThreadPool(nodeName, serverName, parentType, tpName, maxSize, minSize, inactivityTimeout, otherAttrList=[], failonerror=AdminUtilities._BLANK_):
try:
        #--------------------------------------------------------------------
        # Configuring ThreadPool
        #--------------------------------------------------------------------
        print "---------------------------------------------------------------"
        print " AdminServerManagement:  Configuring ThreadPool"
        print " nodeName:               "+nodeName
        print " serverName:             "+serverName
        print " parentType:             "+parentType
        print " threadPoolName:         "+tpName
        print " maximumSize:            %s" % (maxSize)
        print " minimumSize:            %s" % (minSize)
        print " inactivityTimeout:      %s" % (inactivityTimeout)
===========================

(4)依上面說明, 其正確指令可寫成:
wsadmin>
configureThreadPool("loveNode02","base03","ThreadPoolManager","WebContainer","200","100","60000")

(5)其輸出結果如下﹕

---------------------------------------------------------------
 AdminServerManagement:  Configuring ThreadPool
 nodeName:               loveNode02
 serverName:             base03
 parentType:             ThreadPoolManager
 threadPoolName:         WebContainer
 maximumSize:            200
 minimumSize:            100
 inactivityTimeout:      60000
 Optional Attributes:
     otherAttributeList  []
 Usage: AdminServerManagement.configureThreadPool("loveNode02", "base03", "ThreadPoolManager", "WebContainer", "'200'", "'100'", "'60000'")
 Return: If the command is successful, a value of 1 is returned.
---------------------------------------------------------------


[customProperties []]
[inactivityTimeout 60000]
[isGrowable false]
[maximumSize 200]
[minimumSize 100]
[name WebContainer]
1

(6)若要把這二個步驟合成一個, 就自行寫個abc.py, 其內容如下﹕

execfile('<WAS-install-root>/scriptLibraries/servers/V70/AdminServerManagement.py')
configureThreadPool("loveNode02","base03","ThreadPoolManager","WebContainer","200","100","60000")

(7)最後要執行時就只要去指定abc.py 即可:
./wsadmin.sh -f abc.py












沒有留言: