一.RocketMQ官方启动脚本不支持大于jdk8的修改

1.1 启动命名服务器(sh mqnamesrv)报错:


**
-Djava.ext.dirs=/usr/local/java/jdk-11.0.8/jre/lib/ext:/usr/RocketMQ/rocketmq-all-4.8.0-bin-release/bin/../lib:/usr/local/java/jdk-11.0.8/lib/ext is not supported. Use -classpath instead.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

原因:RocketMQ官方启动脚本不支持jdk11的修改,官方都是以jdk8进行配置的。如果想使用高版本的jdk,解决方案:

修改runserver.sh

  • 删除 -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection和-XX:-UseParNewGC和-XX:+PrintGCDetails
  • -Xloggc:改成-Xlog:gc:
  • 删除 JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib"

1.2 启动消息服务器(sh mqbroker -n localhost:9876)报错:


[0.000s][warning][gc] -Xloggc is deprecated. Will use -Xlog:gc:/dev/shm/rmqbroker_gc%p_%t.log instead.
Unrecognized VM option ‘PrintGCDateStamps’
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

原因同上,解决方案:

修改runbroker.sh

  • 删除 -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy 和 JAVA_OPT=”${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m” 和-XX:+PrintGCDetails
  • -Xloggc:改成-Xlog:gc:
  • 删除 JAVA_OPT=”${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib”

二. rocketmq broker启动报错,找不到或无法加载主类

原因:JAVAHOME环境变量路径中包含空格.
方案:修改runbroker.sh,将set "JAVA_OPT=%JAVA_OPT% -cp %CLASSPATH%" 改成:set "JAVA_OPT=%JAVA_OPT% -cp "%CLASSPATH%""