Startup Scripts for WebLogic and SOA Suite

Yes I know there are many blogs and sites out there that have startup scripts for WebLogic. I have noticed that some are very detailed and maybe a bit complex for a newbe. Therefore goal of this post is to provide new administrators a basic startup script for WebLogic with an emphasis on SOA Suite. You should be able to use these scripts as a base to start building more complex scripts that accept parameters, or start clusters, etc.


  1. If you want Node Manager to restart a failed Managed server you must ensure that either the nodemanager.properties file or the startup.properties has the parameters AutoRestart=true and StartScriptEnabled=true. I believe this is set to true in the startup.properties by default. The nodemanager.properties file can be found in  $MW_HOME/wlserver_10.3/common/nodemanager
  2. I use 2 scripts to start WebLogic, a control shell script, which then calls a WLST script. For the purpose of this blog I have placed the scripts in the following directory.

    /home/oracle/scripts/weblogic/startup

  3. Create a scripts called startNM.sh in the directory your choice, e.g. /home/oracle/scripts/weblogic/startup
    here is a sample, adjust for your environment:

    MW_HOME=/u01/oracle/product/middleware

    $MW_HOME/oracle_common/common/bin/setNMProps.sh

    nohup $MW_HOME/wlserver_10.3/server/bin/startNodeManager.sh > $MW_HOME/wlserver_10.3/common/nodemanager/nodemanager.out &

    nohup $MW_HOME/user_projects/domains/soa_domain/bin/startWebLogic.sh > $MW_HOME/user_projects/domains/soa_domain/servers/AdminServer/logs/AdminServer.out &

    . $MW_HOME/user_projects/domains/soa_domain/bin/setDomainEnv.sh

    java weblogic.WLST /home/oracle/scripts/weblogic/startup/startMS.py

    Please note that each command is separated by a empty line, therefore the nohup commands are one command until the &

  4. Now create the WLST script as called by the startNM.sh script above. Call it startMS.py:

    import time
    sleep=time.sleep
    print "#####################################"
    print "# Waiting for Admin Server to Start #"
    print "#####################################"
    while True:
    try:
    connect(adminServerName="AdminServer")
    break

    except:

    sleep(60)

    print "##############################"
    print "# Admin Server has come up #"
    print "##############################"

    print "##########################"
    print "# Starting SOA Server 1 #"
    print "##########################"

    start(name="soa_server1", block="true")

    print "##########################"
    print "# Starting OSB Server #"
    print "##########################"

    start(name="osb_server1", block="true")

    print "##########################"
    print "# Starting BAM Server #"
    print "##########################"

    start(name="bam_server1", block="true")

    exit()

When you use these scripts you will get errors in the WLST script while it waits for the AdminServer to come up this is to be expected so just ignore. I have set the retry for 60 seconds so it shouldn’t try too many times.

Also you may get an error like 'ERROR: transport error 202: bind failed: Address already in use'. This is caused because 2 managed servers are using the same debugging port. If this is the case then you can edit the setDomainEnv.sh file and turn debugging off. Do this by searching for debugFlag="true" and set it to false, e.g. debugFlag="false".

If you want a shutdown script, it is much the same but in reverse.


  1. Create a script called stopMN.sh in directory of your choice, e.g. /home/oracle/scripts/weblogic/shutdown:

    MW_HOME=/u01/oracle/product/middleware

    . $MW_HOME/user_projects/domains/soa_domain/bin/setDomainEnv.sh

    $MW_HOME/oracle_common/common/bin/setNMProps.sh

    java weblogic.WLST /home/oracle/scripts/weblogic/shutdown/stopMS.py

    nohup $MW_HOME/user_projects/domains/soa_domain/bin/stopWebLogic.sh > $MW_HOME/user_projects/domains/soa_domain/servers/AdminServer/logs/AdminServerShutdown.out &

  2. Create a WLST script in the same directory called stopMS.py:

    connect(adminServerName="AdminServer")

    exitonerror=false
    # Stop all managed Servers
    shutdown('soa_server1','Server', force="true")
    shutdown('osb_server1','Server', force="true")
    shutdown('bam_server1','Server', force="true")

    exit()

Happy scripting.

Comments:

Nice one James - keep up the good work !

Posted by Dom on October 21, 2010 at 09:36 AM GMT+13:00 #

Good day!
I have a problem when I try to execute startup SOA servers with this script. I get following error:

Problem invoking WLST - Traceback (innermost last):
(no code object) at line 0
File "/oracle/script/start/startMS.py", line 8
try:
^
SyntaxError: invalid syntax

Posted by AlekZandre on December 23, 2010 at 03:00 PM GMT+13:00 #

I found out a cause of this error.
It is a intersection of a features of python and web-editor. In this case before try statement must be space symbol(s). And the web-editor removed ones after author had posted this article

Posted by AlekZandre on December 23, 2010 at 03:59 PM GMT+13:00 #

Startup_scripts_for_weblogic_and_soa_suite.. Corking :)

Posted by blogs.oracle.com on April 22, 2011 at 08:14 PM GMT+13:00 #

Hi - First let me start off by saying I am new to the weblogic arena and am looking to use your scripts for startup and shutdown. The startup script works to a point, it brings up the node manager and the weblogic adminserver, but when it goes down into the startMS.py script to start the managed servers it complains about line 8, which is the connect line. Does it need a password to go along with the connect? Any idea as to what the problem is? I appreciate your help and thanks in advance.

Posted by JCRowan on September 15, 2011 at 01:07 AM GMT+13:00 #

These scripts are really just to get you started. If you are getting an error trying to connect to the admin server it could be that the startWeblogic.sh did not start. The script is designed to keep trying until it makes a successful connection. Are you able to post the error you are getting.

cheers
James

Posted by James Taylor on September 15, 2011 at 05:19 AM GMT+13:00 #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Discussions and Examples using Oracle Fusion Middleware. Some image links are broken when using Firefox, Safari, and Chrome. If you want to see the full image please use IE.

Twitter:@james8001

tumblr hit counter vistors, thanks for your support

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today