centos7 安装 rocketMQ 二进制发行版
2021-01-29 本文已影响0人
爱烫头的程序员
- 下载二进制版本,解压迁移目录
wget https://mirrors.bfsu.edu.cn/apache/rocketmq/4.8.0/rocketmq-all-4.8.0-bin-release.zip
unzip rocketmq-all-4.8.0-bin-release.zip
mv rocketmq-all-4.8.0-bin-release /usr/local/rocketmq
- 配置环境变量
echo -e '\nexport ROCKETMQ_HOME=/usr/local/rocketmq\n' >> /etc/profile
echo -e '\nexport PATH=$PATH:${ROCKETMQ_HOME}/bin\n' >> /etc/profile
- 在发送和接收消息之前,我们需要告诉客户端 Name Server的位置。RocketMQ提供了多种方法来实现这一目标。为简单起见,我们使用环境变量NAMESRV_ADDR
echo -e '\nexport NAMESRV_ADDR=localhost:9876\n' >> /etc/profile
- 使之生效
source /etc/profile
- 修改启动脚本, 根据自己服务器的内存情况,调整占用的内存大小,防止内存不足(可选)
vim /usr/local/rocketmq/bin/runserver.sh
vim /usr/local/rocketmq/bin/runbroker.sh
- 尝试启动
- 启动 Name Server
cd /usr/local/rocketmq/
nohup sh bin/mqnamesrv &
tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...
- 启动 Broker
nohup sh bin/mqbroker -n localhost:9876 &
- 或者使用指定配置运行 -c
nohup sh bin/mqbroker -n localhost:9876 -c ./conf/broker.conf &
tail -f ~/logs/rocketmqlogs/broker.log
The broker[%s, 172.30.30.233:10911] boot success...
- 测试发送和消费消息
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...
- 关闭服务
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