RocketMQ启动失败
报错信息
[root@VM-16-6-centos bin]# sh mqnamesrv
Java HotSpot™ 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
Java HotSpot™ 64-Bit Server VM warning: UseCMSCompactAtFullCollection is deprecated and will likely be removed in a future release.
Java HotSpot™ 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:
/opt/rocketmq-all-4.5.2-bin-release/bin/hs_err_pid15105.log
参考网址
https://cloud.tencent.com/developer/article/1979870?from=article.detail.1966342&areaSource=106000.15&traceId=WbFBSBEPwCt30YYar1_to
原因
jvm 分配内存不够
修改目录 /distribution/target/apache-rocketmq/bin 下的 3 个配置文件: runserver.sh、runbroker.sh 、tools.sh 。 设置 runserver.sh 中此项配置 为:
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
复制
设置 runbroker.sh 中此项配置 为:
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m"
复制
(我改了 runserver.sh、runbroker.sh 依旧不行,后来注意到 tools.sh 中也有配置,3个都改就行了)
设置 tools.sh 中此项配置 为:
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn256m -XX:PermSize=128m -XX:MaxPermSize=128m"
复制
完成以上操作,后续测试就成功运行了。