1、下载RocketMQ
-
从官网下载RocketMQ,我下的是最新版的rocketmq-all-5.2.0
-
将下载好的
rocketmq-all-5.2.0-bin-release.zip
上传到服务器的/opt/software
-
解压文件到
/opt/module
unzip /opt/software/rocketmq-all-5.2.0-bin-release.zip -d /opt/module
- 重命名一下
mv -f /opt/module/rocketmq-all-5.2.0-bin-release /opt/module/rocketmq-all-5.2.0
2、启动NameServer
# 启动namesrv
nohup sh bin/mqnamesrv >> /dev/null 2>&1 &
# 验证namesrv是否启动成功
tail -1000f ~/logs/rocketmqlogs/namesrv.log
3、启动Broker+Proxy
# 先启动broker
nohup sh bin/mqbroker -n localhost:9876 --enable-proxy >> /dev/null 2>&1 &
# 验证broker是否启动成功, 比如, broker的ip是192.168.1.2 然后名字是broker-a
tail -f ~/logs/rocketmqlogs/proxy.log
这边会发现启动不起来,去掉
nohup
直接运行会报Unrecognized VM option 'UseBiasedLocking'
,这个时候可以找到/opt/module/rocketmq-all-5.2.0/bin/
的runbroker.sh
,找到-XX:-UseBiasedLocking
,去掉重新执行即可
4、测试发送与接受消息
- 测试发送信息
export NAMESRV_ADDR=localhost:9876
bin/tools.sh org.apache.rocketmq.example.quickstart.Producer
- 测试接收信息
bin/tools.sh org.apache.rocketmq.example.quickstart.Consumer
5、关闭服务器
# 关闭broker
bin/mqshutdown broker
# NameServer
bin/mqshutdown namesrv
6、可视化平台
为什么用docker,因为我有下载过源码,然后在虚拟机上mvn编译,编译失败,还是直接docker简单一点
6.1、下载docker
- 删除旧版本
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
- 安装远程仓库
yum install -y yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
- 安装docker
yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- 启动docker
systemctl start docker
- 测试docker
docker run hello-world
6.2、安装rocketmq-dashboard
- 拉取
rocketmq-dashboard
镜像
docker pull apacherocketmq/rocketmq-dashboard:latest
- docker 容器中运行
rocketmq-dashboard
docker run -d --name rocketmq-dashboard -e "JAVA_OPTS=-Drocketmq.namesrv.addr=192.168.8.100:9876" -p 8180:8080 -t apacherocketmq/rocketmq-dashboard:latest
# 查看运行日志
docker logs -f rocketmq-dashboard
- 通过http://192.168.8.100:8180/#/就可以看到管理页面