下载rocketmq安装包:
cd /opt/soft
# 下载二进制安装包
wget https://archive.apache.org/dist/rocketmq/4.7.1/rocketmq-all-4.7.1-bin- release.zip
# 如果没有安装
unzip yum install -y unzip
# 解压
unzip rocketmq-all-4.7.1-bin-release.zip
# 创建软链
ln -s /opt/soft/rocketmq-all-4.7.1-bin-release /usr/local/rocketmq
启动 NameServer、Broker:
# 修改runserver.sh,把内存调小
# 启动nameserver
nohup /usr/local/rocketmq/bin/mqnamesrv &
# 关闭
/usr/local/rocketmq/bin/mqshutdown namesrv
# 修改runbroker.sh,把内存调小
# 启动broker
nohup /usr/local/rocketmq/bin/mqbroker &
# 关闭
/usr/local/rocketmq/bin/mqshutdown broker
验证:
jps
发送和接收消息:
/usr/local/rocketmq/bin
# autoCreateTopicEnable=true 4.8.0有bug,加了也没用
# 创建topic
sh mqadmin updateTopic -t TopicTest -n 192.168.1.2:9876 -b localhost:10911
# 临时设置namesrv环境变量
export NAMESRV_ADDR=localhost:9876
# 使用rocket自动的生产者
sh tools.sh org.apache.rocketmq.example.quickstart.Producer
# 使用rocket自动的消费者
sh tools.sh org.apache.rocketmq.example.quickstart.Consumer
标签:bin,4.7,local,sh,实例,RocketMQ,安装,rocketmq,usr
From: https://www.cnblogs.com/snail-gao/p/16733039.html