rocketmq-all-4.4.0-source-release版本的启动详解:
系统环境准备:
安装64bit JDK 1.8+ 配置JAVA_HOME
安装Maven 3.2.x 配置M2_HOME
1.windows环境:
第一步:
下载rocketmq-all-4.4.0-source-release.zip 源码。
(https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.4.0/rocketmq-all-4.4.0-source-release.zip )
第二步:
解压rocketmq-all-4.4.0-source-release.zip到指定目录下
第三步:
打开cmd命令行窗口,进入到当前解压目录。
> mvn -Prelease-all -DskipTests clean install -U
> cd distribution/target/apache-rocketmq
第四步:
Start Name Server
运行 \bin\mqnamesrv.cmd
查看日志:C:\Users\Administrator\logs\rocketmqlogs\namesrv.log
看到The Name Server boot success. 内容表明启动成功。
第五步:
Start Broker
打开cmd> mqbroker.cmd -n localhost:9876
查看日志:
看到 The broker[USER-20160716AF, 192.168.209.1:10911] boot success. 内容表明启动成功。
第六步:
Send & Receive Messages 发送、接收信息
设置环境变量:
> set NAMESRV_ADDR=localhost:9876
> tools.cmd org.apache.rocketmq.example.quickstart.Producer
查看控制台日志输出“SendResult [sendStatus=SEND_OK, msgId=” 内容表明发送成功。
> tools.cmd org.apache.rocketmq.example.quickstart.Consumer
查看控制台日志输出“ConsumeMessageThread_1 Receive New Messages: [MessageExt“内容表明信息接收成功。
第七步:
卸载Apache RocketMQ:
> mqshutdown.cmd broker
> mqshutdown.cmd namesrv
2.linux环境:
第一步:Download & Build from Release
Click here to download the 4.4.0 source release. Also you could download a binary release from here.
Now execute the following commands to unpack 4.4.0 source release and build the binary artifact.
> 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
第二步:Start Name Server
> nohup sh bin/mqnamesrv &
> tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...
第三步:Start Broker
> nohup sh bin/mqbroker -n localhost:9876 &
> tail -f ~/logs/rocketmqlogs/broker.log
The broker[%s, 172.30.30.233:10911] boot success...
第四步:Send & Receive Messages
Before sending/receiving messages, we need to tell clients the location of name servers. RocketMQ provides multiple ways to achieve this. For simplicity, we use environment variable NAMESRV_ADDR
> 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...
第五步:Shutdown Servers
> 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