ActiveMQ无法启动或无法进入8161
作者:互联网
项目场景:
只有一个模块需要用到mq,于是选择ActiveMQ代替过于重型的RabbitMQ
问题描述:
问题1: 刚装好activeMQ,启动后无法连接8161
问题2: ./activemq start后./activemq status显示ActiveMQ not running
maverick@Maverick bin % ./activemq start
INFO: Loading '/opt/homebrew/Cellar/activemq/5.16.3/libexec//bin/env'
INFO: Using java '/opt/homebrew/opt/openjdk/bin/java'
INFO: Starting - inspect logfiles specified in logging.properties and log4j.properties to get details
;: line 2: /opt/homebrew/Cellar/activemq/5.16.3/libexec//data/activemq.pid: Permission denied
INFO: pidfile created : '/opt/homebrew/Cellar/activemq/5.16.3/libexec//data/activemq.pid' (pid '22216')
maverick@Maverick bin % ./activemq status
INFO: Loading '/opt/homebrew/Cellar/activemq/5.16.3/libexec//bin/env'
INFO: Using java '/opt/homebrew/opt/openjdk/bin/java'
ActiveMQ not running
原因分析:
问题一:active可以启动但连接不上8161
可能是因为 activemq/libexec/conf/jetty.xml内的ip设置有误
问题2:无法启动activeMQ
启动不了的原因有很多,我遇到的是端口被占用
ActiveMQ默认后台启动,不会默认把错误显示出来而是需要你
./activemq console
以前台启动来查看错误
activeMQ是纯JAVA程序,异常一般JAVA程序员都能看懂
关于端口占用问题
ActiveMQ不只是使用前端控制中心8161端口和61616端口,而是会占用
8161, 61616, 5672, 61613, 1883, 61614共6个端口
在activemq/libexec/conf/activemq.xml内可以看到
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
</transportConnectors>
而我本机每次重启都会被占用61613,找到占用端口的进程,kill掉重启ActiveMQ就ok
解决方案:
问题1解决方案:
需要将activemq/libexec/conf/jetty.xml内的127.0.0.1改为0.0.0.0
<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>
问题2解决方案:
找到占用以上6个端口的进程kill掉
maverick@Maverick conf % lsof -i tcp:8161
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 19144 maverick 148u IPv6 0x1d3977c14786090b 0t0 TCP *:patrol-snmp (LISTEN)
maverick@Maverick conf % kill 19144
总结:
如遇到其他问题可使用 ./activemq console查看具体报错信息
标签:opt,libexec,8161,ActiveMQ,无法,bin,homebrew,activemq 来源: https://blog.csdn.net/weixin_43973305/article/details/122026693