64位操作系统,建议使用Linux / Unix /
JDK Maven 的安装自行 Google
下载4.3.0源码版本:https://www.apache.org/dyn/closer.cgi?path=rocketmq/4.3.0/rocketmq-all-4.3.0-source-release.zip
现在执行以下命令来解压4.3.0源码版本并构建二进制文件
关闭防火墙:
systemctl stop firewalld.service
unzip rocketmq-all-4.3.0-source-release.zip
cd rocketmq-all-4.3.0/
mvn -Prelease-all -DskipTests clean install -U
mv distribution/target/apache-rocketmq /opt/apache-rocketmq
cd /opt/apache-rocketmq
编译成功的响应:
默认 RocketMQ Server 内存需要很大的
vi bin/runserver.sh
JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
我修改成
JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
nohup sh bin/mqnamesrv > /dev/null 2>&1 &
tail -f ~/logs/rocketmqlogs/namesrv.log
会看到如下响应信息
2018-02-01 16:15:16 INFO main - The Name Server boot success...
默认 RocketMQ Broker 内存需要很大的
vi bin/runbroker.sh
JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g"
我修改成
JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m"
启动Broker
nohup sh bin/mqbroker -n localhost:9876 > /dev/null 2>&1 &
tail -f ~/logs/rocketmqlogs/broker.log
会看到如下响应信息
2018-02-01 17:37:48 INFO main - The broker[node1, 192.168.252.121:10911] boot success...
[root@node1 apache-rocketmq]# jps
2374 BrokerStartup
2350 NamesrvStartup
3194 Jps
Send & Receive Messages
发送消息
发送/接收消息之前,我们需要告诉客户端 NameServer 地址。RocketMQ 提供了多种方式来实现这一目标。为简单起见,我们使用环境变量 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...
停止 broker
> sh bin/mqshutdown broker
The mqbroker(36695) is running...
Send shutdown request to mqbroker(36695) OK
停止 namesrv
> sh bin/mqshutdown namesrv
The mqnamesrv(36664) is running...
Send shutdown request to mqnamesrv(36664) OK
RocketMQ web界面监控RocketMQ-Console-Ng部署
下载并且 maven 编译
git clone https://github.com/apache/rocketmq-externals.git
cd rocketmq-externals/rocketmq-console/
mvn clean package -Dmaven.test.skip=true
编译成功结果:
rocketmq.config.namesrvAddr
NameServer
地址,默认启动端口8080
nohup java -jar target/rocketmq-console-ng-1.0.0.jar --rocketmq.config.namesrvAddr=127.0.0.1:9876 > /dev/null 2>&1 &
作者:搜云库技术团队
链接:https://juejin.im/post/5a74243a6fb9a0634d277ead
来源:掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。