Categories
Oracle

Start and stop WebLogic Server using scripts

You can use scripts to facilitate the management of WebLogic Server and reduce the manual tasks you have to do.
Examples of these scripts are scripts to automate start and stop of Admin and Managed Servers of WebLogic Server.

In this post I will provide the scripts I use and you can download them here: scripts.zip

These are the scripts that I use to start WebLogic Server in my Linux VM.
One of them is a Shell script to start Node Manager and AdminServer, and the other is a Python script to start SOA, OSB and BAM Managed Servers.

Shell script:

echo "############################"
echo "# All Servers are STARTING #"
echo "############################"
export FMW_HOME=/u01/app/fmw
export DOMAIN_HOME=/u01/app/fmw/user_projects/domains/fmw_domain

nohup $DOMAIN_HOME/bin/startNodeManager.sh > $DOMAIN_HOME/nodemanager/logs/nodemanager.out &

nohup $DOMAIN_HOME/bin/startWebLogic.sh > $DOMAIN_HOME/servers/AdminServer/logs/AdminServer.out &

SERVER=127.0.0.1 PORT=7001
while !(: < /dev/tcp/$SERVER/$PORT) 2>/dev/null
do
    echo "** Waiting for Admin Server to Start **"
    sleep 30
done

. $FMW_HOME/wlserver/server/bin/setWLSEnv.sh
. $DOMAIN_HOME/bin/setDomainEnv.sh
. $DOMAIN_HOME/bin/setStartupEnv.sh

/u01/app/jdk/bin/java weblogic.WLST /u01/app/utils/scripts/allServersStart.py

echo "###########################"
echo "# All Servers are RUNNING #"
echo "###########################"

tail -f $DOMAIN_HOME/nodemanager/logs/nodemanager.out $DOMAIN_HOME/servers/AdminServer/logs/AdminServer.out

start-and-stop-weblogic-server-using-scripts1

Python script:

while True:
 try:
  connect(adminServerName="AdminServer")
  break

 except:
  sleep(60)

print "** Starting SOA Server **"
start(name="SOA_server", block="true")

print "** Starting OSB Server **"
start(name="SOA_osbserver", block="true")

print "** Starting BAM Server **"
start(name="SOA_bamserver", block="true")

exit()

start-and-stop-weblogic-server-using-scripts2

And these are the scripts that I use to stop WebLogic Server in my Linux VM.
One of them is a Shell script to stop Node Manager and AdminServer, and the other is a Python script to stop SOA, OSB and BAM Managed Servers.

Shell script:

echo "############################"
echo "# All Servers are STOPPING #"
echo "############################"
export FMW_HOME=/u01/app/fmw
export DOMAIN_HOME=/u01/app/fmw/user_projects/domains/fmw_domain

. $FMW_HOME/wlserver/server/bin/setWLSEnv.sh
. $DOMAIN_HOME/bin/setDomainEnv.sh
. $DOMAIN_HOME/bin/setStartupEnv.sh

/u01/app/jdk/bin/java weblogic.WLST /u01/app/utils/scripts/allServersStop.py

nohup $DOMAIN_HOME/bin/stopWebLogic.sh > $DOMAIN_HOME/servers/AdminServer/logs/AdminServer.out

nohup $DOMAIN_HOME/bin/stopNodeManager.sh > $DOMAIN_HOME/nodemanager/logs/nodemanager.out

start-and-stop-weblogic-server-using-scripts3

Python script:

connect(adminServerName="AdminServer")

exitonerror=false

# Stop all managed Servers
shutdown('SOA_server', 'Server', force="true")
shutdown('SOA_osbserver', 'Server', force="true")
shutdown('SOA_bamserver', 'Server', force="true")

exit()

start-and-stop-weblogic-server-using-scripts4

Enjoy!

10 replies on “Start and stop WebLogic Server using scripts”

Hi Waslley,

I got the below exception while using stop-all servers script, can you please check and advise ?

Connecting to t3://localhost:7001 with userid weblogic …
This Exception occurred at Wed Apr 11 13:07:47 EDT 2018.
javax.naming.CommunicationException: Failed to initialize JNDI context, tried 2 time or times totally, the interval of each time is 0ms.
t3://localhost:7001: Destination 127.0.0.1, 7001 unreachable.; nested exception is:
java.net.ConnectException: Connection refused (Connection refused); No available router to destination.; nested exception is:
java.rmi.ConnectException: No available router to destination. [Root exception is java.net.ConnectException: t3://localhost:7001: Destination 127.0.0.1, 7001 unreachable.; nested exception is:
java.net.ConnectException: Connection refused (Connection refused); No available router to destination.; nested exception is:
java.rmi.ConnectException: No available router to destination.]
Problem invoking WLST – Traceback (innermost last):
File “/orabpm/app/scripts/Test_ServerRestart/allServersStop.py”, line 1, in ?
File “”, line 19, in connect
File “”, line 553, in raiseWLSTException
WLSTException: Error occurred while performing connect : Error getting the initial context. There is no server running at t3://localhost:7001 : Failed to initialize JNDI context, tried 2 time or times totally, the interval of each time is 0ms.
t3://localhost:7001: Destination 127.0.0.1, 7001 unreachable.; nested exception is:
java.net.ConnectException: Connection refused (Connection refused); No available router to destination.; nested exception is:
java.rmi.ConnectException: No available router to destination.
Use dumpStack() to view the full stacktrace :

nohup: ignoring input and redirecting stderr to stdout
nohup: ignoring input and redirecting stderr to stdout

i m facing an issue called ” <The Administration Server was unable to establish JMX Connectivity with the Managedserver2 at the JMX Service URL of .>” . So please tell me the solution how to rectify it. Once again Allserversstop script file is not working. Please check the code once

Hi Waslley,

thank you for the scripts.
How should I modify the scripts, if my T3 works on different port?
In my case it is 8001, due to env. setting.
I set the hostname and port in allServersStart.sh, but it is not used for t3 link.

It still tries to connec to the default t3://localhost:7001

Hey, thanks for the script ,

when i was about to start the Manage server , in the shell script i am getting it like below,

nohup ./startManagedWebLogic.sh opa_server01 > opa_server01.log &
[oracle@opa01 bin]$ nohup: ignoring input and redirecting stderr to stdout

and there are other commands which needs to be executed after this command. But it is like that and no further script is running.
so the question is how to make the remaining script also to run ?

Hi Waslley,

How can we get run time status of weblogic admin servers when admin is started with wslt script(not using Node manager)?

Hi,
Does your script also start nodemanagers on other hosts? Example, I have multiple hosts, each hosts has managed servers that I like to start up with the script. Right now, I have nodemanagers come up as a service on each host. But just in case, nodemanagers do not come up on some hosts, I’d like the script to start nodemanagers up.

Comments are closed.