问题:所有配置都正确,生产者可以正常发送消息,消费者无法消费
- 解决: 删除 store 下所有的数据,重启后,可以正常消费了。
- 原因: 待补
- 配置信息说明:
rocketmq在docker 中的位置/opt/rocketmq-4.4.0 ,
broker数据存储路径为默认位置 /root/
配置文件位置 /etc/rocketmq
docker-compse信息
version: '2'
services:
namesrv-m:
image: foxiswho/rocketmq:server-4.4.0
restart: always
ports:
- 9876:9876
volumes:
- "./namesrv/master/logs:/root/logs"
- "./namesrv/master/store:/root/store"
- /etc/localtime:/etc/localtime:ro
environment:
JAVA_OPT_EXT: "-server -Xms300m -Xmx300m -Xmn150m"
namesrv-s:
image: foxiswho/rocketmq:server-4.4.0
restart: always
ports:
- 9877:9876
volumes:
- "./namesrv/slave/logs:/root/logs"
- "./namesrv/slave/store:/root/store"
- /etc/localtime:/etc/localtime:ro
environment:
JAVA_OPT_EXT: "-server -Xms300m -Xmx300m -Xmn150m"
broker-master:
image: foxiswho/rocketmq:broker-4.4.0
restart: always
ports:
- 10909:10909
- 10911:10911
- 10912:10912
volumes:
- "./broker/master/logs:/root/logs"
- "./broker/master/store:/root/store"
- "./broker/master/conf/broker.conf:/etc/broker.conf"
- /etc/localtime:/etc/localtime:ro
command: mqbroker -n <外网地址>:9876 -c /etc/broker.conf autoCreateTopicEnable=true &
links:
- namesrv-m:namesrv-m
- namesrv-s:namesrv-s
environment:
JAVA_OPTS: " -Dfile.encoding=UTF-8 "
#见rocketmq jvm内存默认配置 (jvm重复参数:后面生效,会覆盖)
JAVA_OPT_EXT: "-server -Xms300m -Xmx300m -Xmn150m"
broker-slave:
image: foxiswho/rocketmq:broker-4.4.0
restart: always
ports:
- 20909:10909
- 20911:10911
- 20912:10912
volumes:
- "./broker/slave/logs:/root/logs"
- "./broker/slave/store:/root/store"
- "./broker/slave/conf/broker.conf:/etc/broker.conf"
- /etc/localtime:/etc/localtime:ro
command: mqbroker -n <外网地址>:9876 -c /etc/broker.conf autoCreateTopicEnable=true &
links:
- namesrv-m:namesrv-m
- namesrv-s:namesrv-s
environment:
JAVA_OPTS: "-Dfile.encoding=UTF-8"
JAVA_OPT_EXT: "-server -Xms300m -Xmx300m -Xmn150m"
console:
image: styletang/rocketmq-console-ng:latest
restart: always
ports:
- 9990:8080
volumes:
- /etc/localtime:/etc/localtime:ro
links:
- namesrv-m:namesrv-m
- namesrv-s:namesrv-s
environment:
JAVA_OPTS: -Drocketmq.config.namesrvAddr=namesrv-m:9876;namesrv-s:9877 -Dcom.rocketmq.sendMessageWithVIPChannel=false
- 主从配置
master
brokerClusterName = dev-rocketmq-cluster
brokerName = broker-x
#0 表示 Master,>0 表示 Slave
brokerId = 0
#这个很有讲究 如果是正式环境 这里一定要填写内网地址(安全)
#如果是用于测试或者本地这里建议要填外网地址,因为你的本地代码是无法连接到阿里云内网,只能连接外网
brokerIP1=<外网地址>
brokerIP2=<外网地址>
# 内网的(阿里云有内网IP和外网IP)
namesrvAddr=172.17.17.152:9876;172.17.17.152:9877
#Broker 对外服务的监听端口
listenPort = 10911
#删除文件时间点,默认凌晨 4点
deleteWhen = 04
#文件保留时间,默认 48 小时
fileReservedTime = 120
#Broker角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=SYNC_MASTER
#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH
autoCreateTopicEnable =true
slave 配置:
brokerClusterName = dev-rocketmq-cluster
brokerName = broker-x
#0 表示 Master,>0 表示 Slave
brokerId = 1
#这个很有讲究 如果是正式环境 这里一定要填写内网地址(安全)
#如果是用于测试或者本地这里建议要填外网地址,因为你的本地代码是无法连接到阿里云内网,只能连接外网
brokerIP1 =<外网地址>
brokerIP2 = <外网地址>
# 内网的(阿里云有内网IP和外网IP)
namesrvAddr=172.17.17.152:9876;172.17.17.152:9877
#Broker 对外服务的监听端口
listenPort = 10911
#删除文件时间点,默认凌晨 4点
deleteWhen = 04
#文件保留时间,默认 48 小时
fileReservedTime = 120
#Broker角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=SLAVE
#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH
autoCreateTopicEnable =true