LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 08-30-2010, 05:32 AM   #1
kapila_sr
Member
 
Registered: Jul 2008
Posts: 33

Rep: Reputation: 15
Add new service on RHEL5.4


Hi

I'm developing simple transaction switch using java socket programming and running operating system RHEL5.4 . Now it is completely done and working fine. So I have written the simple shell script to run it on background.


runr.sh

Code:
#!/bin/sh
#runr.sh
Today=$(date +%F)
sh /opt/EpicTle/tle/run.sh >/root/.epicline/logs/debug/$Today.console.out 2>&1 &
where run.sh

Code:
#!/bin/sh
 
export JAVA_HOME=/opt/EpicTle/java1.6
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$PATH:/opt/PTK/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/PTK/lib
export MANPATH=$MANPATH:/opt/PTK/man/man1
export TLE_HOME=/root/les
export PATH=$TLE_HOME/config:$TLE_HOME/run:$PATH
 
cd /opt/EpicTle/tle
java -jar -Xms500M -Xmx1500M  epictle.jar
where epictle.jar is the my application

When I run 'runr.sh', actually it will run on background and server will response correctly.


Now I wanted to run it as linux service, so Again I wrote the shell script which put it into etc/init.d

This is my starting shell script


epict

Code:
#!/bin/sh
#
# epict        Starts the epict Daemon
#
# chkconfig:   2345 25 88
# description:Epic_TLE is the server which can be applied for a banking system
 
# processname: epict
#
### BEGIN INIT INFO
# Provides: epict
# Should-Start: $syslog openct
# Should-Stop: $syslog openct
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Epic_TLE  daemon
# Description: Epic_TLE is the server which can be applied for a banking system
### END INIT INFO
. /etc/rc.d/init.d/functions
# See how we were called.
 
 
export JAVA_HOME=/opt/EpicTle/java1.6
export PATH=$PATH:$JAVA_HOME/bin
export PATH=$PATH:/opt/PTK/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/PTK/lib
export MANPATH=$MANPATH:/opt/PTK/man/man1
export TLE_HOME=/root/les
export PATH=$PATH:$TLE_HOME/config:$TLE_HOME/run
 
case "$1" in
  start)
 
        if ps ax | grep -v grep | grep epictle > /dev/null
        then
                echo "epict already is running........."
 
        else
                echo -n "Starting epict: "
                daemon lnrunr
                sleep 5
                RETVAL=$?
                echo
                [ $RETVAL = 0 ] && touch /var/lock/subsys/epict
                sleep 10
        fi
        ;;
 
 stop)
        echo -n "Shutting down epict: "
        killproc epict
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/epict /var/run/epict.pid
        ;;
 
  status)
        status epict
        ;;
  restart)
        $0 stop
        sleep 10
        $0 start
        sleep 5
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
esac
 
exit 0

where lnrunr

ls -S /opt/EpicTle/tle/runr.sh /root/les/run/lnrunr

and add the '/root/les/run/' to PATH variable

In fact, Now I can use

service epict start , stop , status and restart

those are working fine.


Now I have used linux HA to make a backup server. So on HA configuration, I have added the my 'epict' service

I will note those servers as

Active
Passive

for convenient explaining


In fact, When Active server is down, the 'epict' service will move to the Passive server and getting start the 'epict' on passive server.

But my issue is,

When epict service stop manually (using 'service epict stop') on active server, Linux HA is not detecting its status it shows still running statues on HA gui panel but actually epict has already downed. But when I test with like 'httpd' service, HA shows the httpd has downed on HA gui. Then it will re-try to start 3 attempts (according to my configuration) to restart if not it will move to the passive server. Actually that is the thing which I wanted to apply for the 'epict' service as well.

Can you tell me what is the wrong with me or is it possible for java application ?

How to HA is monitoring the status of services ?


Best regards
-Kapila
 
Old 09-01-2010, 12:19 AM   #2
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 101Reputation: 101
Are you using heartbeat? Could you please post the steps which you did and related configuration files?
 
Old 09-02-2010, 10:52 PM   #3
kapila_sr
Member
 
Registered: Jul 2008
Posts: 33

Original Poster
Rep: Reputation: 15
hi

Yes I'm using heartbeat.

I'm using the GUI (hb_gui) to configure the node and everything.

/etc/ha.d/ha.cf

logfile /var/log/ha-log
logfacility local0
keepalive 500ms
deadtime 2
initdead 5
ucast eth1 192.168.1.124
udpport 694
auto_failback on
crm yes
node tlenode1.epiclanka.net tlenode2.epiclanka.net
autojoin any

/var/lib/heartbeat/crm/cib.xml

<cib admin_epoch="0" have_quorum="true" ignore_dtd="false" num_peers="2" cib_feature_revision="2.0" crm_feature_set="2.0" generated="true" epoch="914" ccm_transition="8" dc_uuid="c4ce3cbd-b33f-4ad4-bf2d-8792ee72de33" num_updates="49" cib-last-written="Thu Sep 2 19:41:32 2010">
<configuration>
<crm_config>
<cluster_property_set id="cib-bootstrap-options">
<attributes>
<nvpair id="cib-bootstrap-options-dc-version" name="dc-version" value="2.1.4-node: aa909246edb386137b986c5773344b98c6969999"/>
<nvpair id="cib-bootstrap-options-last-lrm-refresh" name="last-lrm-refresh" value="1283426036"/>
</attributes>
</cluster_property_set>
</crm_config>
<nodes>
<node id="e49b1e30-0559-4a56-b86b-d8a0e4e0d694" uname="node2.tle.epiclanka.net" type="normal">
<instance_attributes id="nodes-e49b1e30-0559-4a56-b86b-d8a0e4e0d694">
<attributes>
<nvpair id="standby-e49b1e30-0559-4a56-b86b-d8a0e4e0d694" name="standby" value="off"/>
</attributes>
</instance_attributes>
</node>
<node id="670b51ac-1cf7-48ac-8c92-b49c2662ba4d" uname="tlenode1.epiclanka.net" type="normal">
<instance_attributes id="nodes-670b51ac-1cf7-48ac-8c92-b49c2662ba4d">
<attributes>
<nvpair id="standby-670b51ac-1cf7-48ac-8c92-b49c2662ba4d" name="standby" value="off"/>
</attributes>
</instance_attributes>
</node>
<node id="c4ce3cbd-b33f-4ad4-bf2d-8792ee72de33" uname="tlenode2.epiclanka.net" type="normal">
<instance_attributes id="nodes-c4ce3cbd-b33f-4ad4-bf2d-8792ee72de33">
<attributes>
<nvpair id="standby-c4ce3cbd-b33f-4ad4-bf2d-8792ee72de33" name="standby" value="off"/>
</attributes>
</instance_attributes>
</node>
</nodes>
<resources>
<group id="tle">
<primitive class="ocf" type="IPaddr" provider="heartbeat" id="ip">
<instance_attributes id="ip_instance_attrs">
<attributes>
<nvpair id="16e26b03-8735-49de-a8ab-3bdd2bd31585" name="ip" value="192.168.1.125"/>
</attributes>
</instance_attributes>
<meta_attributes id="ip_meta_attrs">
<attributes/>
</meta_attributes>
<operations>
<op id="op_ip_mo" name="monitor" description="op_ip_mo" interval="5s" timeout="60s" start_delay="1s" disabled="false" role="Started"/>
</operations>
</primitive>
<meta_attributes id="tle_meta_attrs">
<attributes/>
</meta_attributes>
<instance_attributes id="tle_instance_attrs">
<attributes/>
</instance_attributes>
<primitive id="epict" class="lsb" type="epict" provider="heartbeat">
<meta_attributes id="epict_meta_attrs">
<attributes>
<nvpair id="epict_metaattr_target_role" name="target_role" value="started"/>
</attributes>
</meta_attributes>
<operations>
<op id="op_tle_mo" name="monitor" interval="15" timeout="15" start_delay="15" prereq="fencing"/>
</operations>
</primitive>
</group>
</resources>
<constraints>
<rsc_location id="location_node2" rsc="tle">
<rule id="prefered_location_node2" score="1" boolean_op="or">
<expression attribute="#uname" id="02d7f3f5-1f03-41b6-9cca-7fafa4f701ef" operation="eq" value="tlenode2.epiclanka.net"/>
</rule>
</rsc_location>
<rsc_location id="location_node1" rsc="tle">
<rule id="prefered_location_node1" score="2" boolean_op="or">
<expression attribute="#uname" id="b62940ee-ab2b-486b-86a3-ece1020d12da" operation="eq" value="tlenode1.epiclanka.net"/>
</rule>
</rsc_location>
</constraints>
</configuration>
</cib>




Please explain me how to check the status of service ? Is it checking the pid file or lock file or anything ?. What I am saying like that, I will think that something missing in my service shell script.


Thanks and regards
-Kapila
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How To Add RPMForge Repo to RHEL5? carlosinfl Red Hat 3 10-12-2010 05:40 AM
RHEL5,4 software load balancing for apache web service machielr Linux - Software 2 07-08-2010 07:00 AM
Unable to start up Imap/Pop3 Service with Dovecot on RHEL5 and Postfix 2.3.3 bono00 Linux - Enterprise 1 05-04-2009 12:47 PM
HOW to add RX Record in RHEL5 mail2mphani Linux - Newbie 4 03-05-2009 11:04 AM
how to add service in service list akamol Linux - Software 2 07-20-2006 01:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration