安装java环境

/usr/java/jdk1.8.0_51


vi /etc/profile


export JAVA_HOME=/usr/java/jdk1.8.0_51

export CLASSPATH=.:%JAVA_HOME%/lib/dt.jar:%JAVA_HOME%/lib/tools.jar

export PATH=$PATH:$JAVA_HOME/bin


安装apache-activemq

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

 mv /usr/local/apache-activemq-5.13.0/ /usr/local/activemq/

cd /usr/local/activemq/bin


启动activemq服务

/usr/local/activemq/bin/activemq start


查看端口是否有运行程序


[root@localhost bin]# netstat -anpult | grep 61616

tcp        0      0 :::61616                    :::*                        LISTEN

  3576/java

完成后添加开启自启动


[root@localhost bin]# cat /etc/rc.local 

#!/bin/sh

#

# This script will be executed *after* all the other init scripts.

# You can put your own initialization stuff in here if you don't

# want to do the full Sys V style init stuff.



touch /var/lock/subsys/local

/usr/local/activemq/bin/activemq start


测试

配置好后可以登录监控管理页面去看队列情况

 http://192.168.100.15:8161/admin/queues.jsp


登录时出现需要身份验证,有两种解决方案:


1.修改配置文件,不需要验证,编辑jetty.xml文件

cd /usr/local/activemq/conf/

vi jetty.xml (property name="authenticate" value="true")改为(property name="authenticate" value="false")

<bean id="securityConstraint" class="org.eclipse.jetty.util.security.Constraint">

        <property name="name" value="BASIC" />

        <property name="roles" value="user,admin" />

        <!-- set authenticate=false to disable login -->

        <property name="authenticate" value="false" />

    </bean>


2.添加用户名和密码,在conf目录下找到jetty-realm.properties

vi jetty-realm.properties

# Defines users that can access the web (console, demo, etc.)

# username: password [,rolename ...]

admin: admin, admin   (用户名)

user: user, user      (密码)



两种方法如果需要生效重启activemq服务