Thursday, January 9, 2014

IBM Sametime 9 - Start solidDB as a Service - redhat - script for your liking

On the Video Manager server, which is Linux Only, there´s also an IBM SolidDB database server that comes bundled with the VMGR installation.

When restarting the VMGR, which is WebSphere based, you should also restart the solidDB, according to this technote: http://www-01.ibm.com/support/docview.wss?uid=swg21649416

The VMGR websphere server has a startup script that you can enable to launch at boot-time just by typing in the command:
cd /etc/init.d
chkconfig STMediaServer_was.init on
So, in order for me to achieve a solidDB auto-startup when the server boots, and also, making it easier for me to stop and start the solidDB server, I created this script:

Note: The script has to be stored in the "/etc/init.d" folder.
The script file name is: "soliddb"
#!/bin/tcsh
# chkconfig: 2345 80 30
# description: SOLIDDB-service Service
# Created by @robertfarstad, http://blog.robertfarstad.com

setenv USER "admin"
setenv PASS "admin"
setenv SERVER "tcp localhost 2315"
setenv STOPARGS "stopargs.sql"
setenv PTH "/opt/solidDB/soliddb-7.0/bin/"

cd $PTH

setenv SERVICE_PID `ps aux | grep standalone | grep -v grep | awk '{print $2}'`;
echo $SERVICE_PID

if (start == $1) then
    if($SERVICE_PID) then
        echo "-----------> SOLIDB-server is already running";
    else
        echo "-----------> SOLIDDB is not running";
        echo "-----------> SOLIDDB-server starting";
        /opt/solidDB/soliddb-7.0/bin/solid -c /opt/solidDB/soliddb-7.0/eval_kit/standalone
        echo "-----------> SolidDB started";
    endif
endif

if (stop == $1) then
    if ($SERVICE_PID) then
        echo "------------> SOLIDDB-service stopping";
        ./solsql "$SERVER" $USER $PASS $STOPARGS
        echo "------------> Waiting for server to stop";
        sleep 1;
        echo ".";
        sleep 1;
        echo "..";
        sleep 1;
        echo "...";
        sleep 1;
        echo "....";
        sleep 1;
        echo ".....";
        sleep 1;
        echo "......";
        sleep 1;
        echo ".......";
        sleep 1;
        echo "........";
        sleep 1;
        echo ".........";
        sleep 1;
        echo "..........";
        sleep 1;
        echo "...........";

        echo "------------> SOLIDDB-service stopped";
    else
        echo "------------> SolidDB already stopped";
    endif
endif

if(restart == $1) then
    if($SERVICE_PID) then
        echo "-------------> SOLIDB-server is already running";
        echo "-------------> Stopping SOLIDDB";
        ./solsql "$SERVER" $USER $PASS $STOPARGS
        echo "-------------> Pausing for 20 secs before restarting";
        sleep 20;

        echo "-------------> Starting SOLIDDB";
        /opt/solidDB/soliddb-7.0/bin/solid -c /opt/solidDB/soliddb-7.0/eval_kit/standalone
        echo "-------------> SolidDB started";
    else
        echo "-------------> SOLIDDB is not running";
        echo "-------------> SOLIDDB-service is starting";
        /opt/solidDB/soliddb-7.0/bin/solid -c /opt/solidDB/soliddb-7.0/eval_kit/standalone
        echo "-------------> SolidDB started";
    endif
endif

if (status == $1) then
    if($SERVICE_PID) then
        echo "-------------> SOLIDDB Server (pid $SERVICE_PID) is running...";
    else
        echo "-------------> SOLIDDB-Server is not running";
    endif
endif

There´s a reference to a file "stopargs.sql" in this script. This file must be created and stored in the "/opt/solidDB/soliddb-7.0/bin/" directory.

The content of the file is this:
admin command 'shutdown force';
exit;
After the "soliddb" script and the stopargs.sql file is created, you have to run the following commands to enable this as a service

cd /etc/init.d
chkconfig --add soliddb
chkconfig soliddb on
Now you can run the following commands in order to stop/start/restart/check status of the soliddb server:
service soliddb status
service soliddb start
service soliddb stop
service soliddb status
And also, restarting the linux redhat server will autostart the SolidDB server.

Hope this was helpful for you guys. Cheers.


6 comments:

kbild said...

Thank you Robert, very helpful!
Cheers
Klaus

Robert Farstad said...

My pleasure, Klaus :-)

MR said...

Hi Robert,

You don't really need the stopargs.sql file as you can pass a command to solsql on the command line. Like so:

solsql -e "admin command 'shutdown force'" "$SERVER" $USER $PASS

Robert Farstad said...

Hi there.
Thanks! Will try that one.

Matteo Bisi said...

Thank you Robert !

Robert Farstad said...

It worked. :-)