WebLogic 11g Autostart

 

Setup Node Manager

* See this post to setup Node Manager.

Setup Auto Start Scripts

* Create a directory, e.g. ~/scripts, to hold scripts:

cd ~
mkdir scripts
cd scripts

* Create auto start script, e.g. named startwls.sh:
vi startwls.sh

MW_HOME=/u01/Oracle/Middleware
DOMAIN_HOME=$MW_HOME/user_projects/domains/soa_domain
 
$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 &
 
. $DOMAIN_HOME/bin/setDomainEnv.sh
java weblogic.WLST /home/oracle/scripts/startms.py

* Create WLST script, e.g. named startms.py, to start managed server using Node Manager (note that leading spaces are significant in Python scripts):
vi startms.py

import time
sleep=time.sleep
 
MW_HOME='/u01/Oracle/Middleware'
DOMAIN_HOME=MW_HOME + '/user_projects/domains/soa_domain'
 
# Connect to NM
print 'Connecting to node manager...'
nmConnect('weblogic', 'welcome1', 'oradev', '5556', 'soa_domain', DOMAIN_HOME,'ssl')
 
# Start AdminServer
print 'Start AdminServer...'
nmStart('AdminServer')
 
while True:
  try:
    print 'Connecting to AdminServer...'
    connect('weblogic','welcome1','t3://oradev:7001')
    break
  except:
    sleep(60)
 
print 'Start soa_server1...'
start("soa_server1", "Server", "t3://oradev:7001", block="true")
print 'Start bam_server1...'
start("bam_server1", "Server", "t3://oradev:7001", block="true")
 
exit()

* Enable execute mode:

chmod u+x *sh

Setup Auto Stop Scripts

* Create auto stop script, e.g. name stopwls.sh:
vi stopwls.sh

MW_HOME=/u01/Oracle/Middleware
DOMAIN_HOME=$MW_HOME/user_projects/domains/soa_domain
 
. $DOMAIN_HOME/bin/setDomainEnv.sh
$MW_HOME/oracle_common/common/bin/setNMProps.sh
java weblogic.WLST /home/oracle/scripts/stopms.py
 
$DOMAIN_HOME/bin/stopWebLogic.sh  >> $DOMAIN_HOME/bin/AdminServer.out 2>> $DOMAIN_HOME/bin/AdminServer.err < /dev/null &

* Create WLST script, e.g. named stopms.py, to stop all managed servers:
vi stopms.py

print 'Connecting to AdminServer...'
connect('weblogic','welcome1','t3://oradev:7001')
exitonerror=false
 
# Stop all managed Servers
print 'Stopping bam_server1...'
shutdown('bam_server1','Server', force="true")
print 'Stopping soa_server1...'
shutdown('soa_server1','Server', force="true")
 
exit()

* Enable execute mode:

chmod u+x *sh

Setup Auto Start Script

* sudo as root user

su -

* Create /etc/init.d/wls:

#!/bin/sh
# chkconfig: 345 99 10
# description: WebLogic servers auto start-stop script.
#
 
ORA_OWNER=oracle
SCRIPTS_DIR=/home/oracle/scripts
 
case "$1" in
    'start')
        su - $ORA_OWNER -c "$SCRIPTS_DIR/startwls.sh >> $SCRIPTS_DIR/startwls.log 2>&1"
        touch /var/lock/subsys/wls
        ;;
    'stop')
        su - $ORA_OWNER -c "$SCRIPTS_DIR/stopwls.sh >> $SCRIPTS_DIR/stopwls.log 2>&1"
        rm -f /var/lock/subsys/wls
        ;;
esac

* Set file permission

chmod 750 /etc/init.d/wls

* Add service with chkconfig command:

chkconfig --add wls

Test

* Test wls script:

service wls stop
service wls start

* Reboot to test

This entry was posted in weblogic11g and tagged , , , . Bookmark the permalink.

2 Responses to WebLogic 11g Autostart

Leave a Reply

Your email address will not be published. Required fields are marked *


*

This site uses Akismet to reduce spam. Learn how your comment data is processed.