免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2272 | 回复: 0
打印 上一主题 下一主题

分布式架构实战--ActiveMQ的安装与使用(单节点) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2016-12-22 16:36 |只看该作者 |倒序浏览

IP:192.168.4.101   

环境:CentOS 6.6、JDK7

1、  安装JDK并配置环境变量(略)

JAVA_HOME=/usr/local/java/jdk1.7.0_72

2、  下载Linux版的ActiveMQ(当前最新版apache-activemq-5.11.1-bin.tar.gz)

$ wget http://apache.fayea.com/activemq ... q-5.11.1-bin.tar.gz

3、  解压安装

$ tar -zxvf apache-activemq-5.11.1-bin.tar.gz

$ mv apache-activemq-5.11.1 activemq-01

如果启动脚本activemq没有可执行权限,此时则需要授权(此步可选)

$ cd /home/wusc/activemq-01/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 /home/wusc/activemq-01/bin

$ ./activemq start

6、  打开管理界面:http://192.168.4.101:8161


默认用户名和密码为:admin/admin

登录后进入

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

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

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

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

$ vi /home/wusc/activemq-01/conf/activemq.xml

<plugins>

     <simpleAuthenticationPlugin>

     <users>

         <authenticationUser username="wusc" password="wusc.123" groups="users,admins"/>

     </users>

     </simpleAuthenticationPlugin>

</plugins>

定义了一个wusc用户,密码为wusc.123,角色为users,admins

设置admin的用户名和密码:

$ vi /home/wusc/activemq-01/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 /home/wusc/activemq-01/conf/jetty-realm.properties

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

# username: password [,rolename ...]

admin: wusc.123, admin

注意:用户名和密码的格式是

用户名 : 密码 ,角色名

重启:

$ /home/wusc/activemq-01/bin/activemq restart

设置开机启动:

# vi /etc/rc.local

加入以下内容

## ActiveMQ

su - wusc -c '/home/wusc/activemq-01/bin/activemq start'

8、  MQ消息生产者也与消息消费者的Demo样例讲解与演示

样例实现参考项目实战内容:ActiveMQ集群与应用


您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP