OBI EE unix start/stop scripts


When installing OBI EE on MS Windows you get start-stop scripts out-of-box, but Oracle doesn’t provide any for Unix installations. Fortunately windows scripts could be very easily changed to work on Unix OS. I’ve tested them on various Linux ad AIX installations, and none of them gave me any troubles. These scripts use Apache ANT for starting and stopping OBI EE. ANT is packaged with all OBI EE distributives, is installed automatically and doesn’t need installation or any configuration.
All you need to do is to create two files: small executable one and then configuration (build) one for ANT. Executable start_stop.sh:


start_stop.sh

export MW_HOME=/u01/oracle/Middleware  
export wls_host=bihome.bisoftdiary.com

export OPMN_PORT=9500  
export wls_admin_port=7001  
export wls_mgd_port=9704  
export wls_mgd_name=bi_server1  
export WLS_SINGLE_SERVER_INSTALL_FLAG=  
export BI_URL=http://$wls_host:$wls_mgd_port/analytics  
export PRODUCTION_MODE=true  
export DOMAIN_HOME=$MW_HOME/user_projects/domains/bifoundation_domain  
export WLS_HOME=$MW_HOME/wlserver_10.3  
export INSTANCE_HOME=$MW_HOME/instances/instance1  
export ORACLE_BI_HOME=$MW_HOME/Oracle_BI1  
export ANT_HOME=$MW_HOME/modules/org.apache.ant_1.7.1

$ANT_HOME/bin/ant -f StartStopServices.xml $1 -DMW_HOME=$MW_HOME -DDOMAIN_HOME=$DOMAIN_HOME -DWLS_HOME=$WLS_HOME -DINSTANCE_HOME=$INSTANCE_HOME -DORACLE_BI_HOME=$ORACLE_BI_HOME -DPRODUCTION_MODE=$PRODUCTION_MODE -Dwls_host=$wls_host -Dwls_admin_port=$wls_admin_port -Dwls_mgd_port=$wls_mgd_port -Dwls_mgd_name=$wls_mgd_name -DOPMN_PORT=$OPMN_PORT -DBI_URL=$BI_URL $WLS_SINGLE_SERVER_INSTALL_FLAG

Here you only need to change the first two lines in accordance with your installation path and host name. Don’t forget to make this file executable.
ANT configuration (build) file StartStopServices.xml:


StartStopServices.xml

<?xml version="1.0"?>

<project name="oracle_bi_ee_start" default="start_all">  
    <!-- for now, all prompts and messages are in English -->
    <property name="StartStopServices.lang" value="en"/>

    <property name="wls.java.options" value="" />
    <property name="wls.admin.url" value="t3://${wls_host}:${wls_admin_port}"/>
    <!-- Root lib directories -->
    <property name="wls.modules" location="${MW_HOME}/modules" />
    <property name="wls.server.lib" location="${WLS_HOME}/server/lib" />
    <property name="admin.server.credentials.file" location="${DOMAIN_HOME}/servers/AdminServer/security/boot.properties"/>    
    <property name="managed.server.credentials.file" location="${DOMAIN_HOME}/servers/${wls_mgd_name}/security/boot.properties"/>
    <property name="NODEMANAGER_PORT" value="9556"/>

    <!-- =============================== Classpaths =======================================-->

    <!-- Include all the jars from the various major WLS directories. -->
    <path id="wls.classpath">
        <fileset dir="${wls.modules}">
            <include name="com.bea.core.annogen_1.0.1.0.jar" />
            <include name="com.bea.core.logging_1.0.1.0.jar" />
            <include name="com.bea.core.utils.classloaders_1.0.1.0.jar" />
            <include name="com.bea.core.utils_1.0.1.0.jar" />
        </fileset>
        <fileset dir="${wls.server.lib}">
            <include name="weblogic.jar" />
        </fileset>
    </path>



    <!-- =================================================================== -->
    <!-- Main Targets -->
    <!-- =================================================================== -->

    <target name="start_all" depends ="determine.language, find.or.get.credentials, nodemanager.start, wls.admin.start, wls.wait.alive, del.generated.admin.server.credentials, wls.mgd.start, wls.mgd.wait.alive, del.generated.managed.server.credentials, opmn.start, show_url">
    </target>

    <target name="stop_all" depends="determine.language, set.is.stop.all,find.or.get.credentials, opmn.stop, wls.mgd.stop, wls.wait.mgd.shutdown, del.generated.managed.server.credentials, wls.stop, wls.wait.admin.shutdown, del.generated.admin.server.credentials, nodemanager.stop">
    </target>

    <target name="set.is.stop.all">
        <property name="is.stop.all" value="true"/>
    </target>

    <target name="find.or.get.credentials" depends="get.credentials.available, get.credentials, create.admin.server.credentials.file, create.managed.server.credentials.file">
    </target>

    <target name="get.credentials.available">
        <condition property="admin.server.boot.properties.available">
            <available file="${DOMAIN_HOME}/servers/AdminServer/security/boot.properties"/>
        </condition>

        <condition property="managed.server.boot.properties.available">
            <and>
                <not><isset property="singleserver"/></not>
                <available file="${DOMAIN_HOME}/servers/${wls_mgd_name}/security/boot.properties"/>
            </and>
        </condition>

        <condition property="should.create.credentials">
            <or>
                <and>
                    <isset property="singleserver"/> 
                    <not><isset property="admin.server.boot.properties.available"/></not>
                </and>
                <and>
                    <not><isset property="singleserver"/></not>
                    <or>
                        <not><isset property="admin.server.boot.properties.available"/></not>
                        <not><isset property="managed.server.boot.properties.available"/></not>
                    </or>
                </and>
            </or>            
        </condition>

        <condition property="should.create.admin.server.credentials">
            <and>
                <isset property="should.create.credentials"/>
                <not><isset property="admin.server.boot.properties.available"/></not>
            </and>
        </condition>

        <condition property="should.create.managed.server.credentials">
            <and>
                <isset property="should.create.credentials"/>
                <not><isset property="managed.server.boot.properties.available"/></not>
            </and>
        </condition>

        <condition property="should.get.credentials">
            <or>
                <isset property="should.create.credentials"/>
                <isset property="is.stop.all"/>
            </or>
        </condition>

    </target>

    <target name="get.credentials" if="should.get.credentials">
      <property file="${StartStopServices.properties.file}"/>
      <echo message="${get.credentials.message.warning}"/>

        <input message="Please enter the username of a WebLogic admin user:" addproperty="WLS_USER">
        </input>
        <input message="Please enter the password for WebLogic user ${WLS_USER}:" addproperty="WLS_PW">
            <handler classname="org.apache.tools.ant.input.SecureInputHandler" />
        </input>
    </target>

    <target name="create.admin.server.credentials.file" if="should.create.admin.server.credentials">
        <touch file="${admin.server.credentials.file}"/>
        <echo file="${admin.server.credentials.file}" message="username=${WLS_USER}${line.separator}password=${WLS_PW}"/>
        <property name="admin.server.boot.properties.created" value="true"/>
    </target>

    <target name="create.managed.server.credentials.file" if="should.create.managed.server.credentials">
        <touch file="${managed.server.credentials.file}"/>
        <echo file="${managed.server.credentials.file}" message="username=${WLS_USER}${line.separator}password=${WLS_PW}"/>
        <property name="managed.server.boot.properties.created" value="true"/>
    </target>

    <target name="show_url">
        <echo message="Oracle BI should now be available at ${BI_URL}"/>
        <sleep seconds="10"/>
    </target>

    <!-- =================================================================== -->
    <!-- OPMN Targets -->
    <!-- =================================================================== -->

    <target name="opmn.start">
        <property name="OPMNCTL_EXECUTABLE" value="${INSTANCE_HOME}/bin/opmnctl" />
        <echo level="verbose" message="Starting opmn using opmnctl (at ${OPMNCTL_EXECUTABLE})..." />
        <exec newenvironment="true" executable="${OPMNCTL_EXECUTABLE}" spawn="true" osfamily="unix">
            <arg value="startall" />
        </exec>
        <echo message="Waiting for OPMN managed services to start..." />
        <check_server_listening_on_port port="${OPMN_PORT}" proc="OPMN" />
        <echo message="OPMN has been started." />
    </target>

    <target name="opmn.stop">
        <property name="OPMNCTL_EXECUTABLE" value="${INSTANCE_HOME}/bin/opmnctl" />
        <echo level="verbose" message="Stopping opmn using opmnctl (at ${OPMNCTL_EXECUTABLE})..." />
        <exec newenvironment="true" executable="${OPMNCTL_EXECUTABLE}" spawn="true" osfamily="unix">
            <arg value="stopall" />
        </exec>
        <echo message="Waiting for OPMN managed services to stop..." />
        <check_port_free port="${OPMN_PORT}" proc="OPMN" />
        <echo message="OPMN has been stopped." />
    </target>

    <!-- =================================================================== -->
    <!-- Node Manager Targets -->
    <!-- =================================================================== -->

    <target name="nodemanager.start">
        <property name="NODEMANAGER_EXECUTABLE" value="${WLS_HOME}/server/bin/startNodeManager.sh" />
        <echo level="verbose" message="Starting node manager (at ${NODEMANAGER_EXECUTABLE})..." />

        <exec spawn="true" executable="${NODEMANAGER_EXECUTABLE}" osfamily="unix"/>

        <echo message="Waiting for Node manager service to start..." />
        <check_server_listening_on_port port="${NODEMANAGER_PORT}" />
        <echo message="Node manager has been started." />
    </target>

    <target name="nodemanager.stop">
        <property name="NODEMANAGER_KILL" value="ps aux | grep -e weblogic.NodeManager | awk '{print $2}'|xargs kill -15" />
        <echo message="Stop node manager manually using:" />
        <echo message="${NODEMANAGER_KILL}" />

    </target>
    <!-- =================================================================== -->
    <!-- Node Manager Targets -->
    <!-- =================================================================== -->

    <!-- Start the Admin Server -->
    <target name="wls.admin.start" description="Start WLS Admin Server">
        <echo message="Starting WLS Admin Server at ${WLS_HOME}..." />
        <property name="wls.start.dir" location="${DOMAIN_HOME}/bin/" />
        <property name="java.options" value="-Doracle.home=${ORACLE_BI_HOME} ${wls.java.options}" />
        <property name="post.classpath" value="" />

        <echo level="verbose" message="  Using java options: ${java.options}" />
        <echo level="verbose" message="  Using extra classpath: ${post.classpath}" />

        <exec spawn="true" executable="${DOMAIN_HOME}/bin/startWebLogic.sh" osfamily="unix" dir="${wls.start.dir}">
            <env key="JAVA_OPTIONS" value="${java.options}" />
            <env key="POST_CLASSPATH" path="${post.classpath}" />
        </exec>
    </target>

    <!-- Stop the Admin Server -->
    <target name="wls.stop" if="wls.domain.exists" depends="wls.check.exists" description="Stop WLS">
        <echo message="Stopping WLS Admin Server..." />

        <exec spawn="true" executable="${DOMAIN_HOME}/bin/stopWebLogic.sh" osfamily="unix" dir="${DOMAIN_HOME}/bin">
            <env key="userID" value="${WLS_USER}"/>
            <env key="password" value="${WLS_PW}"/>
            <env key="ADMIN_URL" value="${wls.admin.url}"/>
        </exec>
    </target>

    <!-- Start the Managed Server -->
    <target name="wls.mgd.start" description="Start WLS Managed Server" unless="singleserver">
        <echo message="Starting WLS Managed Server ${wls_mgd_name} ..." />
        <property name="wls.start.dir" location="${MW_HOME}" />
        <property name="bisearch.java.options" value="-Doracle.ecsf.crawl.mode.debug=true -Doracle.ecsf.security.service=oracle.biee.search.security.BISearchSecurityService -Doracle.ecsf.configuration.class=oracle.biee.search.services.BISearchServiceConfiguration -Doracle.biee.search.bisearchproperties=${ORACLE_BI_HOME}/bifoundation/jee/BISearchConfig.properties" />
        <property name="mgd.server.java.options" value="-Doracle.home=${ORACLE_BI_HOME} ${wls.java.options} ${bisearch.java.options} -Dserver.group=obi" />
        <property name="post.classpath" value="" />

        <echo level="verbose" message="  Using java options: ${mgd.server.java.options}" />
        <echo level="verbose" message="  Using extra classpath: ${post.classpath}" />

        <exec spawn="true" executable="${DOMAIN_HOME}/bin/startManagedWebLogic.sh" osfamily="unix" dir="${DOMAIN_HOME}/bin">
            <env key="JAVA_OPTIONS" value="${mgd.server.java.options}" />
            <env key="POST_CLASSPATH" path="${post.classpath}" />
            <env key="SERVER_NAME" value="${wls_mgd_name}" />
            <env key="ADMIN_URL" value="${wls.admin.url}" />
        </exec>
    </target>

    <!-- Stop the Managed Server -->
    <target name="wls.mgd.stop" description="Stop WLS Managed Server" unless="singleserver">
        <echo message="Stopping WLS Managed Server ${wls_mgd_name} ..." />
        <property name="wls.start.dir" location="${MW_HOME}" />
        <property name="bisearch.java.options" value="-Doracle.ecsf.crawl.mode.debug=true -Doracle.ecsf.security.service=oracle.biee.search.security.BISearchSecurityService -Doracle.ecsf.configuration.class=oracle.biee.search.services.BISearchServiceConfiguration -Doracle.biee.search.bisearchproperties=${ORACLE_BI_HOME}/bifoundation/jee/BISearchConfig.properties" />
        <property name="mgd.server.java.options" value="-Doracle.home=${ORACLE_BI_HOME} ${wls.java.options} ${bisearch.java.options} -Dserver.group=obi" />
        <property name="post.classpath" value="" />

        <echo level="verbose" message="  Using java options: ${mgd.server.java.options}" />
        <echo level="verbose" message="  Using extra classpath: ${post.classpath}" />

        <exec spawn="true" executable="${DOMAIN_HOME}/bin/stopManagedWebLogic.sh" osfamily="unix" dir="${wls.start.dir}">
            <arg value="${wls_mgd_name}" />
            <arg value="${wls.admin.url}" />
            <env key="JAVA_OPTIONS" value="${mgd.server.java.options}" />
            <env key="POST_CLASSPATH" path="${post.classpath}" />
        </exec>
    </target>


    <!-- =================================================================== -->
    <!--  Internal targets. -->
    <!-- =================================================================== -->

    <target name="wls.wait.alive" depends="wls.alive">
        <fail if="wls.not.alive">
            Timed out waiting for weblogic to become available at: ${wls_host}:${wls_admin_port}
        </fail>
        <echo message="--> Weblogic Admin Server running: Admin console available at http://${wls_host}:${wls_admin_port}/console..." />
    </target>

    <target name="wls.wait.admin.shutdown" if="wls.domain.exists" depends="wls.admin.shutdown">
        <fail if="wls.stop.timedout" message="Timed out waiting to stop WLS" />
    </target>

    <target name="wls.mgd.wait.alive" depends="wls.mgd.alive">
        <fail if="wls.mgd.not.alive">
            Timed out waiting for weblogic to become available at: ${wls_host}:${wls_mgd_port}
        </fail>
        <echo message="--> WLS Managed Server is running: available at ${wls_host}:${wls_mgd_port}..." />
    </target>

    <target name="wls.wait.mgd.shutdown" unless="singleserver" depends="wls.mgd.shutdown">
        <fail if="wls.mgd.stop.timedout" message="Timed out waiting to stop WLS Managed server "/>      
    </target>

    <target name="wls.check.exists">
        <condition property="wls.server.exists">
            <!-- weblogic.jar must be present -->
            <available file="weblogic.jar" filepath="${WLS_HOME}/server/lib/" />
        </condition>
        <condition property="wls.domain.exists">
            <and>
                <available file="${wls_mgd_name}" type="dir" filepath="${DOMAIN_HOME}/servers" />
                <available file="bin" type="dir" filepath="${DOMAIN_HOME}" />
            </and>
        </condition>
    </target>

    <target name="del.generated.admin.server.credentials" if="should.delete.generated.admin.server.credentials.file">
        <delete file="${admin.server.credentials.file}"/>        
    </target>

    <!-- Checks if the server is up, if not sets the property wls.not.alive -->
    <target name="wls.alive">
        <echo level="verbose" message="--> Checking to see if WLS Admin console is available at http://${wls_host}:${wls_admin_port}/console..." />
        <waitfor checkeveryunit="second" maxwaitunit="second" maxwait="600" checkevery="1" timeoutproperty="wls.not.alive">
         <http url="http://${wls_host}:${wls_admin_port}/console"/>   
        </waitfor>
        <condition property="should.delete.generated.admin.server.credentials.file">
            <and>
                <isset property="wls.not.alive"/>
                <isset property="admin.server.boot.properties.created"/>
            </and>
        </condition>
    </target>

    <!-- Checks if the server is up, if not sets the property wls.not.alive -->
    <target name="wls.admin.shutdown" if="wls.domain.exists">
        <waitfor maxwait="5" maxwaitunit="minute" checkevery="100" timeoutproperty="wls.stop.timedout">
            <not>
                <socket server="${wls_host}" port="${wls_admin_port}" />
            </not>
        </waitfor>
        <condition property="should.delete.generated.admin.server.credentials.file">
            <and>
                <isset property="wls.stop.timedout"/>
                <isset property="admin.server.boot.properties.created"/>
            </and>
        </condition>
    </target>

    <!-- cleans up generated password file if required -->
    <target name="del.generated.managed.server.credentials" if="should.delete.generated.managed.server.credentials.file">
        <delete file="${managed.server.credentials.file}"/>
    </target>

    <!-- Checks if the managed server is up, if not sets the property wls.mgd.not.alive -->
    <target name="wls.mgd.alive" unless="singleserver">
        <echo level="verbose" message="--> Checking to see if WLS Managed Server is available at ${wls_host}:${wls_mgd_port}..." />
        <waitfor checkeveryunit="second" maxwaitunit="second" maxwait="900" checkevery="1" timeoutproperty="wls.mgd.not.alive">
         <http url="http://${wls_host}:${wls_mgd_port}/biservices"/>  
        </waitfor>
        <condition property="should.delete.generated.managed.server.credentials.file">
            <and>
                <isset property="wls.mgd.not.alive"/>
                <isset property="managed.server.boot.properties.created"/>
            </and>
        </condition>
    </target>

    <!-- Checks if the server is up, if not sets the property wls.not.alive -->
    <target name="wls.mgd.shutdown" unless="singleserver">
        <waitfor maxwait="5" maxwaitunit="minute" checkevery="100" timeoutproperty="wls.mgd.stop.timedout">
            <not>
                <socket server="localhost" port="${wls_mgd_port}"/>
            </not>
        </waitfor>
        <condition property="should.delete.generated.managed.server.credentials.file">
            <and>
                <isset property="wls.mgd.stop.timedout"/>
                <isset property="managed.server.boot.properties.created"/>
            </and>
        </condition>
    </target>

    <macrodef name="check_server_listening_on_port" description="Wait for a server to start listening on a port and fail if it does not">
        <attribute name="host" default="localhost" description="Host to check"/>
        <attribute name="port" description="Port to check"/>
        <attribute name="minutes" default="5" description="Time to wait in minutes"/>
        <attribute name="proc" default="[unknown]" description="Name of process"/>
        <attribute name="message" default="Port @{host}:@{port} is not open for process @{proc}" description="Message if port is not open"/>
        <sequential>
            <waitfor maxwaitunit="minute" maxwait="@{minutes}" timeoutproperty="[email protected]{host}[email protected]{port}_free">
               <socket server="@{host}" port="@{port}"/> 
            </waitfor>
            <fail if="[email protected]{host}[email protected]{port}_free" message="@{message}"/>
        </sequential>
    </macrodef>

    <macrodef name="check_port_free" description="Wait for a port to become free and fail if it does not">
        <attribute name="host" default="localhost" description="Host to check"/>
        <attribute name="port" description="Port to check"/>
        <attribute name="minutes" default="5" description="Time to wait in minutes"/>
        <attribute name="proc" default="[unknown]" description="Name of process"/>
        <attribute name="message" default="Port @{host}:@{port} for process @{proc} is not free" description="Message if port is not free"/>
        <sequential>
            <waitfor maxwaitunit="minute" maxwait="@{minutes}" timeoutproperty="[email protected]{host}[email protected]{port}_busy">
                <not>
                  <socket server="@{host}" port="@{port}"/> 
                </not>
            </waitfor>
            <fail if="[email protected]{host}[email protected]{port}_busy" message="@{message}"/>
        </sequential>
    </macrodef>

    <!-- to pick the language (localization) used for messages and prompts -->

    <target name="determine.language" depends="determine.language_prompt" if="StartStopServices.lang">
        <property name="StartStopServices.properties.file" value="StartStopServices.properties.${StartStopServices.lang}"/>
    </target>

    <target name="determine.language_prompt" unless="StartStopServices.lang">
        <!-- get ready for message localization by storing messages in a properties file -->
        <input message="Please enter the desired language code. Chooses are en|de|es|fr|it|ja|ko|pt_BR|zh_CN|zh_TW:" addproperty="StartStopServices.lang" defaultvalue="en">
        </input>
        <property name="StartStopServices.properties.file" value="StartStopServices.properties.${StartStopServices.lang}"/>
    </target>
</project>  


This file doesn't need any changes.

Usage:

Put these scripts wherever you like. Change start_stop.sh to be executable (<chmod +x start_stop.sh) and run the following commands:

Start all services. If any service is already running it’ll be skipped;
./start_stop.sh start_all

Stop all running services
./start_stop.sh stop_all

Stop all opmn managed services
./start_stop.sh opmn.stop

Start all opmn managed services
./start_stop.sh opmn.start

Disclaimer: I'm not the author of this scripts. They are created by Oracle corp. and installed with OBI EE at MS Windows OS only. All I've done was Linux adaptation. Use them at your own responsibility.

linux oracle obiee


Andrew Fomin Profile Picture
Andrew Fomin

OBIEE specialist since 2007 and Oracle Discoverer before. DWH architect, BI enthusiast, blogger. Lazy cats owner. All opinions are my own and not the views of my employer.


Additional Posts
Share This Post
Twitter Google+ Pinterest Facebook
comments powered by HyperComments