本文主要是介绍centos7 安装rocketmq4.7.0以及RocketMQ-Console-Ng控制台,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、前置工作
1.1安装jdk8
https://blog.csdn.net/pang_ping/article/details/80570011
1.2安装maven
https://www.cnblogs.com/116970u/p/11211963.html
1.3安装git
https://blog.csdn.net/xwj1992930/article/details/96428998
二、安装rocketmq
大部分的步骤在官网上面都有显示,链接:http://rocketmq.apache.org/docs/quick-start/
不过需要注意单机情况下,尤其是内存不足的时候有许多的注意事项,下面从头开始安装。
2.1 下载最新版rocketmq 4.7.0,并且解压
mkdir /opt/software/
cd /opt/software/
wget https://archive.apache.org/dist/rocketmq/4.7.0/rocketmq-all-4.7.0-source-release.zip
unzip rocketmq-all-4.7.0-source-release.zip
cd rocketmq-all-4.7.0-source-release/
mvn -Prelease-all -DskipTests clean install -U
2.2 修改三个sh文件
cd /opt/software/rocketmq-all-4.7.0-source-release/distribution/target/rocketmq-4.7.0/rocketmq-4.7.0
vim bin/runserver.sh
vim bin/runbroker.sh
vim bin/tools.sh
将三个文件中的Xms,Xmx,Xmn三个参数修改为合适的数值
JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
将三个文件27-29行中的JAVA_HOME设置为本机的java路径,并注释下面两行,不然会报java环境错误
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=JAVA_HOME=/usr/local/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)!"
修改完毕后保存
三、校验安装
3.1启动mqnamesrv
nohup sh bin/mqnamesrv &
tail -f ~/logs/rocketmqlogs/namesrv.log
出现
The Name Server boot success...为成功
3.2启动Broker
nohup sh bin/mqbroker -n localhost:9876 &
tail -f ~/logs/rocketmqlogs/broker.log
出现
The broker[%s, 172.30.30.233:10911] boot success...为成功
如果部署在外网上面,需要公网ip访问的话,最好修改conf/broker.conf,新增
brokerIP1=X.X.X.X(公网IP)
同时启动时采用命令:
nohup sh bin/mqbroker -n <公网ip>:9876 -c conf/broker.conf autoCreateTopicEnable=true &
注意:利用公网部署的时候需要关闭selinux,开放端口9876和10911
3.3 利用rocketmq中的快速启动类校验收发消息
> export NAMESRV_ADDR=localhost:9876> 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...为消费成功
四、安装可视化控制台
4.1 官方地址:
https://github.com/apache/rocketmq-externals/tree/master/rocketmq-console
4.2 git拉取源码
cd /opt/software
git clone https://github.com/apache/rocketmq-externals.git
4.3 修改配置文件
cd /opt/software/rocketmq-externals/rocketmq-console/src/main/resources
vim application.properties
将rocketmq.config.isVIPChannel设置为false,配置rocketmq.config.namesrvAddr为 本机地址:9876,可以选择性修改port或者下一步再命令中指定
server.contextPath=
server.port=7777### SSL setting
#server.ssl.key-store=classpath:rmqcngkeystore.jks
#server.ssl.key-store-password=rocketmq
#server.ssl.keyStoreType=PKCS12
#server.ssl.keyAlias=rmqcngkey#spring.application.index=true
spring.application.name=rocketmq-console
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
logging.config=classpath:logback.xml
#if this value is empty,use env value rocketmq.config.namesrvAddr NAMESRV_ADDR | now, you can set it in ops page.default localhost:9876
rocketmq.config.namesrvAddr=192.168.50.195:9876
#if you use rocketmq version < 3.5.8, rocketmq.config.isVIPChannel should be false.default true
rocketmq.config.isVIPChannel=false
#rocketmq-console's data path:dashboard/monitor
rocketmq.config.dataPath=/tmp/rocketmq-console/data
#set it false if you don't want use dashboard.default true
rocketmq.config.enableDashBoardCollect=true
#set the message track trace topic if you don't want use the default one
rocketmq.config.msgTrackTopicName=
rocketmq.config.ticketKey=ticket#Must create userInfo file: ${rocketmq.config.dataPath}/users.properties if the login is required
rocketmq.config.loginRequired=false
利用maven打包
mvn clean package -Dmaven.test.skip=true
关于打包报错:https://blog.csdn.net/qq_37495786/article/details/102620550
运行jar包,启动项目,这里也可以设置rocketmq.config.namesrvAdd:和port
java -jar rocketmq-console-ng-1.0.1.jar
#或者加入addr和port
java -jar rocketmq-console-ng-1.0.0.jar --server.port=7777 --rocketmq.config.namesrvAddr=192.168.50.195:9876
需要后台启动加入nohup,启动后的首页如图
http://192.168.50.195:7777/#/
这篇关于centos7 安装rocketmq4.7.0以及RocketMQ-Console-Ng控制台的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!