rocketMQ 踩坑解决No route info of this topic和rocketmq:connect to 172.17.42.1:10911 failed

命令所在位置 /root/rocketmq-all-4.3.1/distribution/target/apache-rocketmq/bin

查看所有的topic集合

  1. ./mqadmin topicList -n localhost:9876(首选)

创建topic

sh mqadmin updateTopic -n XXX:9876 -b XXX:10911 -t ESOrderListTopic

启动mqnamesrv

nohup sh mqnamesrv & :属于后台启动

sh mqnamesrv :属于终端启动,直接输出日志信息,按 ctrl+c 可直接关闭退出

# 查看启动日志能看到:The Name Server boot success字样则成功
$ tail -f ~/logs/rocketmqlogs/namesrv.log
先关闭namesrv服务:sh bin/mqshutdown namesrv

启动broker

nohup sh bin/mqbroker -n localhost:9876 & :属于后台启动
建议 nohup sh mqbroker -n localhost:9876 autoCreateTopicEnable=true &
 tail -f ~/logs/rocketmqlogs/broker.log查看日志或是cat nohup.out
关闭broker服务 :sh bin/mqshutdown broker

启动broker报错

tail -f ~/logs/rocketmqlogs/broker.log
2019-11-10 19:51:41 INFO BrokerControllerScheduledThread1 - Slave fall behind master: 179890 bytes
2019-11-10 19:51:41 WARN brokerOutApi_thread_4 - registerBroker Exception, localhost:9876
org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to  failed
        at org.apache.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:393) ~[rocketmq-remoting-4.3.1.jar:4.3.1]
        at org.apache.rocketmq.broker.out.BrokerOuterAPI.registerBroker(BrokerOuterAPI.java:194) ~[rocketmq-broker-4.3.1.jar:4.3.1]
        at org.apache.rocketmq.broker.out.BrokerOuterAPI.access$000(BrokerOuterAPI.java:61) ~[rocketmq-broker-4.3.1.jar:4.3.1]
        at org.apache.rocketmq.broker.out.BrokerOuterAPI$1.run(BrokerOuterAPI.java:150) ~[rocketmq-broker-4.3.1.jar:4.3.1]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_212]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_212]
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]
2019-11-10 19:52:11 WARN brokerOutApi_thread_1 - registerBroker Exception, localhost:9876
org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to  failed
        at org.apache.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:393) ~[rocketmq-remoting-4.3.1.jar:4.3.1]
        at org.apache.rocketmq.broker.out.BrokerOuterAPI.registerBroker(BrokerOuterAPI.java:194) ~[rocketmq-broker-4.3.1.jar:4.3.1]
        at org.apache.rocketmq.broker.out.BrokerOuterAPI.access$000(BrokerOuterAPI.java:61) ~[rocketmq-broker-4.3.1.jar:4.3.1]
        at org.apache.rocketmq.broker.out.BrokerOuterAPI$1.run(BrokerOuterAPI.java:150) ~[rocketmq-broker-4.3.1.jar:4.3.1]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_212]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_212]
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_212]

解决:注意启动命令路径对不对。

报错
还是启动命令不对

[root@hz-fangke-01 apache-rocketmq]# sh bin/mqadmin topicList –n 10.1.0.36:9876
OpenJDK 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
org.apache.rocketmq.tools.command.SubCommandException: TopicListSubCommand command failed
        at org.apache.rocketmq.tools.command.topic.TopicListSubCommand.execute(TopicListSubCommand.java:113)
        at org.apache.rocketmq.tools.command.MQAdminStartup.main0(MQAdminStartup.java:132)
        at org.apache.rocketmq.tools.command.MQAdminStartup.main(MQAdminStartup.java:83)
Caused by: org.apache.rocketmq.remoting.exception.RemotingConnectException: connect to  failed
        at org.apache.rocketmq.remoting.netty.NettyRemotingClient.invokeSync(NettyRemotingClient.java:393)
        at org.apache.rocketmq.client.impl.MQClientAPIImpl.getTopicListFromNameServer(MQClientAPIImpl.java:1239)
        at org.apache.rocketmq.tools.admin.DefaultMQAdminExtImpl.fetchAllTopicList(DefaultMQAdminExtImpl.java:222)
        at org.apache.rocketmq.tools.admin.DefaultMQAdminExt.fetchAllTopicList(DefaultMQAdminExt.java:189)
        at org.apache.rocketmq.tools.command.topic.TopicListSubCommand.execute(TopicListSubCommand.java:107)
        ... 2 more

报错 No route info of this topic XXX 异常

一般来讲是因为rocket中没有XXX这个topic,我怕们可以手动在rocketmq自己添加一个。

    ```
    rocketmq命令都是在/root/rocketmq-all-4.3.1/distribution/target/apache-rocketmq/bin路径下
    sh mqadmin updateTopic -n XXX:9876 -b XXX:10911 -t ESOrderListTopic
    ```

RemotingConnectException: connect to <172.17.0.1:10911> failed

这个错误看代码是发送消息后出的问题,说明和代码没有关系

原因是:broker部署在虚拟机,并且虚拟双网卡,client无法正常连接服务端

解决: 在config/broker.conf配置文件中添加:

brokerIP1=服务器地址
namesrvAddr =服务器地址:9876

指定为本机的IP
然后重启rocketmq就可以了。
参考 :https://blog.csdn.net/mayifan0/article/details/67633729

你可能感兴趣的:(互联网,lunix,服务器配置)