Wednesday, June 8, 2016

Weblogic 12c: start and stop script for starting weblogic admin and managed server

As in my previous blog post I share the concept of starting and stopping nodemanager. In this blog post I am going to show you how you can start and stop weblogic admin server and managed server using admin server connection.

Start scripts for admin server and managed server

Well the basic logic to start admin and managed server is as:

  • Start the admin server using ./startWeblogic.sh script stored at the domain directory.
  • check for the admin server status is running or not by using same way as did for nodemanager in this post. But here we check for the string "RUNNING"
  • After admin started we invoke to start all the managed server cluster (all the server in a cluster will automatically start).
Here is the script:


rm -rf  *_Server.out AdminServer.out

tfile="AdminServer.out"

cd $DOMAIN_HOME
nohup ./startWebLogic.sh > AdminServer.out &

AdminStatus="STOP"

while [ "$AdminStatus" = "STOP" ]; do
                echo $tfile

                count=$(cat $tfile | grep "RUNNING" | wc -l)

echo "The value of count is ${count}"

                if [[ "$count" -gt 0 ]]; then
                        echo "AdminServer Started..."
AdminStatus="RUNNING"
nohup $WEBLOGIC_HOME/common/bin/wlst.sh startOSB.sh > OSB_Server.out &
                        nohup $WEBLOGIC_HOME/common/bin/wlst.sh startSOA.sh > SOA_Server.out &
                        nohup $WEBLOGIC_HOME/common/bin/wlst.sh startWSM.sh > WSM_Server.out &

                        rm -f $tfile
                        exit 0
                else
                    echo "Waiting For AdminServer To Start..."
                        
                fi
        sleep 5s
        done


echo "Please check ${tfile} log file for more issues"
exit 1 

In the above scripts I am calling three more scripts which are used to start the managed server cluster.

startOSB.sh

Content of the script is as follow:

connect('weblogic', 'welcome1', 't3://adminhostname:port')

start('bpm_osb_cluster','Cluster')

disconnect()

startSOA.sh

Content of the script is as follow:

connect('weblogic', 'Oracle123', 't3://adminhostname:port')

start('bpm_soa_cluster','Cluster')

disconnect()

startWSM.sh

Content of the script is as follow:

connect('weblogic', 'Oracle123', 't3://adminhostname:port')

start('bpm_wsm_cluster','Cluster')

disconnect()

Note: you can start the server instead of start cluster, refer this documentation 

Stop scripts for admin and managed server

For stopping managed server scripts first connect to the nodemanager and use the nmkill() method to kill the managed server

nmConnect('weblogic', 'Oracle123', 'prdbpmn01.ebsafrica.com', '5556', 'BPMDomain', '/u02/oracle/config/domains/BPMDomain','ssl')

nmKill('wls_wsm1')
nmKill('wls_osb1')
nmKill('wls_soa1')

nmDisconnect()

exit()

so you have to kill each server because there is no such method available to stop the cluster.

After that stop the admin server using this script.

nohup sh /u01/oracle/config/domains/BPMDomain/bin/stopWebLogic.sh &

Weblogic 12c: start and stop script for nodemanager

Recently I was working on the automated script to start and stop the nodemanager, AdminServer and all managed server (ESS, SOA, OSB, WSM) in a domain. So in this post I am going to share my work, it may be possible that these scripts may not be suited for your environment but yes It must give you a basic idea of how to start and stop nodemanager automatically.

Start scripts for nodemanager

Well the basic logic that I used to start the nodemanager is

  • check if nodemanager is running or not
  • start the nodemanager and take the output in a temporary file.
  • while the nodemanager is starting keep looking for the string "socket listener started on port" in a temporary file. 
  • if the matching string is found that means node manager is started and exit().
rm -rf nodemanage.*

tfile="nodemanage.$$.out"
status= ps -eaf | grep "weblogic.NodeManager" | grep -v grep| wc -l
date=date
echo $status
echo "Node Manager Directory: " $1

if [[ "$status" -eq 0 ]]; then
echo  $date " :Starting Weblogic NodeManager..."
echo $1
nohup $1 > $tfile 2>&1 &

else
echo  $date " :NodeManager is already RUNNING.."
fi

if [ "$?" != 0 ]; then
echo "Command Failed To Execute Properly"
exit 1;
fi

export a=0;
while [ $a -lt 10 ]; do
echo $tfile

count=$(cat $tfile | grep "socket listener started on port" | wc -l)

echo "The value of count is ${count}"                 

if [[ "$count" -gt 0 ]]; then
echo "NodeManager Started..."
rm -f $tfile
exit 0
else
echo "Waiting For NodeManager To Start..."
echo $a
((a++))
fi
sleep 5s
done
echo "Please check ${tfile} log file for more issues"
exit 1

Save the above script in .sh file e.g. startNode.sh. Now to run this script you have to pass the location of the nodemanager i.e.

nohup ./StartNode.sh $DOMAIN_HOME/bin/startNodeManager.sh > nodemanage.out &


Stop script for nodemanager

To stop the nodemanager find the process id of nodemanager instance and kill that process id, here is the script below:

node1=$(ps -ef | grep weblogic.nodemanager | grep config=/u01 | awk '{printf $2}')

kill -9 $node1

Save the above code in the .sh file e.g. stopNode.sh and execute the script as below:

nohup sh StopNode.sh &


In the next post I am going to share the start and stop script for weblogic AdminServer and Managed server.

Thursday, June 2, 2016

Change default /tmp path to other alternate tmp path for middleware installation

Some times when you install middleware component like oracle soa, weblogic etc. then it requires some temp space to extract content and install on the location but there may be case your /tmp directory is full or not having write permissin etc. (in my case there was no space in the tmp directory) you middleware installation stops in between.

Solution:

you can create a new directory as tmp only in some other location (/home/oracle/tmp) and map to the symbolic link of the directory /tmp (previously created).

Command : ln {source} {link}

i.e. ln -s /home/oracle/tml /tmp