专注于 JetBrains IDEA 全家桶,永久激活,教程
持续更新 PyCharm,IDEA,WebStorm,PhpStorm,DataGrip,RubyMine,CLion,AppCode 永久激活教程

当rockemq遇到装了Docker的主机

前言

目前做直播项目,生产环境用的阿里云的ons-rocketmq,测试环境打算本地装一下rocketmq。

安装

看了下dockerhub的景象,还是4.3的版本,而官网已经4.7了。那就直接按照官网的安装方式,下载zip包,去linux主机上安装了。 详情见官网介绍

53_1.png

可视化

可视化直接用docker-compose安装

version: "3.8"
services: 
    rocket_console:
        image: styletang/rocketmq-console-ng
        container_name: rocket_console
        ports: 
            - "8088:8080"
        environment: 
            - "JAVA_OPTS=-Drocketmq.namesrv.addr=0.0.0.0:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"

详情见 github

连接rocketmq遇到两个问题,第一个我没法复现

@Configuration
@Conditional(RocketMqCondition.class)
public class RocketMqProducer {
    @Autowired
    private RocketmqConfig rocketmqConfig;
    @Bean
    public DefaultMQProducer defaultMQProducer(){
        DefaultMQProducer producer = new DefaultMQProducer("halu");
        producer.setVipChannelEnabled(false);
        producer.setNamesrvAddr(rocketmqConfig.getAddr());
        try {
            producer.start();
        }catch (MQClientException e){
            e.printStackTrace();
        }
        return producer;
    }

}

如上代码所示,我选择连接的生产者群组是halu,但是一直报以下错误

The producer group[halu] has been created before, specify another name please.See http://rocketmq.apache.org/docs/faq/ for further details.

百度的话说的是没有进行producer.shutdown(); 可能连接没关掉,但我试过重启服务了。明天再试一下。

第二个问题是连接上namesrv,但是发消息显示以下错误

connect to 172.17.0.1:10911 failed 
## 大概意思

百度了下,意思是mq里的broker用的是第一个网卡,而我这台机器上装了docker

53_2.png

解决方案如下修改安装目录下的 /conf/broker.conf

brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
##加上下面两行
brokerIP1 = 192.168.0.10
namesrvAddr = 192.168.0.10:9876

然后重启broker的时候指定这个配置,命令如下

nohup sh bin/mqbroker  -c conf/broker.conf &

效果如下

OpenJDK 64-Bit Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release
OpenJDK 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
OpenJDK 64-Bit Server VM warning: MaxNewSize (1048576k) is equal to or greater than the entire heap (1048576k).  A new max generation size of 1048512k will be used.
The Name Server boot success. serializeType=JSON

文章永久链接:https://tech.souyunku.com/42442

未经允许不得转载:搜云库技术团队 » 当rockemq遇到装了Docker的主机

JetBrains 全家桶,激活、破解、教程

提供 JetBrains 全家桶激活码、注册码、破解补丁下载及详细激活教程,支持 IntelliJ IDEA、PyCharm、WebStorm 等工具的永久激活。无论是破解教程,还是最新激活码,均可免费获得,帮助开发者解决常见激活问题,确保轻松破解并快速使用 JetBrains 软件。获取免费的破解补丁和激活码,快速解决激活难题,全面覆盖 2024/2025 版本!

联系我们联系我们