1、下载
>wget http://mirror.bit.edu.cn/apache/rocketmq/4.4.0/rocketmq-all-4.4.0-source-release.zip
>unzip rocketmq-all-4.4.0-source-release.zip
> cd rocketmq-all-4.4.0/
> mvn -Prelease-all -DskipTests clean install -U
> cd distribution/target/apache-rocketmq
2、启动
2.1 linux启动
2.1.1 启动name server
> nohup sh bin/mqnamesrv &
> tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...
2.1.2 启动Broker
远程访问需要配置
(1)防火墙需要开放端口:9876、10909、10910、10911
(2)修改conf/broker.conf
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
#增加
namesrvAddr=外网ip:9876
brokerIP1=外网ip
启动broker,指定配置文件
>nohup sh bin/mqbroker -n xxx:9876 autoCreateTopicEnable=true -c /root/rocketmq/rocketmq-all-4.4.0/distribution/target/apache-rocketmq/conf/broker.conf & #xxx为公网ip
2.2 windows启动
2.2.1 设置环境变量
ROCKETMQ_HOME="D:\rocketmq"
NAMESRV_ADDR="localhost:9876"
2.2.2 启动Name Server
.\bin\mqnamesrv.cmd
2.2.3 启动Broker
.\bin\mqbroker.cmd -n localhost:9876 autoCreateTopicEnable=true
2.2.4 发送、接收消息
发送消息
.\bin\tools.cmd org.apache.rocketmq.example.quickstart.Producer
接收消息
.\bin\tools.cmd org.apache.rocketmq.example.quickstart.Consumer