一、RocketMQ简介
RocketMQ是由阿里捐赠给Apache的一款低延迟、高并发、高可用、高可靠的分布式消息中间件。经历了淘宝双十一的洗礼。RocketMQ既可为分布式应用系统提供异步解耦和削峰填谷的能力,同时也具备互联网应用所需的海量消息堆积、高吞吐、可靠重试等特性。
二、安装JDK
JDK下载地址:https://www.oracle.com/java/technologies/javase/javase8-archive-downloads.html
文章源自小柒网-https://www.yangxingzhen.cn/9324.html
1、安装JDK-1.8
文章源自小柒网-https://www.yangxingzhen.cn/9324.html
[root@localhost ~]# yum -y install jdk-8u202-linux-x64.rpm
文章源自小柒网-https://www.yangxingzhen.cn/9324.html
2、查看是否安装成功
文章源自小柒网-https://www.yangxingzhen.cn/9324.html
[root@localhost ~]# java -version
文章源自小柒网-https://www.yangxingzhen.cn/9324.html
java version "1.8.0_202"
文章源自小柒网-https://www.yangxingzhen.cn/9324.html
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
文章源自小柒网-https://www.yangxingzhen.cn/9324.html
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
文章源自小柒网-https://www.yangxingzhen.cn/9324.html
三、Centos 7.9安装RocketMQ
官网下载地址:https://rocketmq.apache.org/zh/download
文章源自小柒网-https://www.yangxingzhen.cn/9324.html
1、下载依赖包
文章源自小柒网-https://www.yangxingzhen.cn/9324.html
[root@localhost ~]# yum -y install wget
2、下载RocketMQ安装包
[root@localhost ~]# wget https://archive.apache.org/dist/rocketmq/4.9.6/rocketmq-all-4.9.6-bin-release.zip
3、解压安装包
[root@localhost ~]# unzip rocketmq-all-4.9.6-bin-release.zip -d /usr/local
[root@localhost ~]# mv /usr/local/rocketmq-all-4.9.6-bin-release/ /usr/local/rocketmq
4、修改broker.conf配置文件
[root@localhost ~]# cd /usr/local/rocketmq/conf
[root@localhost conf]# vim broker.conf
# 加入以下参数配置,192.168.56.134为本地服务器IP
namesrvAddr=192.168.56.134:9876
brokerIP1=192.168.56.134
autoCreateTopicEnable=true
5、修改runserver.sh和runbroker.sh脚本的启动参数(根据自身配置修改,这里只是为了方便演示,修改成1g)
[root@localhost conf]# cd ../bin/
[root@localhost bin]# sed -i -e 's/4g/1g/g' -e 's/2g/512m/g' runserver.sh
[root@localhost bin]# sed -i 's/8g/1g/g' runbroker.sh
6、启动RocketMQ
注:需要启动NameServer和Broker。
# 启动NameServer,使用jps命令看到NamesrvStartup就是启动成功了。
[root@localhost bin]# nohup ./mqnamesrv -n 192.168.56.134:9876 &
[root@localhost bin]# jps
2555 NamesrvStartup
2591 Jps
# 启动Broker,使用jps命令看到BrokerStartup就是启动成功了。
[root@localhost bin]# nohup ./mqbroker -n 192.168.56.134:9876 -c ../conf/broker.conf &
[root@localhost bin]# jps
2854 Jps
2555 NamesrvStartup
2751 BrokerStartup
7、测试数据发送和消费
[root@localhost bin]# export NAMESRV_ADDR=192.168.56.134:9876
[root@localhost bin]# ./tools.sh org.apache.rocketmq.example.quickstart.Producer
8、关闭RocketMQ
注:需要先先关闭 Broker,然后再关闭Name Server。
[root@localhost bin]# ./mqshutdown broker
The mqbroker(2751) is running...
Send shutdown request to mqbroker(2751) OK
[root@localhost bin]# ./mqshutdown namesrv
The mqnamesrv(2555) is running...
Send shutdown request to mqnamesrv(2555) OK
[2]+ Exit 143 nohup ./mqbroker -n 192.168.56.134:9876 -c ../conf/broker.conf autoCreateTopicEnable=true
四、安装RocketMQ-Dashboard
1、下载源代码
[root@localhost ~]# wget https://github.com/apache/rocketmq-dashboard/archive/refs/tags/rocketmq-dashboard-1.0.0.zip
[root@localhost ~]# unzip rocketmq-dashboard-1.0.0.zip
2、安装Maven
[root@localhost ~]# wget https://dlcdn.apache.org/maven/maven-3/3.9.3/binaries/apache-maven-3.9.3-bin.zip
[root@localhost ~]# unzip apache-maven-3.9.3-bin.zip
[root@localhost ~]# mv apache-maven-3.9.3 /usr/local/maven
[root@localhost ~]# ln -sf /usr/local/maven/bin/mvn /usr/bin/
3、编译
[root@localhost ~]# cd rocketmq-dashboard-rocketmq-dashboard-1.0.0
[root@localhost rocketmq-dashboard-rocketmq-dashboard-1.0.0]# mvn clean package -Dmaven.test.skip=true
4、启动rocketmq-dashboard
[root@localhost rocketmq-dashboard-rocketmq-dashboard-1.0.0]# cd target
[root@localhost target]# nohup java -jar rocketmq-dashboard-1.0.0.jar &
5、访问rocketmq-dashboard
1)浏览器访问http://192.168.56.134:8080/,如下图所示
2)连接RocketMQ
3)切换中文语言
4)创建Topic
5)创建消费者组consumer
6)扩容Topic队列
7)发送消息
# 向指定Topic发送消息
# 发送结果
若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!
![weinxin](https://www.yangxingzhen.com/images/weixin.jpg)
![weinxin](https://www.yangxingzhen.com/images/weixingongzhonghao.png)
评论