Rocketmq 4.2.0 安装
标签(空格分隔): RocketMQ
[toc]
1. 编译
> unzip rocketmq-all-4.2.0-source-release.zip
> cd rocketmq-all-4.2.0/
> mvn -Prelease-all -DskipTests clean install -U
> cd distribution/target/apache-rocketmq
2. 启动 Name Server
> nohup sh bin/mqnamesrv &
> tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...
3. 启动Broker
> nohup sh bin/mqbroker -n localhost:9876 &
> tail -f ~/logs/rocketmqlogs/broker.log
The broker[%s, 172.30.30.233:10911] boot success...
# 启动加入配置文件参数
nohup sh bin/mqbroker -c /paxos/software/apache-rocketmq-all/conf/2m-2s-sync/broker-a.properties -n 127.0.0.1:9876 &
[rocketmq@localhost rocketmq]$ more /paxos/software/apache-rocketmq-all/conf/2m-2s-sync/broker-a.properties
#Broker对外服务的监听端口
#listenPort = 10911
## Name Server地址
#namesrvAddr=192.168.0.26:9876
#本机IP地址,默认系统自动识别,但是某些多网卡机器会存在识别错误的情况,这种情况下可以人工配置
brokerIP1=192.168.0.26
#Broker所属哪个集群,其中缺省值为DefaultCluster
brokerClusterName=DefaultCluster
#本机主机名
brokerName=broker-a
#BrokerId,必须是大等于0的整数,0表示Master,>0表示Slave,一个Master可以挂多个Slave,Master与Slave通过BrokerName来配对
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=SYNC_MASTER
flushDiskType=ASYNC_FLUSH
4. Send & Receive Messages
> export NAMESRV_ADDR=localhost:9876
> sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
SendResult [sendStatus=SEND_OK, msgId= ...
> sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
ConsumeMessageThread_%d Receive New Messages: [MessageExt...
5. 停止服务
> sh bin/mqshutdown broker
The mqbroker(36695) is running...
Send shutdown request to mqbroker(36695) OK
> sh bin/mqshutdown namesrv
The mqnamesrv(36664) is running...
Send shutdown request to mqnamesrv(36664) OK