CentOS 安装RocketMQ
一、安装RocketMQ
1.下载安装包(下载地址)
https://archive.apache.org/dist/rocketmq/4.3.0/rocketmq-all-4.3.0-bin-release.zip
2.解压
unzip rocketmq-all-4.3.0-bin-release.zip
3.创建启动namesrv与broker的脚本
#!/bin/bash mkdir -p logs nohup sh ./bin/mqnamesrv > ./logs/namesrv.log & tail -f logs/namesrv.log
#!/bin/bash nohup sh ./bin/mqbroker -n localhost:9876 > ./logs/broker.log & tail -f logs/broker.log
二、设置开机自启动
1.创建自启动脚本
vi /etc/init.d/rocketmq
#!/bin/sh # # rocketmq - this script starts and stops the rocketmq daemon # # chkconfig: - 85 15 export JAVA_HOME=/usr/local/jdk1.8.0_281 export PATH=$JAVA_HOME/bin:$PATH ROCKETMQ_HOME=/data/install/rocketmq ROCKETMQ_BIN=${ROCKETMQ_HOME}/bin ADDR=`hostname -i`:9876 LOG_DIR=${ROCKETMQ_HOME}/logs NAMESERVER_LOG=${LOG_DIR}/namesrv.log BROKER_LOG=${LOG_DIR}/broker.log start() { if [ ! -d ${LOG_DIR} ];then mkdir ${LOG_DIR} fi cd ${ROCKETMQ_HOME} nohup sh bin/mqnamesrv > ${NAMESERVER_LOG} 2>&1 & echo -n "The Name Server boot success..." nohup sh bin/mqbroker -n ${ADDR} > ${BROKER_LOG} 2>&1 & echo -n "The broker[%s, ${ADDR}] boot success..." } stop() { cd ${ROCKETMQ_HOME} sh bin/mqshutdown broker sleep 1 sh bin/mqshutdown namesrv } restart() { stop sleep 5 start } case "$1" in start) start ;; stop) stop ;; restart) restart ;; *) echo $"Usage: $0 {start|stop|restart}" exit 2 esac
2.分配可执行权限
chmod a+x /etc/init.d/rocketmq
3.设置开机自启动
chkconfig --add rocketmq
chkconfig rocketmq on
4.验证自启动状态
chkconfig --list
三、设置队列主题
1.单机版创建主题
sh bin/mqadmin updateTopic -n localhost:9876 -b localhost:10911 -t zxz
2.集群版创建主题
sh bin/mqadmin updateTopic -n localhost:9876 -c DefaultCluster -t zxz
作者:[一柒微笑]