Tuesday, August 13, 2013

Install and Set up Weblogic 10.3.2 in Linux

1. Unzip the tar into your choosen dir, e.g.
/opt/weblogic
2. Execute configure.sh script, e.g.
/opt/weblogic/wl10.3.5.0/wlserver_10.3/common/bin/config.sh
3. Follow the instruction in the console: creating username, password, domain name, admin server name, managed server name, port number...
 That's it. Now you have Weblogic AdminServer running!
If you wish to customize start and stop Weblogic scripts, you may try as folllow. 
4. Create dirs for scripts: e.g. /opt/yourcompany/yourproject/weblogic/scripts
Under Scripts, create admin, managed, all
scripts/admin
scripts/managed
scripts/all

5. Start script for admin server: start-admin.sh
e.g. your company name: abc and your project/app: xyz

#!/bin/bash


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

echo " ** Oracle Weblogic 10.3.2 startup script **"
echo " ** "$DATE" **"

export DOMAIN_HOME=/opt/abc/xyz/weblogic/xyzdomain
export XYZ_LOG_HOME=/var/abc/xyz/app/logs
export XYZ_ADMIN_LOG_NAME=xyzadmin.log

ADMIN_PORT=9090
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 > $XYZ_LOG_HOME/$YOURPROJECT_ADMIN_LOG_NAME 2>&1 &
 admin_run=`grep -i RUNNING $YOURPROJECT_LOG_HOME/$XZY_ADMIN_LOG_NAME |grep -v grep |awk 'END{print NR}'`
 while [ $admin_run -eq 0 ]
do
  sleep 2;
  admin_run=`grep -i RUNNING $YOURPROJECT_LOG_HOME/$YOURPROJECT_ADMIN_LOG_NAME |grep -v grep |awk 'END{print NR}'`
  echo -n "."
done
 echo -n "\n"
 echo "Started Oracle Weblogic 10.3.2 admin server at port:"$ADMIN_PORT
fi

6. Stop script for Admin Server: stop-admin.sh

#!/bin/bash

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

echo " ** Oracle Weblogic 10.3.2 start/stop script **"
echo " ** "$DATE" **"

export DOMAIN_HOME=/opt/yourcompany/yourproject/weblogic/yourdomain
export YOURPROJECT_LOG_HOME=/var/yourcompany/yourproject/app/logs

ADMIN_PORT=8098
admin_num=`netstat -nl|grep "$ADMIN_PORT" |grep -v grep |awk 'END{print NR}'`

if [ $admin_num -eq 0 ];
then
 echo "WebLogic Admin Server not RUNNING."
 exit 0
else
 echo "."
 cd $DOMAIN_HOME/bin
 echo "Stopping WebLogic Admin Server...."
 cd $DOMAIN_HOME/bin
 ./stopWebLogic.sh
 cd $DOMAIN_HOME
 echo "Stopped Oracle Weblogic 10.3.2 admin server at port:"$ADMIN_PORT
fi

7. Start script for Managed Server: start-managed.sh

#!/bin/bash

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

echo " ** Oracle Weblogic 10.3.2 managed server start script **"
echo " ** "$DATE" **"

export DOMAIN_HOME=/opt/abc/xyz/weblogic/xyzdomain
export XYZ_LOG_HOME=/var/abc/xyz/app/logs

ADMIN_URL=t3://url.com
ADMIN_PORT=9090
MANAGED_SERVER_NAME=TestServer
MANAGED_SERVER_PORT=9091

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

if [  $admin_num -gt  0 ]
then
 echo "WebLogic Admin Server is RUNNING."
 managed_server_num=`netstat -nl|grep "$MANAGED_SERVER_PORT" |grep -v grep |awk 'END{print NR}'`
 if [ $managed_server_num -gt  0 ]
 then
  echo "WebLogic Managed Server Already RUNNING."
  exit 0
 else
  echo "."
  cd $DOMAIN_HOME/bin
  echo "Starting WebLogic Managed Server...."
  nohup ./startManagedWebLogic.sh $MANAGED_SERVER_NAME  > $XYZ_LOG_HOME/$MANAGED_SERVER_NAME.log 2>&1 &
  managed_server_run=`grep -i "Server started in RUNNING mode" $XYZ_LOG_HOME/$MANAGED_SERVER_NAME.log |grep -v grep |awk 'END{print NR}'`
 while [ $managed_server_run -eq 0 ]
 do
  sleep 2;
  managed_server_run=`grep -i "Server started in RUNNING mode" $XYZ_LOG_HOME/$MANAGED_SERVER_NAME.log |grep -v grep |awk 'END{print NR}'`
  echo -n "."
 done
  echo "Started Oracle Weblogic 10.3.2 managed server at port:"$MANAGED_SERVER_PORT
 fi
else
 sleep 10
 echo "WebLogic Admin Server is not RUNNING."
 exit 0
fi


No comments:

Post a Comment