Thursday 27 February 2014

Linux Start/Stop script for OBIEE


A few years ago a blogged a start/stop control script for OBIEE. It seems like every time I use it for a new client I improve it in one way or another, so I guess it’s time for an update.

The script is below. Save it in a text file with execute permissions with a name like 'obiee.sh'.

It requires one of seven parameters:

start - Perform a full start of Weblogic and OBIEE
stop - Perform a full stop of Weblogic and OBIEE, including tidying up .lok files and killing the node manager
restart - Runs both the above stop and start processes
stopopmn - Stops the OBIEE Process Manager (just OBIEE, not weblogic)
startopmn - Starts the OBIEE Process Manager
restartopmn - Runs both the above stop and start OBIEE Process manager tasks
status - Displays the current status of the OBIEE Process manager and the five OBIEE services

When performing normal start or stop operations, just the start and stop parameters will be fine.  The others are all for times when either a bounce of the services is required or just the OBIEE services (as opposed to the weblogic services) need stopping, for instance when a configuration change has been made.

The status parameter is a quick way of seeing if the OBIEE process manager (and by implication weblogic) is running, it responds with the following:

***************************************************************************
Oracle BIEE components status....
***************************************************************************

Processes in Instance: instance1
---------------------------------+--------------------+---------+---------
ias-component                    | process-type       |     pid | status
---------------------------------+--------------------+---------+---------
coreapplication_obiccs1          | OracleBIClusterCo~ |   24806 | Alive
coreapplication_obisch1          | OracleBIScheduler~ |   24805 | Alive
coreapplication_obijh1           | OracleBIJavaHostC~ |   24804 | Alive
coreapplication_obips1           | OracleBIPresentat~ |   24803 | Alive
coreapplication_obis1            | OracleBIServerCom~ |   24802 | Alive

If the process manager is not running it will simply state that it is not running. The five components listed are the same five OBIEE components in the enterprise manager ‘pie’ chart.

The stop parameter also performs some tidying up, including killing the node manager and deleting any .lok files that may prevent services from starting. In a recovery scenario when either OBIEE or Weblogic is failing to respond always run the script with the stop parameter before attempting a start.

When either the start or stop parameters are used the script will create a log file into which all responses from the Weblogic and OBIEE services will be routed. These are called obiee_start_yyyymmdd_hhmm.log and obiee_stop_yyyymmdd_hhmm.log respectively and are stored in the log directory (mentioned below).

The ‘start’ log contains all output from Weblogic and OBIEE services during the entire time they are running, not just the start process. So should any errors with Weblogic or OBIEE be encountered the ‘start’ log may well contain any internal error messages generated.  As a result the start logs may grow quite large over time and may need deleting occasionally.

The ‘stop’ log only contains output during the stop process.

The script also creates symbolic link files for all Weblogic and OBIEE log files in the log directory so they can all be seen from a single location – so much easier than trawling through the weblogic directories!

At the top there are a number of config settings which need adapting to the OBIEE environment it’s being used for.

Anyway, here's the script. Enjoy!

# Start and stop Oracle Business Intelligence 11g components.
#
# Paul Cannon, 3-Sixty Analytics. Feb 2014.
#

ORACLE_OWNR=oracle                                     # Local Unix user running OBIEE
ORACLE_FMW=/u01/app/oracle/product/Middleware          # Deployment Middleware directory

BIEE_DOMAIN=bifoundation_domain                        # Domain name
BIEE_INSTANCE=instance1                                # Instance name
BIEE_SERVER=bi_server1                                 # Server name
BIEE_MANAGER_URL=servername:7001                       # Admin server URL (hostname:port)
BIEE_USER=weblogic                                     # Admin user
BIEE_PASSWD=Welcome1                                   # Admin password
LOG_PATH=/home/oracle/logs                             # Log directory


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

ORACLE_HOME=$ORACLE_FMW/Oracle_BI1
export ORACLE_HOME

INSTANCE_HOME=$ORACLE_FMW/instances/$BIEE_INSTANCE
export INSTANCE_HOME

WLS_HOME=$ORACLE_FMW/wlserver_10.3
export WLS_HOME

FMW_HOME=$ORACLE_FMW
export FMW_HOME



#create the security file boot.properties

rm -f $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/AdminServer/security/boot.properties

rm -f $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/$BIEE_SERVER/security/boot.properties

echo  username=$WL_USER >$ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/AdminServer/security/boot.properties

echo  password=$WL_PASSWD >>$ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/AdminServer/security/boot.properties

echo  username=$WL_USER >$ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/$BIEE_SERVER/security/boot.properties

echo  password=$WL_PASSWD >>$ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/$BIEE_SERVER/security/boot.properties
# recreate symbolic links to log files.

ln -sf $ORACLE_INSTANCE/diagnostics/logs/OracleBIServerComponent/coreapplication_obis1/nqserver.log $LOG_PATH/nqserver.log
ln -sf $ORACLE_INSTANCE/diagnostics/logs/OracleBIServerComponent/coreapplication_obis1/nqquery.log $LOG_PATH/nqquery.log
ln -sf $ORACLE_INSTANCE/diagnostics/logs/OracleBIServerComponent/coreapplication_obis1/console~coreapplication_obis1~1.log $LOG_PATH/console~coreapplication_obis1~1.log

ln -sf $ORACLE_INSTANCE/diagnostics/logs/OracleBIPresentationServicesComponent/coreapplication_obips1/console~coreapplication_obips1~1.log $LOG_PATH/console~coreapplication_obips1~1.log

ln -sf $(ls -Art $ORACLE_INSTANCE/diagnostics/logs/OracleBIPresentationServicesComponent/coreapplication_obips1/sawlog*.log | tail -n 1) $LOG_PATH/sawlog.log

ln -sf $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/AdminServer/logs/AdminServer.log $LOG_PATH/AdminServer.log
ln -sf $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/AdminServer/logs/AdminServer-diagnostic.log $LOG_PATH/AdminServer-diagnostic.log
ln -sf $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/AdminServer/logs/access.log $LOG_PATH/AdminServer-access.log

ln -sf $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/bi_server1/logs/bi_server1-diagnostic.log $LOG_PATH/bi_server1-diagnostic.log
ln -sf $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/bi_server1/logs/bi_server1.log $LOG_PATH/bi_server1.log
ln -sf $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/bi_server1/logs/access.log $LOG_PATH/bi_server-access.log

ln -sf $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/bi_server1/logs/bipublisher/bipublisher.log $LOG_PATH/bipublisher.log

ln -sf $WLS_HOME/common/nodemanager/nodemanager.log $LOG_PATH/nodemanager.log

ln -sf $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/bi_server1/data/ldap/log/EmbeddedLDAPAccess.log $LOG_PATH/EmbeddedLDAPAccess.log
ln -sf $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/bi_server1/data/ldap/log/EmbeddedLDAP.log $LOG_PATH/EmbeddedLDAP.log


NOW=$(date +"%Y%m%d-%H%M")
START_LOG=$LOG_PATH/obiee_start_$NOW.log
STOP_LOG=$LOG_PATH/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_HOME/opmn/bin/opmnctl startall
    $ORACLE_HOME/opmn/bin/opmnctl status


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

stop() {
    echo "********************************************************************************"
    echo "Stopping BI components on $(date)"
    echo "********************************************************************************"
    $ORACLE_HOME/opmn/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 "$ORACLE_FMW/wlserver_10.3/server/lib/weblogic.policy -Dweblogic.nodemanager"

    echo "********************************************************************************"
    echo "Stopping Admin Server on $(date)"
    echo "********************************************************************************"
    $BIEE_PATH/stopWebLogic.sh

    echo "********************************************************************************"
    echo "Cleaning up .lok files"
    echo "********************************************************************************"
    rm -f $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/edit.lok
    rm -f $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/config/config.lok
    rm -f $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/bi_server1/data/ldap/ldapfiles/EmbeddedLDAP.lok
    rm -f $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/bi_server1/tmp/bi_server1.lok
    rm -f $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/AdminServer/data/ldap/ldapfiles/EmbeddedLDAP.lok
    rm -f $ORACLE_FMW/user_projects/domains/$BIEE_DOMAIN/servers/AdminServer/tmp/AdminServer.lok

    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 "To view log file: tail -f $START_LOG"
        echo "********************************************************************************"
        start &> $START_LOG &
        touch $LOG_PATH/$SUBSYS
    ;;
    stop)
        echo "********************************************************************************"
        echo "Stopping Oracle Business Intelligence on $(date)"
        echo "Logs are sent to $STOP_LOG"
        echo "********************************************************************************"
        stop &> $STOP_LOG
        rm -f  $LOG_PATH/$SUBSYS
    ;;
    status)
        echo "********************************************************************************"
        echo "Oracle BIEE components status...."
        echo "********************************************************************************"
        $ORACLE_HOME/opmn/bin/opmnctl status
    ;;
    stopopmn)
        echo "********************************************************************************"
        echo "Oracle BIEE components status...."
        echo "********************************************************************************"
        $ORACLE_HOME/opmn/bin/opmnctl stopall
    ;;
    startopmn)
        echo "********************************************************************************"
        echo "Oracle BIEE components status...."
        echo "********************************************************************************"
        $ORACLE_HOME/opmn/bin/opmnctl startall
        $ORACLE_HOME/opmn/bin/opmnctl status
    ;;
    restartopmn)
        echo "********************************************************************************"
        echo "Oracle BIEE components status...."
        echo "********************************************************************************"
        $ORACLE_HOME/opmn/bin/opmnctl stopall
        $ORACLE_HOME/opmn/bin/opmnctl startall
        $ORACLE_HOME/opmn/bin/opmnctl status
    ;;


    restart)
        $0 stop
        $0 start
    ;;
    *)
        echo "Usage: $(basename $0) start|stop|restart|stopopmn|startopmn|restartopmn|status"
        exit 1
esac


exit 0

No comments:

Post a Comment