我的mq放在了/opt以下操作均以mq在/opt文件下操作,可根据自己实际安装目录做修改
1、复制activemq文件到/etc/init.d/下并进入/etc/init.d/下
cp /opt/activemq/bin/activemq /etc/init.d/
cd /etc/init.d/
2、查看init.d目录下:
3、编辑activemq文件:
vim activemq
添加如下配置: export JAVA_HOME和ACTIVEMQ_HOME按实际目录写
### BEGIN INIT INFO
# Provides: activemq
# Required-Start: $remote_fs $network $syslog
# Required-Stop: $remote_fs $network $syslog
# Default-Start: 3 5
# Default-Stop: 0 1 6
# Short-Description: Starts ActiveMQ
# Description: Starts ActiveMQ Message Broker Server
### END INIT INFO
export JAVA_HOME=/usr/java/deafult
ACTIVEMQ_HOME=/opt/activemq
保存文件退出。
4、添加activemq到服务列表:
chkconfig --add activemq
5、查看是否添加成功
chkconfig --list
好了,就可以使用service activemq start启动activemq,service activemq stop停止
6、 加入开机自启动
chkconfig activemq on