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进行关闭

  

 

 posted on 2023-09-03 21:56  曹军  阅读(30)  评论(0编辑  收藏  举报