Ravish Mody

Today, Chris Giddings one of our subscriber asked us by commenting if we have any automated script which can start the Admin Server as they have this type of requirement and the script should not take much load too on there system. So seeing the requirement we took out sometime and wrote a WLST script which can do that job for Chris and hope that this script would also help our other subscribers too.

The logic behind this WLST script is that first this script would start the NodeMnager, then the script would connect to NodeMnager and then it would also start the Admin Server. So in short this script would do three things in no time without much load and just by changing few things in the property file called domains.properties as per your environment which has all the details about the domains and the server which has to started.

Note:

- Make sure you associate a Machine for the Admin Server
- Make sure you keep both this files (i.e. domains.properties and Start_Admin.py) in the same folder when you are running the script or else you would have to give the path.
- Also this script would create nm_data.properties, nodemanager.log and nodemanager.properties if they are not present in the directory from where you are running the script.
- This script does not use SSL, so you would have to first start the adminserver using startWebLogic.sh first, then go to the Admin Console path

Environment –> Machines –> [YOUR_MACHINE_NAME] –> Configuration [tab] –> Node Manager [sub-tab]

Type = Plain

- Following is the nodemanager.properties which we had used you can notice that SecureListener=false as we not using SSL and StartScriptEnabled=true because we had got OutOfMemory: PermGen error so by doing this the memory parameters would be picked up by startWebLogic.sh

#Fri Apr 29 20:12:43 IST 2011
DomainsFile=/WLS/Start_Admin/nodemanager.domains
LogLimit=0
PropertiesVersion=10.3
AuthenticationEnabled=true
NodeManagerHome=/WLS/Start_Admin
JavaHome=/Jdk/jdk1.6.0_21/jre
LogLevel=INFO
DomainsFileEnabled=true
StartScriptName=startWebLogic.sh
ListenAddress=localhost
NativeVersionEnabled=true
ListenPort=5556
LogToStderr=true
SecureListener=false
LogCount=1
StopScriptEnabled=false
QuitEnabled=true
LogAppend=true
StateCheckInterval=500
CrashRecoveryEnabled=false
StartScriptEnabled=true
LogFile=/WLS/Start_Admin/nodemanager.log
NodemanagerHome=/WLS103/wlserver_10.3/common/nodemanager
LogFormatter=weblogic.nodemanager.server.LogFormatter
ListenBacklog=50

Steps to Start AdminServer And NodeManager Using WLST

1. Below is the details which domains.properties would have

username=weblogic
password=weblogic
host=localhost
nm.port=5556
domain.name=Domain_7001
domain.dir=/WLS103/user_projects/domains/Domain_7001
nm.type=plain
server.name=AdminServer

2. And below is the WLST python script Start_Admin.py which would call the above properties.

#############################################################################
#
# @author Copyright (c) 2010 - 2011 by Middleware Magic, All Rights Reserved.
#
#############################################################################
from java.io import FileInputStream
import java.lang
import os
import string

propInputStream = FileInputStream("domain.properties")
configProps = Properties()
configProps.load(propInputStream)

Username = configProps.get("username")
Password = configProps.get("password")
Host = configProps.get("host")
nmPort = configProps.get("nm.port")
domainName = configProps.get("domain.name")
domainDir = configProps.get("domain.dir")
nmType = configProps.get("nm.type")

startNodeManager()
print ''
print '============================================='
print ' NODE MANAGER started Successfully...!!!'
print '============================================='
print ''
nmConnect(Username,Password,Host,nmPort,domainName,domainDir,nmType)
print ''
print '============================================='
print 'Connected to NODE MANAGER Successfully...!!!'
print '============================================='
print ''

serverName = configProps.get("server.name")
print '###### serverName = ', serverName
nmStart(serverName)
serverName = configProps.get("server.name")
print ''
print '============================================='
print '===> Successfully started ', serverName, '  <==='
print '============================================='
print ''

3 . Following would be the output as soon as you run the Start_Admin.py using the below command

Command:

java weblogic.WLST Start_Admin.py

Output:

D:\Oracle\Test App\Domain>java weblogic.WLST Start_Admin.py

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Launching NodeManager ...
 Properties: {}
 Command: /Jdk/jdk1.6.0_21/jre/bin/java -d64 -classpath /Jdk/jdk1.6.0_21/jre/lib/rt.jar:/Jdk/jdk1.6.0_21/jre/lib/i18n.jar:/WLS103/patch_wls1030/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/WLS103/patch_cie660/profiles/default/sys_manifest_classpath/weblogic_patch.jar:/Jdk/jdk1.6.0_21/lib/tools.jar:/WLS103/wlserver_10.3/server/lib/weblogic_sp.jar:/WLS103/wlserver_10.3/server/lib/weblogic.jar:/WLS103/modules/features/weblogic.server.modules_10.3.0.0.jar:/WLS103/wlserver_10.3/server/lib/webservices.jar:/WLS103/modules/org.apache.ant_1.6.5/lib/ant-all.jar:/WLS103/modules/net.sf.antcontrib_1.0.0.0_1-0b2/lib/ant-contrib.jar:/WLS103/wlserver_10.3/common/eval/pointbase/lib/pbclient57.jar:/WLS103/wlserver_10.3/server/lib/xqrl.jar weblogic.NodeManager -v
NMProcess: <Apr 29, 2011 8:32:53 PM> <INFO> <Loading domains file: /WLS/Start_Admin/nodemanager.domains>
NMProcess: <Apr 29, 2011 8:32:53 PM> <WARNING> <Domains file not found: /WLS/Start_Admin/nodemanager.domains>
NMProcess: <Apr 29, 2011 8:32:53 PM> <INFO> <Loaded node manager configuration properties from '/WLS/Start_Admin/nodemanager.properties'>
NMProcess: Node manager v10.3
NMProcess:
NMProcess: Configuration settings:
NMProcess:
NMProcess: NodeManagerHome=/WLS/Start_Admin
NMProcess: ListenAddress=localhost
NMProcess: ListenPort=5556
NMProcess: ListenBacklog=50
NMProcess: SecureListener=false
NMProcess: AuthenticationEnabled=true
NMProcess: NativeVersionEnabled=true
NMProcess: CrashRecoveryEnabled=false
NMProcess: JavaHome=/Jdk/jdk1.6.0_21/jre
NMProcess: StartScriptEnabled=true
NMProcess: StopScriptEnabled=false
NMProcess: StartScriptName=startWebLogic.sh
NMProcess: StopScriptName=
NMProcess: LogFile=/WLS/Start_Admin/nodemanager.log
NMProcess: LogLevel=INFO
NMProcess: LogLimit=0
NMProcess: LogCount=1
NMProcess: LogAppend=true
NMProcess: LogToStderr=true
NMProcess: LogFormatter=weblogic.nodemanager.server.LogFormatter
NMProcess: DomainsFile=/WLS/Start_Admin/nodemanager.domains
NMProcess: DomainsFileEnabled=true
NMProcess: StateCheckInterval=500
NMProcess: QuitEnabled=true
NMProcess:
NMProcess: Domain name mappings:
NMProcess:
NMProcess:
NMProcess: <Apr 29, 2011 8:32:54 PM> <INFO> <Plain socket listener started on port 5556, host localhost>
Successfully launched the Node Manager.
The Node Manager process is running independent of the WLST process.
Exiting WLST will not stop the Node Manager process. Please refer
to the Node Manager logs for more information.
The Node Manager logs will be under /WLS/Start_Admin/.

=============================================
 NODE MANAGER started Successfully...!!!
=============================================

Connecting to Node Manager ...
NMProcess: <Apr 29, 2011 8:33:03 PM> <Info> <Domain_7001> <MS-1> <Startup configuration properties loaded from "/WLS103/user_projects/domains/Domain_7001/servers/MS-1/data/nodemanager/startup.properties">
Successfully Connected to Node Manager.

=============================================
Connected to NODE MANAGER Successfully...!!!
=============================================

###### serverName =  AdminServer
Starting server AdminServer ...
NMProcess: <Apr 29, 2011 8:33:03 PM> <Info> <Domain_7001> <AdminServer> <Rotated server output log to "/WLS103/user_projects/domains/Domain_7001/servers/AdminServer/logs/AdminServer.out00007">
NMProcess: <Apr 29, 2011 8:33:03 PM> <Info> <Domain_7001> <AdminServer> <Server error log also redirected to server log>
NMProcess: <Apr 29, 2011 8:33:03 PM> <Info> <Domain_7001> <AdminServer> <Starting WebLogic server with command line: /WLS103/user_projects/domains/Domain_7001/bin/startWebLogic.sh >
NMProcess: <Apr 29, 2011 8:33:03 PM> <Info> <Domain_7001> <AdminServer> <Working directory is "/WLS103/user_projects/domains/Domain_7001">
NMProcess: <Apr 29, 2011 8:33:03 PM> <Info> <Domain_7001> <AdminServer> <Server output log file is "/WLS103/user_projects/domains/Domain_7001/servers/AdminServer/logs/AdminServer.out">
Successfully started server AdminServer ...

=============================================
===> Successfully started  AdminServer   <===
=============================================

.

.

Regards,
Ravish Mody

Start_Admin.py