RocketMQ 4.3.2 standalone Installation and Configuration

1 Download RockeMQ Package:

  You need to download it and put it to the OS Image.

wget http: //apache .claz.org /rocketmq/4 .3.2 /rocketmq-all-4 .3.2-bin-release.zip and unzip the package to  /opt/rocketmq


2 Prerequsite

 JDK installed.

3 Create service account for Jetty

useradd  -m rocketmq echo  "umask 002"  >>  /home/rocketmq/ .bash_profile


4 Modify PATH system variable
4

run  /opt/rocketmq/bin/os .sh change JVM parameters  in  /opt/rocketmq/bin/runserver .sh

 


5 Configure RocketMQ

run  /opt/rocketmq/bin/os .sh change JVM parameters  in  /opt/rocketmq/bin/runserver .sh change JVM parameters  in  /opt/rocketmq/bin/runbroker .sh #Note: Usually set the Xmn to 1/8 or Xmx

 

8 Add RocketMQ to system service

 

cd  /etc/init .d vi  rocketmq  and add     #!/usr/bin/env bash # # rocketmq - this script starts and stops the rocketmq daemon # # chkconfig:   - 85 15 ROCKETMQ_HOME= /opt/rocketmq ROCKETMQ_BIN=${ROCKETMQ_HOME} /bin ADDR=` hostname  -i`:9876 LOG_DIR=${ROCKETMQ_HOME} /logs NAMESERVER_LOG=${LOG_DIR} /namesrv .log BROKER_LOG=${LOG_DIR} /broker .log start() {      if  [ ! -d ${LOG_DIR} ]; then         su  - rocketmq -c  "mkdir ${LOG_DIR}"      fi      cd  ${ROCKETMQ_HOME}      su  - rocketmq -c   "nohup sh $ROCKETMQ_HOME/bin/mqnamesrv > ${NAMESERVER_LOG} 2>&1 &"      echo   "The Name Server boot success..."      su  - rocketmq -c   "nohup  sh $ROCKETMQ_HOME/bin/mqbroker -n ${ADDR} > ${BROKER_LOG} 2>&1 &"      echo   "The broker[%s, ${ADDR}] boot success..." } stop() {      cd  ${ROCKETMQ_HOME}      su  - rocketmq -c  "sh $ROCKETMQ_HOME/bin/mqshutdown broker"      sleep  1      su  - rocketmq -c  "sh $ROCKETMQ_HOME/bin/mqshutdown namesrv" } restart() {      stop      sleep  5      start } case  "$1"  in      start)          start          ;;      stop)          stop          ;;      restart)          restart          ;;      *)          echo  $ "Usage: $0 {start|stop|restart}"          exit  2 esac     ################################################# chmod  a+x rocketmq chkconfig --add rocketmq chown  -R rocketmq:rocketmq  /opt/rocketmq

9 add a boot script to setup Rocketmq JVM(below script is only for standalone mode)

#!/bin/bash #set -x #this script is only going to set Rocketmq standalone installation(nameserver and broker server in a same host)   RQ_HOME_BIN= /opt/rocketmq/bin #RQ_HOME_BIN=/home/dc-user/rq/rocketmq-all-4.3.2-bin-release/bin #$RQ_HOME_BIN/runserver.sh to modify the #39  JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m" #$RQ_HOME_BIN/runbroker.sh to modify the #39   JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g" #get current physical memory setting mem_size=` free  -m |  grep  Mem |  awk  '{print $2}' ` #set jetty JVM xmx to 50% of mem jmem=$(($mem_size /4 )) jmemn=$(($jmem /2 )) jmem=$jmem "m" jmemn=$jmemn "m" sed  -i  "s/-Xmn[0-9]\+[g|m]/-Xmn$jmemn/g"  $RQ_HOME_BIN /runserver .sh sed  -i  "s/-Xms[0-9]\+[g|m]/-Xms$jmem/g"  $RQ_HOME_BIN /runserver .sh sed  -i  "s/-Xmx[0-9]\+[g|m]/-Xmx$jmem/g"  $RQ_HOME_BIN /runserver .sh sed  -i  "s/-Xmn[0-9]\+[g|m]/-Xmn$jmemn/g"  $RQ_HOME_BIN /runbroker .sh sed  -i  "s/-Xms[0-9]\+[g|m]/-Xms$jmem/g"  $RQ_HOME_BIN /runbroker .sh sed  -i  "s/-Xmx[0-9]\+[g|m]/-Xmx$jmem/g"  $RQ_HOME_BIN /runbroker .sh