rocketMQ学习笔记一:RocketMQ安装部署
文章目录一、环境要求二、下载、构建三、 启动NameServer四、启动Broker五、发送和接收消息六、启动rocketmq-console控制台七、mqadmin使用八、关闭服务官网链接:rocketmq-apache-org一、环境要求推荐64bit OS, Linux/Unix/Mac;(32位会有问题,用64位系统少采坑)64bit JDK 1.8+;Maven 3.2.x...
·
官网链接: rocketmq-apache-org
一、环境要求
- 推荐64bit OS, Linux/Unix/Mac;(32位会有问题,用64位系统少采坑)
- 64bit JDK 1.8+;
- Maven 3.2.x;
- Git;
- 4g+ free disk for Broker server
二、下载、构建
// 下载
curl -O --insecure 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
目录结构
GNGMacBook-Pro:apache-rocketmq gongninggang$ ll
total 56
drwxr-xr-x 9 gongninggang staff 288B 5 8 15:43 ./
drwxr-xr-x 11 gongninggang staff 352B 5 8 15:43 ../
-rw-r--r-- 1 gongninggang staff 17K 1 14 15:18 LICENSE
-rw-r--r-- 1 gongninggang staff 1.3K 1 14 15:18 NOTICE
-rw-r--r-- 1 gongninggang staff 2.4K 1 14 16:24 README.md
drwxr-xr-x 6 gongninggang staff 192B 5 8 15:43 benchmark/
drwxr-xr-x 32 gongninggang staff 1.0K 5 8 15:43 bin/
drwxr-xr-x 11 gongninggang staff 352B 1 17 19:20 conf/
drwxr-xr-x 29 gongninggang staff 928B 5 8 15:43 lib/
三、 启动NameServer
// 后台启动NameServer
nohup sh bin/mqnamesrv &
// 查看日志
tail -f ~/logs/rocketmqlogs/namesrv.log
四、启动Broker
nohup sh bin/mqbroker -n localhost:9876 &
tail -f ~/logs/rocketmqlogs/broker.log
五、发送和接收消息
在发送和接收消息之前,首先需要告诉客户端“Name Server”所在的位置。方式有很多。本文使用环境变量的方式。
// 添加环境变量
export NAMESRV_ADDR=localhost:9876
// 生产消息
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
// 消费消息
sh bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
六、启动rocketmq-console控制台
java -jar /Users/gongninggang/source/rocketmq-externals/rocketmq-console/target/rocketmq-console-ng-1.0.1.jar
七、mqadmin使用
// 进入bin目录
cd /Users/gongninggang/rocketmq-all-4.4.0/distribution/target/apache-rocketmq/bin
// 查看mqadmin有哪些操作
GNGMacBook-Pro:bin gongninggang$ sh mqadmin
// 查看命令的帮助
GNGMacBook-Pro:bin gongninggang$ sh mqadmin help topicList
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
usage: mqadmin topicList [-c] [-h] [-n <arg>]
-c,--clusterModel clusterModel
-h,--help Print help
-n,--namesrvAddr <arg> Name server address list, eg: 192.168.0.1:9876;192.168.0.2:9876
//
// 查看TOPIC列表
GNGMacBook-Pro:bin gongninggang$ sh mqadmin topicList -n '172.16.173.191:9876'
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
%RETRY%please_rename_unique_group_name
RMQ_SYS_TRANS_HALF_TOPIC
%RETRY%please_rename_unique_group_name_4
BenchmarkTest
OFFSET_MOVED_EVENT
TopicTest
GNGMacBook-Pro.local
TBW102
TopicTestXXB
%RETRY%TOOLS_CONSUMER
SELF_TEST_TOPIC
DefaultCluster
GNGMacBook-Pro:bin gongninggang$
八、关闭服务
cd /Users/gongninggang/rocketmq-all-4.4.0/distribution/target/apache-rocketmq
// 关闭broker
sh bin/mqshutdown broker
// 关闭namesrv
sh bin/mqshutdown namesrv
更多推荐
已为社区贡献1条内容
所有评论(0)