ActiveMQ 的安装与使用(单节点)

环境:CentOS6.6、JDK8

1.下载:http://archive.apache.org/dist/activemq/5.11.1/apache-activemq-5.11.1-bin.tar.gz


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


3、 下载或上传 Linux 版的 ActiveMQ(可按实际情况使用新一点的版本) $ cd /root/install


4、 解压安装
$ tar -zxvf apache-activemq-5.11.1-bin.tar.gz

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

$ cd /root/install/activemq-01/bin/

$ chmod 755 ./activemq


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

扫描二维码关注公众号,回复: 4183883 查看本文章


5、 启动
$ cd /root/install/activemq-01/bin

$ ./activemq start

6.打开管理界面

默认用户名和密码为: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="fajun" password="fajun.com" groups="users,admins"/>
    </users>
  </simpleAuthenticationPlugin>
</plugins> 

定义了一个 fajun用户,密码为 fajun.com ,角色为 users,admins
设置 admin 的用户名和密码: $ vi /root/install/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 /root/install/activemq-01/conf/jetty-realm.properties

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


重启:
$ /root/install/activemq-01/bin/activemq restart

猜你喜欢

转载自www.cnblogs.com/wangfajun/p/10000176.html