Personally I get shivers down my spine, when I have to start a server process with nohup and pipe the output to a separate log, I refer to the startWeblogic.sh / bat script supplied by Oracle on a Weblogic installation. By a lot of weblogic implementation by Oracle you still have to start weblogic this way, OBIEE 11g for example. Well Weblogic has something nice, called WLST or WebLogic Scripting Tool. This is a Jython based interface to your Weblogic environment. Jython is en scripting language based on Python, but specially for Java.
For starting an OBIEE 11g (Oracle Business Intelligence Enterprise Edition) environment I wrote the following script, to boot the weblogic parts of OBI. This can by used on every platform.
StartServers.py example:
import os
if os.environ.has_key('wlsAdminServer'):
wlsAdminServer = os.environ['wlsAdminServer']
if os.environ.has_key('nmUserID'):
nmUserID = os.environ['nmUserID']
if os.environ.has_key('wlsUserID'):
wlsUserID = os.environ['wlsUserID']
if os.environ.has_key('wlsPassword'):
wlsPassword = os.environ['wlsPassword']
if os.environ.has_key('wlsAdminURL'):
wlsAdminURL = os.environ['wlsAdminURL']
if os.environ.has_key('wlsNodeManagerHome'):
wlsNodeManagerHome = os.environ['wlsNodeManagerHome']
if os.environ.has_key('nmPort'):
nmPort = os.environ['nmPort']
if os.environ.has_key('wlsHost'):
wlsHost = os.environ['wlsHost']
if os.environ.has_key('wlsDomainName'):
wlsDomainName = os.environ['wlsDomainName']
if os.environ.has_key('wlsDomainLocation'):
wlsDomainLocation = os.environ['wlsDomainLocation']
print '-- START NODE MANAGER --';
startNodeManager(verbose='true', NodeManagerHome=wlsNodeManagerHome, ListenPort=nmPort, ListenAddress=wlsHost)
print '-- CONNECT TO NODE MANAGER --';
nmConnect(nmUserID, wlsPassword, wlsHost, nmPort, wlsDomainName, wlsDomainLocation, 'ssl')
print '-- START ADMIN SERVER --';
nmStart(wlsAdminServer)
connect(wlsUserID, wlsPassword, url=wlsAdminURL, adminServerName=wlsAdminServer)
domainRuntime()
serverLifeCycles = cmo.getServerLifeCycleRuntimes()
for serverLifeCycle in serverLifeCycles:
if (serverLifeCycle.getState() != 'RUNNING'):
print 'Starting Server: ' + serverLifeCycle.getName()
start(serverLifeCycle.getName(), 'Server')
exit()
I first import some OS variables which I set with an other script, for example I have a bi_env script.
bi_env:
export wlsAdminServer="AdminServer"
export nmUserID="nodemanager"
export wlsUserID="weblogic"
export wlsPassword="
"
export wlsHost=`hostname`
export nmPort="9556"
export asPort="7001"
export wlsAdminURL="t3://${wlsHost}:${asPort}"
export wlsDomainName="bifoundation_domain"
export wlsMiddleWareHome="/u00/oracle/product/11.1.1"
export wlsDomainLocation="${wlsMiddleWareHome}/user_projects/domains/bifoundation_domain"
export wlsNodeManagerHome="${wlsMiddleWareHome}/wlserver_10.3/common/nodemanager"
What you do next is simple, on Linux, but Windows as well, set the environment variables and run the start script. WLST will start all the WLS process in the background as it should be, with the logging in the right place. For example:
. /wlserver_10.3/server/bin/setWLSEnv.sh
. ~/bi_env
java weblogic.WLST StartServers.py
You can also use WLST to stop the processes and check the status, to initiate scripts you can use the above code sample.
StopServers.py:
import os
if os.environ.has_key('wlsAdminServer'):
wlsAdminServer = os.environ['wlsAdminServer']
if os.environ.has_key('nmUserID'):
nmUserID = os.environ['nmUserID']
if os.environ.has_key('wlsUserID'):
wlsUserID = os.environ['wlsUserID']
if os.environ.has_key('wlsPassword'):
wlsPassword = os.environ['wlsPassword']
if os.environ.has_key('wlsAdminURL'):
wlsAdminURL = os.environ['wlsAdminURL']
if os.environ.has_key('wlsNodeManagerHome'):
wlsNodeManagerHome = os.environ['wlsNodeManagerHome']
if os.environ.has_key('nmPort'):
nmPort = os.environ['nmPort']
if os.environ.has_key('wlsHost'):
wlsHost = os.environ['wlsHost']
if os.environ.has_key('wlsDomainName'):
wlsDomainName = os.environ['wlsDomainName']
if os.environ.has_key('wlsDomainLocation'):
wlsDomainLocation = os.environ['wlsDomainLocation']
print '-- CONNECT TO NODE MANAGER AND ADMINSERVER --';
nmConnect(nmUserID, wlsPassword, wlsHost, nmPort, wlsDomainName, wlsDomainLocation, 'ssl')
connect(wlsUserID, wlsPassword, url=wlsAdminURL, adminServerName='AdminServer')
domainRuntime()
serverLifeCycles = cmo.getServerLifeCycleRuntimes()
for serverLifeCycle in serverLifeCycles:
if (serverLifeCycle.getState() == 'RUNNING') and (serverLifeCycle.getName() != wlsAdminServer ):
print 'Stopping Server: ' + serverLifeCycle.getName()
nmKill(serverLifeCycle.getName())
print '-- STOPPING NODE MANAGER --'
stopNodeManager()
exit()
StatusServers.py:
import os
if os.environ.has_key('wlsAdminServer'):
wlsAdminServer = os.environ['wlsAdminServer']
if os.environ.has_key('nmUserID'):
nmUserID = os.environ['nmUserID']
if os.environ.has_key('wlsUserID'):
wlsUserID = os.environ['wlsUserID']
if os.environ.has_key('wlsPassword'):
wlsPassword = os.environ['wlsPassword']
if os.environ.has_key('wlsAdminURL'):
wlsAdminURL = os.environ['wlsAdminURL']
if os.environ.has_key('wlsNodeManagerHome'):
wlsNodeManagerHome = os.environ['wlsNodeManagerHome']
if os.environ.has_key('nmPort'):
nmPort = os.environ['nmPort']
if os.environ.has_key('wlsHost'):
wlsHost = os.environ['wlsHost']
if os.environ.has_key('wlsDomainName'):
wlsDomainName = os.environ['wlsDomainName']
if os.environ.has_key('wlsDomainLocation'):
wlsDomainLocation = os.environ['wlsDomainLocation']
nmConnect(nmUserID, wlsPassword, wlsHost, nmPort, wlsDomainName, wlsDomainLocation, 'ssl')
connect(wlsUserID, wlsPassword, url=wlsAdminURL, adminServerName='AdminServer')
domainRuntime()
serverLifeCycles = cmo.getServerLifeCycleRuntimes();
for serverLifeCycle in serverLifeCycles:
print 'Server: ' + serverLifeCycle.getName() + ', State: ' + serverLifeCycle.getState();
if (serverLifeCycle.getState() == 'RUNNING'):
cd('ServerRuntimes/' + serverLifeCycle.getName());
jvm = cmo.getJVMRuntime();
print 'Java VM Vendor: ' + jvm.getJavaVMVendor();
print 'Heap Free Space: ' + repr(jvm.getHeapFreePercent()) + '%';
print 'Heap Size Current: ' + repr(jvm.getHeapSizeCurrent());
print 'Maximum Heap Size: ' + repr(jvm.getHeapSizeMax());
cd('/');
exit()
One thing you must not forget, is to make a boot.properties file in /user_projects/domains/bifoundation_domain/servers/AdminServer/security. This file contains the credentials to boot the AdminServer and makes sure the WLST doesn’t come with the following error message:
Error Starting server AdminServer: weblogic.nodemanager.NMException: Exception while starting server 'AdminServer'
wls:/nm/bifoundation_domain> NMProcess:
NMProcess: java.io.IOException: Server failed to start up. See server output log for more details.
NMProcess: at weblogic.nodemanager.server.ServerManager.start(ServerManager.java:331)
NMProcess: at weblogic.nodemanager.server.Handler.handleStart(Handler.java:567)
NMProcess: at weblogic.nodemanager.server.Handler.handleCommand(Handler.java:116)
NMProcess: at weblogic.nodemanager.server.Handler.run(Handler.java:70)
NMProcess: at java.lang.Thread.run(Thread.java:619)
NMProcess:
NMProcess: Feb 10, 2011 4:56:27 PM weblogic.nodemanager.server.Handler handleStart
NMProcess: WARNING: Exception while starting server 'AdminServer'
NMProcess: java.io.IOException: Server failed to start up. See server output log for more details.
NMProcess: at weblogic.nodemanager.server.ServerManager.start(ServerManager.java:331)
NMProcess: at weblogic.nodemanager.server.Handler.handleStart(Handler.java:567)
NMProcess: at weblogic.nodemanager.server.Handler.handleCommand(Handler.java:116)
NMProcess: at weblogic.nodemanager.server.Handler.run(Handler.java:70)
NMProcess: at java.lang.Thread.run(Thread.java:619)
You boot.properties should look something like:
#Thu Feb 10 17:10:34 CET 2011
password=password
username=weblogic
This file will be encrypted on first use.