RocketMQ报错: commit_memory(0x00000006ec800000, 2147483648, 0) failed; error=‘Cannot allocate memory

2022-08-28 11:21:58 浏览数 (1)

大家好,又见面了,我是你们的朋友全栈君。

环境:

虚拟机测试环境,在向MQ推送消息发现连不上namesrv,查看

代码语言:javascript复制
netstat -antlp | grep 9876

发现namesrv进程已关闭。利用命令重启:

代码语言:javascript复制
sh /usr/local/rocketmq/rocketmq-all/bin/mqnamesrv

提示报错:

[root@hantest rocketmq-all]# sh /usr/local/rocketmq/rocketmq-all/bin/mqnamesrv 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)

解决:

定位到是内存不足错误,采用调整参数扩容。

更改 bin/runserver.sh下的参数:

将上边一行改为下面一行即可。

代码语言:javascript复制
#JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn128m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"

重新运行启动脚本,启动成功。

踩坑

1 注意单位不一样,将 4g改为256m而不要忘了更改m,一开始忘了改单位所以报错:

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00007f26b0a00000, 274877841408, 0) failed; error=’Cannot allocate memory’ (errno=12)

2 xmn要小于前面的值,不然会报错

代码语言:javascript复制
OpenJDK 64-Bit Server VM warning: MaxNewSize (131072k) is equal to or greater than the entire heap (131072k).  A new max generation size of 131008k will be used.

参考:

哎,一古,金社长:博主:JAVA_OPT=”${JAVA_OPT} -server -Xms256m -Xmx256m -Xmn512m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m”这个配置有问题吧,Xms和Xmx都设置为256了,Xmn搞个512,新生代的大小比整个堆都大1 年前回复

参考链接

https://www.jianshu.com/p/837b4c6aee65

https://blog.csdn.net/jiangyu1013/article/details/81486374

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/146384.html原文链接:https://javaforall.cn

0 人点赞