ActiveMQ安装及配置

1. ActiveMQ安装

下载地址

http://activemq.apache.org/components/classic/download/

这里下载 ActiveMQ 5.14.5,将软件包上传至linux服务器,安装ActiveMQ前需要安装jdk环境。

将 apache-activemq-5.14.5-bin.tar.gz上传至服务器的/opt目录

1.进入安装目录

cd /opt

2.解压软件包

tar xf apache-activemq-5.14.5-bin.tar.gz

3.创建软链接

ln -s /opt/apache-activemq-5.14.5 /opt/activemq

4.软件包目录文件说明

[root@consul1 opt]# ll /opt/activemq
total 15888
-rwxr-xr-x 1 root root 16211254 Aug 1 2018 activemq-all-5.14.5.jar  #jar包
drwxr-xr-x 5 root root 139 Aug 1 2018 bin                           #脚本目录
drwxr-xr-x 2 root root 4096 Aug 2 09:50 conf                        #配置文件
drwxr-xr-x 3 root root 98 Aug 2 2018 data                           #数据文件
drwxr-xr-x 2 root root 73 Aug 1 2018 docs                           #说明文档
drwxr-xr-x 7 root root 66 Aug 1 2018 examples                       #示例
drwxr-xr-x 6 root root 4096 Aug 1 2018 lib                          #依赖jar包
-rw-r--r-- 1 root root 40580 Aug 1 2018 LICENSE              
-rw-r--r-- 1 root root 3334 Aug 1 2018 NOTICE
-rw-r--r-- 1 root root 2610 Aug 1 2018 README.txt
drwxr-xr-x 4 root root 134 Aug 13 2018 tmp
drwxr-xr-x 6 root root 89 Aug 1 2018 webapps                        #系统部署目录
drwxr-xr-x 3 root root 17 Aug 1 2018 webapps-demo                   #demo

 5. 配置文件说明

[root@consul1 opt]# ll activemq/conf

total 88
-rw-r--r-- 1 root root 6444 Aug 2 11:38 activemq.xml                   #主配置文件
-rw-r--r-- 1 root root 6106 Apr 25 2018 activemq.xml.bak
-rw-r--r-- 1 root root 1370 Apr 11 2017 broker.ks
-rw-r--r-- 1 root root 592 Apr 11 2017 broker-localhost.cert
-rw-r--r-- 1 root root 665 Apr 11 2017 broker.ts
-rw-r--r-- 1 root root 1357 Apr 11 2017 client.ks
-rw-r--r-- 1 root root 665 Apr 11 2017 client.ts
-rw-r--r-- 1 root root 1172 Apr 11 2017 credentials-enc.properties
-rw-r--r-- 1 root root 1121 Apr 11 2017 credentials.properties  
-rw-r--r-- 1 root root 962 Apr 11 2017 groups.properties
-rw-r--r-- 1 root root 1011 Apr 11 2017 java.security
-rw-r--r-- 1 root root 1092 Apr 10 2018 jetty-realm.properties        #activemq管理控制台配置文件包括是否开启认证、访问端口等
-rw-r--r-- 1 root root 7791 Apr 10 2018 jetty.xml                     #配置控制台登陆的用户名密码
-rw-r--r-- 1 root root 965 Apr 11 2017 jmx.access
-rw-r--r-- 1 root root 964 Apr 11 2017 jmx.password
-rw-r--r-- 1 root root 3084 Apr 11 2017 log4j.properties
-rw-r--r-- 1 root root 1207 Apr 11 2017 logging.properties
-rw-r--r-- 1 root root 1016 Apr 11 2017 login.config
-rw-r--r-- 1 root root 961 Apr 11 2017 users.properties

6. ActiveMQ安全认证配置

1)控制端安全认证:

ActiveMQ目录conf下jetty.xml:

<bean id="securityLoginService" class="org.eclipse.jetty.security.HashLoginService">
        <property name="name" value="ActiveMQRealm" />
        <property name="config" value="${activemq.conf}/jetty-realm.properties" />
    </bean>

    <bean id="securityConstraint" class="org.eclipse.jetty.util.security.Constraint">
        <property name="name" value="BASIC" />
        <property name="roles" value="admin" />
        <!-- set authenticate=false to disable login -->
        <property name="authenticate" value="true" />
    </bean>
<property name="authenticate" value="true" /> true开启认证,false关闭认证。
ActiveMQ目录conf下jetty-realm.properties:
# Defines users that can access the web (console, demo, etc.)
# username: password [,rolename ...]
test: testtest, admin
#user: user, user

web界面登录用户名和密码:

认证用户名: 认证密码 [,角色名称 ...]

注意: 配置需重启ActiveMQ才会生效。

2)客户端安全认证:

simpleAuthenticationPlugin 认证: 直接把相关的认证插件配置到xml文件中

ActiveMQ目录conf下activemq.xml的broker元素中添加插件:

<plugins>
                <simpleAuthenticationPlugin>
                <users>
                        <authenticationUser username="test" password="hello123" groups="users,admins"
/>
                </users>
                </simpleAuthenticationPlugin>
        </plugins>

重启ActiveMQ, 使配置生效。

7. 启动ActiveMQ

/opt/activemq/bin/activemq start

 

posted @ 2019-08-06 14:15  大脸猫爱吃鱼!!!  阅读(753)  评论(0编辑  收藏  举报