centos&ubuntu安裝activeMQ并设置为开机自启动

Download apache activemq

activemq 5.14.xx 需要JDK最低版本为1.7
activemq 5.15.xx 需要JDK最低版本为1.8

1 install activemq

mkdir -p /opt/apps
cd /opt/apps

下载 activemq bin

wget http://apache.website-solution.net//activemq/5.14.5/apache-activemq-5.14.5-bin.tar.gz

解压缩到 /usr/local/ 目录下

tar -zxvf apache-activemq-5.14.5-bin.tar.gz -C /usr/local/

建立 activemq 软连接

ln -s /usr/local/apache-activemq-5.14.5/  /usr/local/activemq

取消软连接

rm -rf /usr/local/activemq

or

unlink /usr/local/activemq
cd /usr/local/activemq/bin

run ActiveMQ as a daemon process:

./activemq console

run ActiveMQ as a daemon process:

./activemq start

2. 设置 activemq 为开机自启动服务

2.1 ubuntu

cp /usr/local/activemq/bin/activemq /etc/init.d
vi /etc/init.d/activemq

增加 Default-Start Default-Stop chkconfig

#### BEGIN INIT INFO 
# Provides:             activemq 
# Required-Start:       $remote_fs $syslog 
# Required-Stop:        $remote_fs $syslog 
# Default-Start:        2 3 4 5 
# Default-Stop:         0 6 
# chkconfig: 2345 64 36 
# Short-Description:    ActiveMQ server 
### END INIT INFO 

增加 export JAVA_HOME 、ACTIVEMQ_HOME

# Authors:
# Marc Schoechlin <ms@256bit.org>

# ------------------------------------------------------------------------
# IMPROVED DEBUGGING (execute with bash -x)
# export PS4=' ${BASH_SOURCE}:${LINENO}(${FUNCNAME[0]}) '
#
# Backup invocation parameters
export JAVA_HOME=/usr/local/jdk1.7.0_80
ACTIVEMQ_HOME=/usr/local/activemq
ubuntu 设置开机自启动 
update-rc.d -f activemq  defaults
ubuntu 卸载开机自启动 
update-rc.d -f activemq  remove

service activemq start
service activemq status
service activemq stop

systemctl status activemq.service

2.2 centos

cd /etc/init.d/
vi activemq

添加以下内容到activemq文件中,注意要根据自己的jdk和activemq安装目录修改启动文件中JAVA_HOME和CATALINA_HOME配置参数

#!/bin/sh
#
# /etc/init.d/activemq
# chkconfig: 345 63 37
# description: activemq servlet container.
# processname: activemq 5.14.5

# Source function library.
#. /etc/init.d/functions
# source networking configuration.
#. /etc/sysconfig/network

export JAVA_HOME=/usr/local/jdk1.7.0_80
export ACTIVEMQ_HOME=/usr/local/activemq

case $1 in
    start)
        sh $ACTIVEMQ_HOME/bin/activemq start
    ;;
    stop)
        sh $ACTIVEMQ_HOME/bin/activemq stop
    ;;
    status)
        sh $ACTIVEMQ_HOME/bin/activemq status
    ;;
    restart)
        sh $ACTIVEMQ_HOME/bin/activemq stop
        sleep 1
        sh $ACTIVEMQ_HOME/bin/activemq start
    ;;

esac
exit 0
# 给activemq文件赋执行权限
chmod +x activemq
#添加activemq到service服务中去
chkconfig --add activemq
#设置activemq为开机启动
chkconfig activemq on
#启动activemq
service activemq start
  • qq_43638135
    妲己再美究为妃: 博主没有想过自己接一些私活干吗?我现在还没毕业,但是我也确实听说外挂市场自动化游戏脚本市场挺火热的,并且报酬也很丰厚,但是具体的我也不是很清楚,求解答。 (1个月前 #47楼) 查看回复(2) 举报 回复
    22