Start and stop WebLogic Server using scripts

Tweet about this on TwitterShare on Facebook0Share on LinkedIn0Share on Google+0

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!

Tweet about this on TwitterShare on Facebook0Share on LinkedIn0Share on Google+0

Autor: Waslley Souza

Consultor Oracle com foco em tecnologias Oracle Fusion Middleware e SOA. Certificado Oracle WebCenter Portal, Oracle ADF e Java.

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *