1.下載ActiveMQ
wget https://archive.apache.org/dist/activemq/5.15.12/apache-activemq-5.15.12-bin.tar.gz
如果下載比較慢,可以進入官網下載,如下:
http://activemq.apache.org/components/classic/download/
然后將下載好的壓縮包上傳到linux環境下
2.安裝ActiveMQ
安裝路徑如下:/usr/software/activemq
進入/usr/software/activemq目錄下,解壓activeMQ
[root@localhost Desktop]# cd /usr/software/activemq
[root@localhost activemq]# tar -xzvf apache-activemq-5.15.12-bin.tar.gz
3.啟動ActiveMQ
進入/usr/software/activemq/apache-activemq-5.15.12/bin/linux-x86-64目錄下,啟動activeMQ
[root@localhost activemq]# cd /usr/software/activemq/apache-activemq-5.15.12/bin/linux-x86-64
[root@localhost linux-x86-64]# ./activemq start
4.開放端口
修改防火牆開啟activemq端口8161(管理平台端口)和61616(通訊端口)
[root@localhost linux-x86-64]# vi + /etc/sysconfig/iptables
#添加下面兩行
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8161 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 61616 -j ACCEPT
重啟防火牆
service iptables restart
[root@localhost linux-x86-64]# service iptables restart
5.驗證
http://140.143.26.129:8161/admin/index.jsp
用戶名:admin
密碼:admin
說明:activemq正常啟動后停止:
activemq正常啟動后,訪問localhost:8161/admin
異常,並且./bin/activemq status
顯示ActiveMQ not running
,即ActiveMQ當前是停止狀態。
但在啟動時日志輸出是正常的。
分析解決
在activemq目錄下運行 ./bin/activemq console
會以調試模式啟動,並將日志輸出到當前頁面。
運行后報錯如下:
這是因為jdk版本與mq 不兼容導致的,需要改到jdk1.8以上;
再次在activemq目錄下運行 ./bin/activemq console
以調試模式啟動,並將日志輸出到當前頁面。
運行后報錯如下:
Caused by: java.io.IOException: Failed to bind to server socket: amqp://0.0.0.0:5672?maximumConnections=1000&wireformat.maxFrameSize=104857600 due to: java.net.BindException: Address already in use (Bind failed)
端口5672已被占用,因為我本機已經啟動了RabbitMQ占用了端口5672。
修改ActiveMQ 5672端口
打開ActiveMQ下的 conf/activemq.xml 查找5672並將其改為其他沒有被使用的端口例如:35672。
重啟ActiveMQ,訪問localhost:8161/admin 正常。