博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
activemq的安装与使用
阅读量:6948 次
发布时间:2019-06-27

本文共 2273 字,大约阅读时间需要 7 分钟。

一、activemq的安装

环境:CentOS 6、JDK8

1、 确保系统已安装了可用的jdk版本
2、 从网上下载 Linux 版的 ActiveMQ( apache-activemq-5.11.1-bin.tar.gz),然后使用xftp上传到linux虚拟机已经建好的文件夹下

3、 解压安装

# tar -zxvf apache-activemq-5.11.1-bin.tar.gz
# mv apache-activemq-5.11.1 activemq
如果启动脚本 activemq 没有可执行权限,此时则需要授权(此步可选)
# cd activemq/bin/
# chmod 755 ./activemq
4、 防火墙中打开对应的端口
ActiveMQ 需要用到两个端口
一个是消息通讯的端口(默认为 61616)
一个是管理控制台端口(默认为 8161)可在 conf/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>
# vi /etc/sysconfig/iptables
添加:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 61616 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8161 -j ACCEPT
重启防火墙:
 service iptables restart
5、 启动
# cd /software/activemq/bin
# ./activemq start
6、 打开管理界面:http://192.168.152.129:8161/    首次进入默认用户名和密码为:admin/admin

7、 安全配置(消息安全)

ActiveMQ 如果不加入安全机制的话,任何人只要知道消息服务的具体地址(包括 ip,端口,消息地址
[队列或者主题地址],), 都可以肆无忌惮的 发送、 接收消息。 关 于 ActiveMQ 安装配置
http://activemq.apache.org/security.html

ActiveMQ 的消息安全配置策略有多种,我们以简单授权配置为例:

在 conf/activemq.xml 文件中在 broker 标签最后加入以下内容即可:
# vi /software/activemq/conf/activemq.xml

<plugins>

<simpleAuthenticationPlugin>
<users>
<authenticationUser username="lgs" password="lgs.123" groups="users,admins"/>
</users>
</simpleAuthenticationPlugin>
</plugins>
定义了一个 lgs用户,密码为 lgs.123,角色为 users,admins

设置 admin 的用户名和密码:

# vi /software/activemq/conf/jetty.xml
<bean id="securityConstraint" class="org.eclipse.jetty.util.security.Constraint">
<property name="name" value="BASIC" />
<property name="roles" value="admin" />
<property name="authenticate" value="true" />
</bean>
确保 authenticate 的值为 true(默认)

控制台的登录用户名密码保存在 conf/jetty-realm.properties 文件中,内容如下:

# vi /software/activemq/conf/jetty-realm.properties
# Defines users that can access the web (console, demo, etc.)
# username: password [,rolename ...]
admin: admin, admin
注意:用户名和密码的格式是
用户名 : 密码 ,角色名

重启:

# vi /software/activemq/bin/activemq restart
设置开机启动:
# vi /etc/rc.local
加入以下内容
## ActiveMQ
su - lgs -c '/software/activemq/bin/activemq start

8.demo代码在个人githup仓库上(https://github.com/leeSmall),欢迎大家fork,一起交流学习

 

转载于:https://www.cnblogs.com/leeSmall/p/7529152.html

你可能感兴趣的文章
install ubuntu tweak on ubuntu lts 10.04,this software is created by zhouding
查看>>
Objective-C中一种消息处理方法performSelector: withObject:
查看>>
JSP实现分页显示
查看>>
关注HTML5安全
查看>>
ios中Pldatabase的用法(4)
查看>>
Leetcode: Search in Rotated Sorted Array
查看>>
windows上配置git
查看>>
新型智能芯片nxp----嗯质朴
查看>>
使用事件捕获实时捕获img是否加载完毕, 实现iframe内容高度自动适应
查看>>
Mysql 分组排序
查看>>
论文撰写及排版流程总结
查看>>
Underscore.js (1.7.0)-函数预览
查看>>
Sublime 插件补充
查看>>
word2013 如何套用模版
查看>>
Objective-C 与JAVA的SHA1/HmacSHA1加密算法实现
查看>>
Android Gradle 自定义Task 详解
查看>>
【nodejs】FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
查看>>
基于.net2 的CAD 绘图控件virtualGraph
查看>>
heroku logs乱码
查看>>
史上最全最强SpringMVC详细示例实战教程
查看>>