linux下安装activeMQ

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 正常。

原文地址:https://www.cnblogs.com/pinghengxing/p/12593547.html