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&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
    <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;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

查看console后,提示java版本问题如果解决

确定自己activeMQ对应得jdk版本与服务器安装得是否一致,不一致更新jdk

加载时官网都有提示,根据情况安装jdk版本就行了,如下图

如果一个服务器上需要运行多个jdk版本,并且与ActiveMQ需要用到的jdk版本不一致如何解决?

打开ActiveMQ安装目录下得bin/activemq文件,对其进行编辑即可以指定jdk版本运行activemq

如何修改activemq得admin密码

打开activemq目录下conf/jetty-realm.properties,按格式修改即可

# Defines users that can access the web (console, demo, etc.)
# username: password [,rolename ...]
admin: admin, admin 
user: user, user

如何修改activemq,让其可以再互联网打开控制台

修改conf/jetty.xml,如下

<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>

总结:

如遇到其他问题可使用 ./activemq console查看具体报错信息

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值