CentOS搭建RocketMQ

1.下载rocketMQ安装包

下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache/rocketmq
根据自己的需求下载相应版本,我下载的是:
rocketmq-all-4.3.1-bin-release.zip

2.解压

unzip rocketmq-all-4.3.1-bin-release.zip

3.进入目录

cd rocketmq-all-4.3.1-bin-release/bin

4.启动server

./mqnamesrv
如下图:The Name server boot success,server就成功启动了
在这里插入图片描述

5.启动broken

./mqbroker -n localhost:9876
如下图:The broken boot success,broken就成功启动了
在这里插入图片描述

在启动的过程中,我遇到了如下问题:

OpenJDK 64-Bit Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release
OpenJDK 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000006ec800000, 2147483648, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2147483648 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /usr/rocketmq/rocketmq-all-4.3.1-bin-release/bin/hs_err_pid18525.log
OpenJDK 64-Bit Server VM warning: Using the DefNew young collector with the CMS collector is deprecated and will likely be removed in a future release
OpenJDK 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000006ec800000, 2147483648, 0) failed; error='Cannot allocate memory' (errno=12)

是因为我的服务器配置太低了,内存不够分配。
修改默认大小空间配置,原本是设置的为 4G、4G、8G,我的服务器内存没有那么大。
runserver.sh
改为JAVA_OPT=" J A V A O P T s e r v e r X m s 1 g X m x 1 g X m n 512 m X X : M e t a s p a c e S i z e = 128 m X X : M a x M e t a s p a c e S i z e = 320 m " r u n b r o k e n . s h J A V A O P T = " {JAVA_OPT} -server -Xms1g -Xmx1g -Xmn512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m" runbroken.sh 改为:JAVA_OPT=" {JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m"

6.停止命令

./mqshutdown broken
./mqshutdown namesrv

7.搭建console

下载源码:https://github.com/apache/rocketmq-externals

下载源码后,进入rocketmq-console项目下,找到配置文件application.properties,并按照自己需求进行配置。

例如:

server.contextPath=
#监控平台运行后的端口后
server.port=8070
#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=127.0.0.1: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=/usr/rocketmq/rocketmq-all-4.3.1-bin-release
#set it false if you don't want use dashboard.default true
rocketmq.config.enableDashBoardCollect=true

rocketmq.config.namesrvAddr=namesrv服务地址(ip1:port;ip2:port)

在文件根目录执行命令:

mvn clean package -Dmaven.test.skip=true

然后在target目录下找到文件rocketmq-console-ng-1.0.0.jar

启动rocketmq-console,执行命令:

java -jar rocketmq-console-ng-1.0.0.jar(或 java -jar rocketmq-console-ng-1.0.0.jar --server.port=8070 --rocketmq.config.namesrvAddr=127.0.0.1:9876)
在这里插入图片描述
在浏览器访问http://localhost:8070出现如上界面,说明搭建成功了

猜你喜欢

转载自blog.csdn.net/u012424449/article/details/84068219
今日推荐