rocketmq 4.8版本 ubuntu20 server 安装记录

rocketmq 安装记录

遇到的问题

  • 启动报错,报错如下
Unrecognized option: -Xlog:gc*:file=/dev/shm/rmq_srv_gc_%p_%t.log:time,tags:filecount=5,filesize=30M
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

这个是因为启动脚本的BUG,误判了JDK版本,我的是1.8版本,所以注释以下代码即可
bin/runserver.sh文件
修改内容如下

choose_gc_options()
{
    # Example of JAVA_MAJOR_VERSION value : '1', '9', '10', '11', ...
    # '1' means releases befor Java 9
    JAVA_MAJOR_VERSION=$("$JAVA" -version 2>&1 | sed -E -n 's/.* version "([0-9]*).*$/\1/p')
#    if [[ "$JAVA_MAJOR_VERSION" -lt "9" ]] ; then
      JAVA_OPT="${JAVA_OPT} -XX:+UseConcMarkSweepGC -XX:+UseCMSCompactAtFullCollection -XX:CMSInitiatingOccupancyFraction=70 -XX:+CMSParallelRemarkEnabled -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+CMSClassUnloadingEnabled -XX:SurvivorRatio=8 -XX:-UseParNewGC"
      JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:${GC_LOG_DIR}/rmq_srv_gc_%p_%t.log -XX:+PrintGCDetails"
      JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
#    else
#      JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0"
#      JAVA_OPT="${JAVA_OPT} -Xlog:gc*:file=${GC_LOG_DIR}/rmq_srv_gc_%p_%t.log:time,tags:filecount=5,filesize=30M"
#    fi
}

注释掉判断即可

  • 内存小的机器启动不起来,因为启动配置中内存配置的太大了,4g以上的内存了,改小就好了
    修改 bin/runserver.sh文件
    JAVA_OPT="${JAVA_OPT} -server -Xms256m -Xmx500m -Xmn500g -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=128m"
    修改 bin/runbroker.sh文件
    JAVA_OPT="${JAVA_OPT} -server -Xms128m -Xmx256m -Xmn256m"

启动命令

cd /home/virde/program/rocketmq-all-4.8.0-bin-release

-- 启动namesrv
nohup sh ./bin/mqnamesrv >> ./logs/namesrv.log &

-- 启动broker
nohup sh bin/mqbroker -n localhost:9876 >> ./logs/mqbroker.log &


上一篇:安装Ubuntu20后需要做的事


下一篇:Ubuntu20 ros