Sunday 29 April 2012

Linux OBIEE start/stop script


Here is a script for starting and stopping the OBIEE 11g services under Linux.

This is generally available from other blogs but I've improved it by adding an option just to restart the OPMN services (rather than the entire weblogic stack) and also got it to create the boot.properties file to prevent prompting for the weblogic admin userid & password.

The settings at the top of the file need to be amended to suit the installation.

The file name should be something like obiee_start_stop.sh.

Update: I've enhanced it further to firstly overcome the occassional problem where the presentation services fails to start, which I suspect it because it's starting too soon, the solution being to start the five opmn services manually one at a time. Secondly I've added additional options to just stop, start and restart the opmn services.


#!/bin/bash
#
# File:    /etc/init.d/obiee
# Purpose: Start and stop Oracle Business Intelligence 11g components.
#
# chkconfig: 2345 99 10
# description: Manage OBIEE service.
#
# These values must be adapted to your environment.

ORACLE_OWNR=user                      # Local Unix user running OBIEE
ORACLE_FMW=/u01/app/obiee            # Deployment root directory
                                  
BIEE_USER=weblogic                    # BIEE administrator name
BIEE_PASSWD=Password1                  # BIEE administrator password              
BIEE_DOMAIN=bifoundation_domain        # Domain name
BIEE_INSTANCE=instance1                 # Instance name
BIEE_SERVER=bi_server1                  # Server name
BIEE_MANAGER_URL=linux.local.com:7001    # Admin server URL (hostname:port)   

#create the security file boot.properties

rm -f $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/AdminServer/security/boot.properties
echo  username=$BIEE_USER >$ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/AdminServer/security/boot.properties
echo  password=$BIEE_PASSWD >>$ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/AdminServer/security/boot.properties

# These should require no change.

WL_PATH=$ORACLE_FMW/wlserver_10.3/server/bin
BIEE_PATH=$ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/bin
ORACLE_INSTANCE=$ORACLE_FMW/instances/$BIEE_INSTANCE

export ORACLE_INSTANCE


NOW=$(date +"%Y%m%d-%H%M")
START_LOG=/u01/app/obiee/logs/obiee-start-$NOW.log
STOP_LOG=/u01/app/obiee/logs/obiee-stop
-$NOW.log
SUBSYS=obiee

start() {
    echo "********************************************************************************"
    echo "Starting Admin Server on $(date)"
    echo "********************************************************************************"
    $BIEE_PATH/startWebLogic.sh &
    wait_for "Server started in RUNNING mode"
   
    echo "********************************************************************************"
    echo "Starting Node Manager on $(date)"
    echo "********************************************************************************"
    $WL_PATH/startNodeManager.sh &
    wait_for "socket listener started on port"

    echo "********************************************************************************"
    echo "Starting Managed Server $BIEE_SERVER on $(date)"
    echo "********************************************************************************"
    $BIEE_PATH/startManagedWebLogic.sh $BIEE_SERVER http://$BIEE_MANAGER_URL &
    wait_for "Server started in RUNNING mode"

    echo "********************************************************************************"
    echo "Starting BI components on $(date)"
    echo "********************************************************************************"
    $ORACLE_INSTANCE/bin/opmnctl start
    $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obijh1
    $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obiccs1
    $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obis1
    $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obisch1
    $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obips1
    $ORACLE_INSTANCE/bin/opmnctl status


    echo "********************************************************************************"
    echo "OBIEE start sequence completed on $(date)"
    echo "********************************************************************************"
}

stop() {
    echo "********************************************************************************"
    echo "Stopping BI components on $(date)"
    echo "********************************************************************************"
    $ORACLE_INSTANCE/bin/opmnctl stopall

    echo "********************************************************************************"
    echo "Stopping Managed Server $BIEE_SERVER on $(date)"
    echo "********************************************************************************"
    $BIEE_PATH/stopManagedWebLogic.sh $BIEE_SERVER t3://$BIEE_MANAGER_URL $BIEE_USER $BIEE_PASSWD
    echo "********************************************************************************"
    echo "Stopping Node Manager on $(date)"
    echo "********************************************************************************"
    pkill -TERM -u $ORACLE_OWNR -f "weblogic\\.NodeManager"
   
    echo "********************************************************************************"
    echo "Stopping Admin Server on $(date)"
    echo "********************************************************************************"
    $BIEE_PATH/stopWebLogic.sh
    echo "********************************************************************************"
    echo "OBIEE stop sequence completed on $(date)"
    echo "********************************************************************************"
}

wait_for() {
    res=0
    while [[ ! $res -gt 0 ]]
    do
        res=$(tail -5 "$START_LOG" | fgrep -c "$1")
        sleep 5
    done
}

case "$1" in
    start)
        echo "********************************************************************************"
        echo "Starting Oracle Business Intelligence on $(date)"
        echo "Logs are sent to $START_LOG"
        echo "********************************************************************************"
        start &> $START_LOG &
        touch /u01/app/obiee/logs/$SUBSYS
    ;;
    stop)
        echo "********************************************************************************"
        echo "Stopping Oracle Business Intelligence on $(date)"
        echo "Logs are sent to $STOP_LOG"
        echo "********************************************************************************"
        stop &> $STOP_LOG
        rm -f /u01/app/obiee/logs/$SUBSYS
    ;;
    status)
        echo "********************************************************************************"
        echo "Oracle BIEE components status...."
        echo "********************************************************************************"
        $ORACLE_INSTANCE/bin/opmnctl status
    ;;
    stopopmn)
        echo "********************************************************************************"
        echo "Oracle BIEE components status...."
        echo "********************************************************************************"
        $ORACLE_INSTANCE/bin/opmnctl stopall
    ;;
    startopmn)
        echo "********************************************************************************"
        echo "Oracle BIEE components status...."
        echo "********************************************************************************"
        $ORACLE_INSTANCE/bin/opmnctl start
        $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obijh1
        $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obiccs1
        $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obis1
        $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obisch1
        $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obips1
        $ORACLE_INSTANCE/bin/opmnctl status
    ;;    
    restartopmn)
        echo "********************************************************************************"
        echo "Oracle BIEE components status...."
        echo "********************************************************************************"
        $ORACLE_INSTANCE/bin/opmnctl stopall
        $ORACLE_INSTANCE/bin/opmnctl start
        $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obijh1
        $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obiccs1
        $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obis1
        $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obisch1
        $ORACLE_INSTANCE/bin/opmnctl startproc ias-component=coreapplication_obips1
        $ORACLE_INSTANCE/bin/opmnctl status
    ;;
    restart)
        $0 stop
        $0 start
    ;;
    *)
        echo "Usage: $(basename $0) start|stop|restart|stopopmn|startopmn|restartopmn|status"
        exit 1
esac


exit 0

1 comment:

  1. Great Script Paul... Very helpful...

    ReplyDelete