MQ ActiveMQ安装部署和配置

1 资源

资源信息版本号备注
服务器Centos7IP: 192.168.51.4
JRE1.8如果已安装请忽略
activeMQ5.16.1

JRE-1.8 下载

CSDN ActiveMQ下载

官网地址:ActiveMQ下载

2 JDK安装

zookeeper是需要依赖于JDK环境的,如果未安装,可参考博文:

Centos7 离线安装和配置jre1.8

3 安装与配置

3.1 上传服务器

将文件上传到服务器的 /opt/module/software/ActiveMQ 目录

[root@localhost software]# cd /opt/module/software/ActiveMQ/
[root@localhost ActiveMQ]# ll
总用量 62744
-rw-r--r--. 1 root root 64246045 3月  25 09:33 apache-activemq-5.16.1-bin.tar.gz

3.2 解压到指定目录

[root@localhost ActiveMQ]# tar -zxvf apache-activemq-5.16.1-bin.tar.gz
[root@localhost ActiveMQ]# cd /opt/module/software/ActiveMQ/apache-activemq-5.16.1
[root@localhost apache-activemq-5.16.1]# ll
总用量 18236
-rwxr-xr-x. 1 root root 18614883 1月  14 20:58 activemq-all-5.16.1.jar
drwxr-xr-x. 5 root root      147 3月  25 09:35 bin
drwxr-xr-x. 2 root root     4096 3月  25 09:37 conf
drwxr-xr-x. 3 root root       57 3月  25 09:36 data
drwxr-xr-x. 2 root root       76 3月  25 09:35 docs
drwxr-xr-x. 7 root root       71 1月  14 21:00 examples
drwxr-xr-x. 6 root root     4096 3月  25 09:35 lib
-rw-r--r--. 1 root root    40580 1月  14 21:00 LICENSE
-rw-r--r--. 1 root root     3334 1月  14 21:00 NOTICE
-rw-r--r--. 1 root root     2610 1月  14 21:00 README.txt
drwxr-xr-x. 2 root root        6 3月  25 09:36 tmp
drwxr-xr-x. 6 root root       95 3月  25 09:35 webapps
drwxr-xr-x. 3 root root       18 3月  25 09:35 webapps-demo
  • bin存放的是脚本文件
  • conf存放的是基本配置文件
  • data存放的是日志文件
  • docs存放的是说明文档
  • examples存放的是简单的实例
  • lib存放的是activemq所需jar包
  • webapps用于存放项目的目录
  • webapps-demo:activemq使用实例目录。

3.3 安全配置

官方参考地址:http://activemq.apache.org/security.html

3.3.1 控制台安全配置

1 编辑 jetty.xml

[root@localhost conf]# vi jetty.xml 
<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="true" />

确保 authenticate 的值为 true(默认)

2 编辑 jetty-realm.properties

[root@localhost conf]# vi jetty-realm.properties
# username: password [,rolename ...]
admin: admin123, admin
auskat: 123456, admin

注意: 用户名和密码的格式是 => 用户名 : 密码 ,角色名

3.3.2 客户端安全配置

一共分为多种配置,这里介绍两种,普通认证策略和高级认证策略,这里我使用的是 普通认证策略

[root@localhost software]# cd /opt/module/software/ActiveMQ/apache-activemq-5.16.1/conf
[root@localhost conf]# vi activemq.xml

在 conf/activemq.xml 文件中在 broker 标签最后加入以下内容

1 普通认证策略

<plugins> 
  <simpleAuthenticationPlugin> 
    <users> 
      <authenticationUser username="auskat" password="123456" groups="users,admins"/> 
    </users> 
  </simpleAuthenticationPlugin> 
</plugins>

定义了一个auskat用户,密码为123456,角色为 users,admins

2 高级认证策略

<!--使用JAAS插件进行高级认证策略-->
 <jaasAuthenticationPlugin configuration="activemq" />

<authorizationPlugin>
            <map>
                <authorizationMap>
                    <authorizationEntries>
                        <authorizationEntry topic=">" read="admins" write="admins" admin="admins" />
                        <authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
                        <!--authorizationEntry topic="FirstTopic" read="smeall,smeadmin" write="smeadmin" admin="smeall,smeadmin" /-->
                        <authorizationEntry topic="ActiveMQ.Advisory.>" read="admins" write="admins" admin="admins"/>
                        <authorizationEntry queue="ActiveMQ.Advisory.>" read="admins" write="admins" admin="admins"/>
                    </authorizationEntries>
                </authorizationMap>
            </map>
        </authorizationPlugin>

3.3.3 允许远程访问

编辑 jetty.xml

[root@localhost conf]# vi jetty.xml 
 <bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start">
             <!-- the default port number for the web console -->
        <property name="host" value="0.0.0.0"/>
        <property name="port" value="8161"/>
</bean>

host value 修改 value=“0.0.0.0”

3.4 测试启动

3.4.1 启动 ActiveMQ

[root@localhost bin]# cd /opt/module/software/ActiveMQ/apache-activemq-5.16.1/bin
[root@localhost bin]# ./activemq start
INFO: Loading '/opt/module/software/ActiveMQ/apache-activemq-5.16.1//bin/env'
INFO: Using java '/opt/module/haoke/jdk1.8.0_141/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
INFO: pidfile created : '/opt/module/software/ActiveMQ/apache-activemq-5.16.1//data/activemq.pid' (pid '84187')

3.4.2 查看进程

[root@localhost bin]# jps -l
84187 /opt/module/software/ActiveMQ/apache-activemq-5.16.1//bin/activemq.jar

3.4.3 查看状态

[root@localhost bin]# ./activemq status
INFO: Loading '/opt/module/software/ActiveMQ/apache-activemq-5.16.1//bin/env'
INFO: Using java '/opt/module/haoke/jdk1.8.0_141/bin/java'
ActiveMQ is running (pid '84187')

如果出现问题,使用 ./activemq console 查看错误日志

如果是端口占用,使用 lsof -i:8161 查看端口信息,8161是端口号

3.4.4 管理页面

在这里插入图片描述

这里使用 自定义的账号登录 auskat 123456

在这里插入图片描述

3.4.5 停止 ActiveMQ

[root@localhost bin]# ./activemq status stop

4 相关信息

  • 博文不易,辛苦各位猿友点个关注和赞,感谢
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小P聊技术

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值