下载并解压安装包到 /usr/local/rocketmq/rocketmq-all-4.7.0-bin-release
修改配置文件vim /etc/profile 添加如下几行:
export NAMESRV_ADDR=127.0.0.1:9876
export ROCKETMQ_HOME=/usr/local/rocketmq/rocketmq-all-4.7.0-bin-release
export PATH=$JAVA_HOME/bin:$ROCKETMQ_HOME/bin:$PATH
记住/etc/profile中JAVA_HOME路径为:/usr/local/src/jdk1.8.0_161
使rocketmq的配置生效
source /etc/profile
cat /etc/profile
进入rocketmq/bin目录,修改runserver.sh runbroker.sh 和 tools.sh
把:
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)!"
改为:
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/local/src/jdk1.8.0_161
#[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
#[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)!"
runserver.sh
找到以下配置,将xms/xmx/xmn 分别修改成以下数值(视机器配置而定)
JAVA_OPT="${JAVA_OPT} -server -Xms512m -Xmx512m -Xmn256m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
##保存
runbroker.sh
##具体数值视机器而定
JAVA_OPT="${JAVA_OPT} -server -Xms128m -Xmx256m -Xmn256m"
##保存
rocketmq/conf中找到broker.conf,添加
namesrvAddr=127.0.0.1:9876
brokerIP1=47.107.185.200
分别后台启动
nohup sh mqnamesrv &
nohup sh mqbroker -n localhost:9876 autoCreateTopicEnable=true &
mqbroker的启动命令为:
nohup sh mqbroker -n localhost:9876 -c ../conf/broker.conf autoCreateTopicEnable=true &
查看mqbroker是否连接上mqnamesrv
sh mqadmin clusterList -n localhost:9876
sh mqadmin clusterList -n 47.107.185.200:9876
启动日志:
tail -f ~/logs/rocketmqlogs/namesrv.log
启动错误日志:
rocketmq/bin/nohup.out
查看是否启动:
ps -ef | grep namesrv
ps -ef | grep mqbroker
或
ss -antulp |grep 9876
3、rocketmq服务关闭
关闭namesrv服务:sh ./mqshutdown namesrv
关闭broker服务 :sh ./mqshutdown broker
你想创建一个名为"tx-mq-TOPIC" 的主题。可以使用如下命令
目录:rocketmq/bin
./mqadmin updateTopic -n localhost:9876 -b localhost:10911 -t tx-mq-TOPIC2
注意:ip和端口号
参考:
https://www.jianshu.com/p/66bb3f575ff8
https://blog.csdn.net/mingtian625/article/details/49307189
https://blog.csdn.net/qq_14853889/article/details/81053145?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-3