1.下载版本
2.解压
unzip
3.配置环境变量
export ROCKETMQ_HOME=/opt/software/rocketmq-all-4.9.1-bin-release export PATH=$PATH:$ROCKETMQ_HOME/bin
4.nameserver服务的创建
修改runserver.sh中的运行内存配置:
启动命令:
nohup ./mqnamesrv &
jps看到进城:
4393 NamesrvStartup
查看日志:
[root@com bin]# more nohup.out Java HotSpot(TM) 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 Java HotSpot(TM) 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release. Java HotSpot(TM) 64-Bit Server VM warning: MaxNewSize (524288k) is equal to or greater than the entire heap (524288k). A new max generation size of 524224k will be used. The Name Server boot success. serializeType=JSON
5.broker服务搭建
修改运行文件中的内存配置:
再修改conf下的broker.conf,使用topic自动创建
autoCreateTopicEnable=true
启动命令:
nohup bin/mqbroker &
日志:
The broker[com.jun, 192.168.19.131:10911] boot success. serializeType=JSON
6.命令启动客户端
配置环境变量NAMESERVER_ADDR,指向nameserver服务
使用tools进行快速验证:
bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
· 日志效果:
SendResult [sendStatus=SEND_OK, msgId=7F00000113C31B6D35860EFC724E03E0, offsetMsgId=C0A8138300002A9F000000000002E792, messageQueue=MessageQueue [topic=TopicTest, brokerName=com.jun, queueId=2], queueOffset=248] SendResult [sendStatus=SEND_OK, msgId=7F00000113C31B6D35860EFC724F03E1, offsetMsgId=C0A8138300002A9F000000000002E852, messageQueue=MessageQueue [topic=TopicTest, brokerName=com.jun, queueId=3], queueOffset=248]
消费接收:
bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
完整的日志:
ConsumeMessageThread_14 Receive New Messages: [MessageExt [brokerName=com.jun, queueId=1, storeSize=192, queueOffset=232, sysFlag=0, bornTimestamp=1693749025285, bornHost=/192.168.19.131:38234, storeTimestamp=1693749025286, storeHost=/192.168.19.131:10911, msgId=C0A8138300002A9F000000000002B9D2, commitLogOffset=178642, bodyCRC=1379786659, reconsumeTimes=0, preparedTransactionOffset=0, toString()=Message{topic='TopicTest', flag=0, properties={MIN_OFFSET=0, MAX_OFFSET=250, CONSUME_START_TIME=1693749176516, UNIQ_KEY=7F00000113C31B6D35860EFC720503A3, CLUSTER=DefaultCluster, TAGS=TagA}, body=[72, 101, 108, 108, 111, 32, 82, 111, 99, 107, 101, 116, 77, 81, 32, 57, 51, 49], transactionId='null'}]]
其中比较关键的属性有:brokerName,queueId,msgId,topic, cluster,tags,body,transactionId。
7.关闭rickermq服务
通过mqshutdown进行关闭
分类:
rocketmq
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)