Creating a Unix Service for ActiveMQ

Below are steps to make ActiveMQ a Linux Daemon on Red Hat 4 ES.

It's based on this article.

Alternatively, you could also use the Java Service Wrapper implementation, refer to the Java Service Wrapper Page for more details.

Settings

JAVA_HOME = /opt/java/jdk1.5.0_06
ActiveMQ = /opt/activemq/incubator-activemq-4.0

Installation

Sun Java JDK

1. Install Sun Java JDK on /opt/java/ directory.

2. Create a shortcut to JDK directory:

sudo ln -s /opt/java/jdk1.5.0_06 /opt/java/java

ActiveMQ

1. Install ActiveMQ on /opt/activemq/ directory.

2. Make ActiveMQ startup and shutdown scripts executable:

sudo chmod +x /opt/activemq/incubator-activemq-4.0/bin/activemq
sudo chmod +x /opt/activemq/incubator-activemq-4.0/bin/shutdown

ActiveMQ as Linux Daemon

1. Create activemq user:

sudo /usr/sbin/useradd activemq

2. Create ActiveMQ startup script /home/activemq/activemqstart.sh with the
following content:

#!/bin/bash
export JDK_HOME=/opt/java/java
export JAVA_HOME=/opt/java/java
/opt/activemq/incubator-activemq-4.0/bin/activemq &

3. Make /home/activemq/activemqstart.sh executable:

sudo chmod +x /home/activemq/activemqstart.sh

4. Create ActiveMQ shutdown script /home/activemq/activemqstop.sh with the
following content:

#!/bin/bash
export JDK_HOME=/opt/java/java
export JAVA_HOME=/opt/java/java
/opt/activemq/incubator-activemq-4.0/bin/shutdown

5. Make /home/activemq/activemqstop.sh executable:

sudo chmod +x /home/activemq/activemqstop.sh

6. Create ActiveMQ Linux service configuration script /etc/init.d/activemq
with the following content:

#!/bin/bash
#
# activemq       Starts ActiveMQ.
#
#
# chkconfig: 345 88 12
# description: ActiveMQ is a JMS Messaging Queue Server.
### BEGIN INIT INFO
# Provides: $activemq
### END INIT INFO

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

[ -f /home/activemq/activemqstart.sh ] || exit 0
[ -f /home/activemq/activemqstop.sh ] || exit 0

RETVAL=0

umask 077

start() {
       echo -n $"Starting ActiveMQ: "
       daemon /home/activemq/activemqstart.sh
       echo
       return $RETVAL
}
stop() {
       echo -n $"Shutting down ActiveMQ: "
       daemon su -c /home/activemq/activemqstop.sh activemq
       echo
       return $RETVAL
}
restart() {
       stop
       start
}
case "$1" in
 start)
       start
       ;;
 stop)
       stop
       ;;
 restart|reload)
       restart
       ;;
 *)
       echo $"Usage: $0 {start|stop|restart}"
       exit 1
esac

exit $?

7. Enable ActiveMQ service configuration as Linux Daemon:

sudo chmod +x /etc/init.d/activemq
sudo /sbin/chkconfig --add activemq
sudo /sbin/chkconfig activemq on

8. Restart the server.

Note: activemq-data is being created in "/" root directory. I have to
explicitly set the activemq-data location in activemq.conf

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值