1. 程式人生 > >activeMQ的安裝--單機版

activeMQ的安裝--單機版

一、單機版

1、 安裝 JDK 並配置環境變數(略)

2、下載apache-activemq-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>

5、 啟動
$ cd /home/wusc/activemq-01/bin
$ ./activemq start

啟動後訪問路徑:http://ip:8161

注:預設密碼:admin/admin

6、安全配置(訊息安全)
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>
</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
注意:使用者名稱和密碼的格式是
使用者名稱 : 密碼 ,角色名