演示環境: Centos8、jdk8、activemq5.15.8
下載地址:
http://activemq.apache.org/activemq-5158-release.html
http://mirror.centos.org/centos/
https://www.oracle.com/java/technologies/javase-jdk8-downloads.html
https://www.oracle.com/cn/java/technologies/javase-jdk8-downloads.html
解壓: tar -zxvf apache-activemq-5.15.8-bin.tar.gz -C /var
修改目錄名稱 mv /var/apache-activemq-5.15.8/ /var/activemq/
啓動: ./bin/activemq start
停止:./bin/activemq stop
做成系統服務
1、創建一個systemd服務文件:vi /usr/lib/systemd/system/activemq.service
2、 放入內容
[Unit]
Description=ActiveMQ service
After=network.target
[Service]
Type=forking
ExecStart=/var/activemq/bin/activemq start
ExecStop=/var/activemq/bin/activemq stop
User=root
Group=root
Restart=always
RestartSec=9
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=activemq
[Install]
WantedBy=multi-user.target
3、 找到java命令所在的目錄 whereis java
4、設置activemq配置文件/var/activemq/bin/env中的JAVA_HOME
# Location of the java installation
# Specify the location of your java installation using JAVA_HOME, or specify the
# path to the "java" binary using JAVACMD
# (set JAVACMD to "auto" for automatic detection)
JAVA_HOME="/usr/local/java/jdk1.8.0_181"
JAVACMD="auto"
5、 通過systemctl管理activemq啓停
- 啓動activemq服務:
systemctl start activemq
- 查看服務狀態:
systemctl status activemq
- 創建軟件鏈接:
ln -s /usr/lib/systemd/system/activemq.service /etc/systemd/system/multi-user.target.wants/activemq.service
- 開機自啓:
systemctl enable activemq
- 檢測是否開啓成功(enable):
systemctl list-unit-files |grep activemq
6、 防火牆配置,Web管理端口默認爲8161,通訊端口默認爲61616
- 添加並重啓防火牆
firewall-cmd --zone=public --add-port=8161/tcp --permanent
firewall-cmd --zone=public --add-port=61616/tcp --permanent
systemctl restart firewalld.service
- 或者直接關閉防火牆:
systemctl stop firewalld.service
默認用戶名密碼 admin/admin
設置ActiveMQ的訪問密碼
1、設置ActiveMQ的訪問密碼,以提高ActiveMQ的安全性
2、在ActiveMQ的conf目錄的activemq.xml中添加賬號密碼
<!-- 添加訪問ActiveMQ的賬號密碼 -->
<plugins>
<simpleAuthenticationPlugin>
<users>
<authenticationUser username="zhangsan" password="123" groups="users,admins"/>
</users>
</simpleAuthenticationPlugin>
</plugins>