Centos6.5 下的 ActiveMQ 5.14.2 的安裝與配置
阿新 • • 發佈:2019-02-15
step 1) 下載ActiveMQ並解壓移到 /usr/local目錄下
cd /opt
wget http://mirrors.cnnic.cn/apache//activemq/5.14.2/apache-activemq-5.14.2-bin.tar.gz
tar zxvf apache-activemq-5.14.2-bin.tar.gz
mv apache-activemq-5.14.2 /usr/local/
ln -s /usr/local/apache-activemq-5.14.2 /usr/local/activemq
step 2) 建立activemq 使用者並賦給目錄許可權
adduser activemq chown -R activemq:activemq /usr/local/activemq
step 3) 安裝ActiveMQ
su activemq
cd /usr/local/activemq
bin/activemq setup ./conf
step 4) 配置成服務
vi /usr/local/activemq/bin/activemq
在第二行加入如下:# chkconfig: - 64 36
在"EXEC_OPTION="下加入如下內容,配置activemq的啟動使用者ACTIVEMQ_USER="activemq"
配置服務與開機啟動
ln -s /usr/local/activemq/bin/activemq /etc/init.d/activemq chkconfig activemq on
step 5)配成ActiveMQ的使用者組與許可權
vi /usr/local/activemq/conf/activemq.xml
找到節點:beans>broker>plugins 加入如下內容<!-- use JAAS to authenticate using the login.config file on the classpath to configure JAAS --> <jaasAuthenticationPlugin configuration="activemq" /> <authorizationPlugin> <map> <authorizationMap> <authorizationEntries> <authorizationEntry topic="ActiveMQ.Advisory.>" write="all" read="all" admin="all" /> <authorizationEntry queue=">" write="producers" read="consumers" admin="admins,consumers" /> </authorizationEntries> <tempDestinationAuthorizationEntry> <tempDestinationAuthorizationEntry write="admin" read="admin" admin="admin" /> </tempDestinationAuthorizationEntry> </authorizationMap> </map> </authorizationPlugin>
剩下的就是管理ActiveMQ使用者(users.properties)與組 (groups.properties)了,這裡略過,
有個巨坑,注意:如果開啟了web控制檯與需要使用REST API,那 conf/jetty-realm.properties 裡的賬戶密碼需要與users.properties的密碼完全一致(還未找到其它解決方案),不然呼叫Rest API的許可權會有問題。
step 6)啟動ActiveMQ服務
service activemq start
參考:http://activemq.apache.org/security.html