Start Weblogic and managed server through script

Requirement– you set weblogic, database and all managed server.You don’t want to go command prompt and start servers.You can start everythng by script in linux environment

Implementation– Please follow below script to start everything by a normal GUI as below –

StartServer

Create a new file and copy below script.You have to change ORACLE_HOME,ORACLE_SID and DOMAIN_HOME according to your machine.Save as extension of .sh .
Double click that file you will see above screen.enter 1 ,2 or following numbers to start and stop the server.

#!/bin/bash

DATE=`date +%A" "%d-%b-%Y-%X`

DATESTAMP=`date +%d-%b-%Y-%T`

clear

echo "************************************************************************"

echo "**********************   ControlCenter   ************************"

echo "************************************************************************"

echo " "

echo "                    "$DATE"

                    "

echo " "


echo " "

echo "1.  START Oracle Database and Listener "

echo "2.  START Oracle Weblogic Server [AdminServer]"

echo "3.  START Oracle UCM [UCM_server1] "

echo "4.  START Oracle Portlet [WC_Portlet] "

echo "5.  START Oracle Utilities [WC_Utilities] "

echo "6.  START Oracle Spaces [WC_Spaces] "

echo " "

echo "7.  STOP Oracle Portlet [WC_Portlet] "

echo "8.  STOP Oracle Utilities [WC_Utilities] "

echo "9.  STOP Oracle UCM [UCM_server1] "

echo "10. STOP Oracle Spaces server [WC_Spaces] "

echo "11. STOP Oracle Weblogic Server [AdminServer] "

echo "12. STOP Oracle Database and Listener "

echo " "

echo "X.  EXIT from this Menu "

echo "************************************************************************"



#export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1

#export PATH=$ORACLE_HOME/bin:$PATH

#export ORACLE_SID=orcl

#export LD_LIBRARY_PATH=$ORACLE_HOME/lib

#export DOMAIN_HOME=/home/oracle/Oracle/Middleware/user_projects/domains/ucm_domain



export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=orcl
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export DOMAIN_HOME=/u01/app/oracle/Oracle/middleware/user_projects/domains/ucm_domain



ADMIN_PORT=7001
UCM_PORT=16200
PORTLET_PORT=8889
SPACES_PORT=8888
UTILITIES_PORT=8891



#echo "\n X.  Exit from Menu"

echo "Enter the Administration Option (X to exit menu):"
read ADMINTASK

#

if [[ -z $ADMINTASK ]]; then

   echo "Please enter a numeric value from the Menu!"

else

case $ADMINTASK in



#---------------------------------------------------------------------------------------------



"101")

clear

#

lsnr_num=`ps -ef|grep tnslsnr |grep -v grep |awk 'END{print NR}'`



if [ $lsnr_num -gt 0 ]

then echo "Database Listener Already RUNNING."

else echo "Starting Infrastructure Database Listener..."

$ORACLE_HOME/bin/lsnrctl start

fi



db_num=`ps -ef|grep pmon |grep -v grep |awk 'END{print NR}'`



if [ $db_num -gt 0 ]

then echo "Database Already RUNNING."

else echo "Starting Oracle Database ..."

$ORACLE_HOME/bin/sqlplus "/ as sysdba" <<EOF

#connect sys/welcome1 as sysdba

startup

EOF

#



sleep 10

echo "Database Services Successfully Started. "

#

fi





admin_num=`ps -ef|grep "$ADMIN_PORT" |grep -v grep |awk 'END{print NR}'`



if [ $admin_num -gt 0 ]

then echo "WebLogic Admin Server Already RUNNING."

else echo "."

cd $DOMAIN_HOME/bin



echo "Starting WebLogic Admin Server...."

nohup ./startWebLogic.sh > weblogic.out &

admin_run=`grep -i RUNNING weblogic.out|grep -v grep |awk 'END{print NR}'`

while [ $admin_run -eq 0 ]

do

sleep 5;

admin_run=`grep -i RUNNING weblogic.out|grep -v grep |awk 'END{print NR}'`

done



echo "Starting UCM_server1...."

nohup ./startManagedWebLogic.sh UCM_server1 > ucm.out &

sleep 5;

ucm_run=`grep -i "Server started in RUNNING mode" ucm.out|grep -v grep

|awk 'END{print NR}'`

while [ $ucm_run -eq 0 ]

do

sleep 5;

ucm_run=`grep -i "Server started in RUNNING mode" ucm.out|grep -v grep

|awk 'END{print NR}'`

done



fi

;;



#---------------------------------------------------------------------------------------------





#---------------------------------------------------------------------------------------------



"1")

clear

#

lsnr_num=`ps -ef|grep tnslsnr |grep -v grep |awk 'END{print NR}'`



if [ $lsnr_num -gt 0 ]

then echo "Database Listener Already RUNNING."

else echo "Starting Infrastructure Database Listener..."

$ORACLE_HOME/bin/lsnrctl start

fi



db_num=`ps -ef|grep pmon |grep -v grep |awk 'END{print NR}'`



if [ $db_num -gt 0 ]

then echo "Database Already RUNNING."

else echo "Starting Oracle Database ..."

$ORACLE_HOME/bin/sqlplus "/ as sysdba" <<EOF

#connect sys/welcome1 as sysdba

startup

EOF

#

sleep 10

echo "Database Services Successfully Started. "

#

fi

;;



#---------------------------------------------------------------------------------------------



"2")
echo "Starting WLS_Admin ...."
admin_num=`netstat -nl|grep "$ADMIN_PORT" |grep -v grep |awk 'END{print NR}'`
if [ $admin_num -gt 0 ]
then echo "WebLogic Admin Server Already RUNNING."
else echo "."
cd $DOMAIN_HOME/bin
echo "Starting WebLogic Admin Server...."
nohup ./startWebLogic.sh > weblogic.out &
sleep 5;
admin_run=`grep -i "Server started in RUNNING mode" weblogic.out|grep -v grep |awk 'END{print NR}'`
while [ $admin_run -eq 0 ]
do
sleep 5;
admin_run=`grep -i "Server started in RUNNING mode" weblogic.out|grep -v grep |awk 'END{print NR}'`
done
fi
;;



#---------------------------------------------------------------------------------------------

"3")

ucm_num=`netstat -nl|grep "$UCM_PORT" |grep -v grep |awk 'END{print NR}'`
if [ $ucm_num -gt 0 ]
then echo "UCM_server1 Already RUNNING."
else echo "."
cd $DOMAIN_HOME/bin
echo "Starting UCM_server1...."
nohup ./startManagedWebLogic.sh UCM_server1 > ucm.out &
sleep 5;
ucm_run=`grep -i "Server started in RUNNING mode" ucm.out|grep -v grep |awk 'END{print NR}'`
while [ $ucm_run -eq 0 ]
do
sleep 5;
ucm_run=`grep -i "Server started in RUNNING mode" ucm.out|grep -v grep |awk 'END{print NR}'`
done
fi
;;


#---------------------------------------------------------------------------------------------


"4")

portlet_num=`netstat -nl|grep "$PORTLET_PORT" |grep -v grep |awk 'END{print NR}'`
if [ $portlet_num -gt 0 ]
then echo "WC_Portlet Already RUNNING."
else echo "."
cd $DOMAIN_HOME/bin
echo "Starting WC_Portlet...."
nohup ./startManagedWebLogic.sh WC_Portlet > portlet.out &
sleep 5;
portlet_run=`grep -i "Server started in RUNNING mode" portlet.out|grep -v grep |awk 'END{print NR}'`
while [ $portlet_run -eq 0 ]
do
sleep 5;
portlet_run=`grep -i "Server started in RUNNING mode" portlet.out|grep -v grep |awk 'END{print NR}'`
done
fi
;;


#---------------------------------------------------------------------------------------------

"5")

utilities_num=`netstat -nl|grep "$UTILITIES_PORT" |grep -v grep |awk 'END{print NR}'`
if [ $utilities_num -gt 0 ]
then echo "WC_Utilities Already RUNNING."
else echo "."
cd $DOMAIN_HOME/bin
echo "Starting WC_Utilities...."
nohup ./startManagedWebLogic.sh WC_Utilities > utilities.out &
sleep 5;
utilities_run=`grep -i "Server started in RUNNING mode" utilities.out|grep -v grep |awk 'END{print NR}'`
while [ $utilities_run -eq 0 ]
do
sleep 5;
utilities_run=`grep -i "Server started in RUNNING mode" utilities.out|grep -v grep |awk 'END{print NR}'`
done
fi
;;



#---------------------------------------------------------------------------------------------

"6")

spaces_num=`netstat -nl|grep "$SPACES_PORT" |grep -v grep |awk 'END{print NR}'`
if [ $spaces_num -gt 0 ]
then echo "WC_Spaces Already RUNNING."
else echo "."
cd $DOMAIN_HOME/bin
echo "Starting WC_Spaces...."
nohup ./startManagedWebLogic.sh WC_Spaces > spaces.out &
sleep 5;
spaces_run=`grep -i "Server started in RUNNING mode" spaces.out|grep -v grep |awk 'END{print NR}'`
while [ $spaces_run -eq 0 ]
do
sleep 5;
spaces_run=`grep -i "Server started in RUNNING mode" spaces.out|grep -v grep |awk 'END{print NR}'`
done
fi
;;


#---------------------------------------------------------------------------------------------



"7")

echo "Stopping  Oracle Portlet [WC_Portlet] ... "

cd $DOMAIN_HOME/bin

./stopManagedWebLogic.sh WC_Portlet

;;





#---------------------------------------------------------------------------------------------



"8")

echo "Stopping  Oracle Utilities [WC_Utilities] ... "

cd $DOMAIN_HOME/bin

./stopManagedWebLogic.sh WC_Utilities

;;


#---------------------------------------------------------------------------------------------



"9")

echo "Stopping  Oracle UCM [UCM_server1] ... "

cd $DOMAIN_HOME/bin

./stopManagedWebLogic.sh UCM_server1

;;


#---------------------------------------------------------------------------------------------



"10")

echo "Stopping Webcenter Spaces [WC_Spaces] ..."

cd $DOMAIN_HOME/bin

./stopManagedWebLogic.sh WC_Spaces

;;




#---------------------------------------------------------------------------------------------



"11")

echo "Stopping Admin Server [WLS_Admin] ..."

cd $DOMAIN_HOME/bin

./stopWebLogic.sh

;;



#---------------------------------------------------------------------------------------------



"12")

echo "Stopping Oracle Database and Listener ..."

$ORACLE_HOME/bin/sqlplus "/ as sysdba" <<EOF

#connect sys/welcome1 as sysdba

shutdown immediate

EOF

#





$ORACLE_HOME/bin/lsnrctl stop

sleep 10;

lsnr_num=`ps -ef|grep tnslsnr |grep -v grep |awk 'END{print NR}'`



if [ $lsnr_num -gt 0 ]

then kill -9 `ps -deafw | grep "$ORACLE_HOME" | grep -v grep |  awk

'{print $2}' | paste -s -d" " -`

fi

;;



#---------------------------------------------------------------------------------------------



"100")

clear



cd $DOMAIN_HOME/bin



echo "Stopping Database,IBR_Server1, UCM_Server1 ..."

./stopManagedWebLogic.sh IBR_server1

./stopManagedWebLogic.sh UCM_server1

./stopWebLogic.sh



echo "Stopping Oracle Database and Listener ..."

$ORACLE_HOME/bin/sqlplus "/ as sysdba" <<EOF

#connect sys/welcome1 as sysdba

shutdown immediate

EOF

#

$ORACLE_HOME/bin/lsnrctl stop

sleep 10;

lsnr_num=`ps -ef|grep tnslsnr |grep -v grep |awk 'END{print NR}'`



if [ $lsnr_num -gt 0 ]

then kill -9 `ps -deafw | grep "$ORACLE_HOME" | grep -v grep |  awk

'{print $2}' | paste -s -d" " -`

fi

;;



#---------------------------------------------------------------------------------------------

"X")
clear
exit
;;
esac
fi
controlscript.sh


 

Happy learning with Vinay Kumar in techartifact….