Saturday, 9 February 2013

Agile BI with Endeca - Part 3

In previous posts I have looked at the broader picture of what Endeca is and given a brief outline of how to setup an evaluation environment on AWS.  In this article I will cover a few minor details of how to make your evaluation environment a little more friendly.

Starting and Stopping


One of the reasons for using AWS is that you only pay for the resource while you are using it, but its rather inconvenient to have to keep logging in via ssh each time to restart the server and portal.   I'm rather surprised that Oracle did not already provide an init script to do this for you, if they have then I have not been able to find it anywhere.  

Linux servers start and stop services with scripts located in /etc/init.d take a look at a few of the examples in there.  

This is one I have written myself to start, stop and check the status of Endeca.  It is not perfect, and there is lots of scope for improvement but it is a starting point.

#!/bin/bash
#
#       /etc/init.d/endeca
#
# Starts the Endeca services
#
# Author: Mark Melton
#
# chkconfig: - 95 5
#   

# Source function library.
. /etc/init.d/functions

RETVAL=0

#
#       See how we were called.
#

server_path="/oracle/Oracle/Endeca/Server/7.4.0/endeca-server"
server_start_cmd="start.sh"
server_stop_cmd="stop.sh"

portal_path="/oracle/Oracle/Endeca/Discovery/2.4.0/endeca-portal/tomcat-6.0.35/bin"
portal_start_cmd="startup.sh"
portal_stop_cmd="shutdown.sh"


start() {


        # Endeca Server
        #
        # Check if endeca-server is already running
        server_pid=$(ps -ef | grep endeca-server | grep -v grep | awk '{print $2}')
        if [ -z "$server_pid" ]; then
            echo -ne $"Starting Endeca Server\n"
            cd $server_path
            $cmd ./$server_start_cmd >> logs/server.log &
            RETVAL=$?
        else
            echo -ne "endeca_server already running with PID $server_pid\n"
        fi

        # Endeca Portal
        #
        # Check if endeca-portal is already running
        portal_pid=$(ps -ef | grep endeca-portal | grep -v grep | awk '{print $2}')
        if [ -z "$portal_pid" ]; then
            echo -ne $"Starting Endeca Portal\n"
            cd $portal_path
            $cmd ./$portal_start_cmd >> portal.log &
            RETVAL=$?
        else
            echo -ne "endeca_portal already running with PID $portal_pid\n"
        fi                                                                                                                                                                   


        return $RETVAL
}

stop() {
        echo -ne $"Stopping endeca-server\n"
        cd $server_path
        $cmd ./$server_stop_cmd server.log &
        RETVAL=$?
        echo

        if [ ! -z "$RETVAL" ]; then
            echo -ne "There was a problem stopping the endeca-server"                                                                                                        
   
            return $RETVAL
        fi
        cd $portal_path  
        $cmd./$portal_stop_cmd >> portal.log &
        RETVAL=$?

        return $RETVAL
}


restart() {
        stop
        start
}

reload() {
        restart
}

status_at() {
        server_pid=$(ps -ef | grep endeca-server | grep -v grep | awk '{print $2}')
        if [ -z "$server_pid" ]; then
            echo -ne $"Endeca Server is not running\n"
        else
            echo -ne $"Endeca Server is running\n"
        fi

        portal_pid=$(ps -ef | grep endeca-portal | grep -v grep | awk '{print $2}')
        if [ -z "$portal_pid" ]; then
            echo -ne $"Endeca Portal is not running\n"
        else
            echo -ne $"Endeca Portal is running\n"
        fi


}

case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload|restart)
         restart                                                                                                                                                             
        ;;
condrestart)
        if [ -f /var/lock/subsys/wdaemon ]; then
            restart
        fi
        ;;
status)
        status_at
        ;;
*)
        echo $"Usage: $0 {start|stop|restart|condrestart|status}"
        exit 1
esac

exit $?
exit $RETVAL

There is just one more command to run:

# chkconfig endeca on

Now when you reboot your Endeca services should restart automatically.

Location


Just one last thing to make it easier to find your Endeca environment is to use an Elastic IP address.  You can have one elastic IP address associated with a running instance at no charge.  Go to the Elastic IP address tab on your AWS console, request a new Elastic IP address and associate it with your Endeca Instance.  You will now be able to access your Endeca instance on  elastic_ip:8080.  You do have to associate the IP address with the server instance each time you start it up, but this can easily be done through the EC2 console.

It just remains to give your server and stop and start just to make sure that everything is working as expected.


No comments:

Post a Comment