部署RocketMQ

安装JDK

  • 软件版本:11
  • 安装目录:/usr/local/jdk11(vi /etc/profile)
# 自定义环境变量
export JAVA_HOME=/usr/local/jdk11
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib

安装RocketMQ

  • 仓库地址:https://github.com/apache/rocketmq.git
  • 软件版本:4.7.1
  • 安装包下载目录:https://mirror.bit.edu.cn/apache/rocketmq/4.7.1/rocketmq-all-4.7.1-bin-release.zip(https://rocketmq.apache.org/community中Latest release v4.7.1)
  • 安装目录:/usr/local/rocketmq-all-4.7.1-bin-release
  • 配置环境变量
export JAVA_HOME=/usr/local/jdk11
export ROCKETMQ_HOME=/usr/local/rocketmq-all-4.7.1-bin-release
export PATH=$PATH:$JAVA_HOME/bin:$ROCKETMQ_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib:${ROCKETMQ_HOME}/lib/rocketmq-broker-4.7.1.jar:${ROCKETMQ_HOME}/lib/*:${ROCKETMQ_HOME}/conf/
  • 修改NameServer的启动配置(vi /usr/local/rocketmq-all-4.7.1-bin-release/bin/runserver.sh)JDK1.8无需改动
#JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
#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"
#JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
#JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages"
#JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib:${JAVA_HOME}/lib/ext"
#JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
#JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
#JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"

JAVA_OPT="${JAVA_OPT} -server -Xms4g -Xmx4g -Xmn2g"
JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0"
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=15g"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-UseBiasedLocking"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
JAVA_OPT="${JAVA_OPT} --add-exports java.base/jdk.internal.ref=ALL-UNNAMED"
  • 修改Broker的启动配置(vi /usr/local/rocketmq-all-4.7.1-bin-release/bin/runbroker.sh)JDK1.8无需改动
#JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g"
#JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0"
#JAVA_OPT="${JAVA_OPT} -verbose:gc -Xloggc:${GC_LOG_DIR}/rmq_broker_gc_%p_%t.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:+PrintAdaptiveSizePolicy"
#JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
#JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
#JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
#JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=15g"
#JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-UseBiasedLocking"
#JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${BASE_DIR}/lib:${JAVA_HOME}/lib/ext"
#JAVA_OPT="${JAVA_OPT} -Xdebug -Xrunjdwp:transport=dt_socket,address=9555,server=y,suspend=n"
#JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
#JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"

JAVA_OPT="${JAVA_OPT} -server -Xms8g -Xmx8g -Xmn4g"
JAVA_OPT="${JAVA_OPT} -XX:+UseG1GC -XX:G1HeapRegionSize=16m -XX:G1ReservePercent=25 -XX:InitiatingHeapOccupancyPercent=30 -XX:SoftRefLRUPolicyMSPerMB=0"
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=15g"
JAVA_OPT="${JAVA_OPT} -XX:-UseLargePages -XX:-UseBiasedLocking"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} -cp ${CLASSPATH}"
JAVA_OPT="${JAVA_OPT} --add-exports java.base/jdk.internal.ref=ALL-UNNAMED"
# 支持远程调试
JAVA_OPT="${JAVA_OPT} -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=0.0.0.0:5005"
  • 配置Broker(vi /usr/local/rocketmq-all-4.7.1-bin-release/conf/broker.conf)
# 追加以下配置

# nameServer地址,分号分割
namesrvAddr=192.168.1.49(本机IP):9876

# 本机ip地址,默认系统自动识别,但是某些多网卡机器会存在识别错误的情况,这种情况下可以人工配置。
brokerIP1=192.168.1.49(本机IP)
  • 启动与停止NameServer
cd /usr/local/rocketmq-all-4.7.1-bin-release
# 启动
nohup sh bin/mqnamesrv > ns.log 2>&1 &
# 停止
./bin/mqshutdown namesrv
  • 启动与停止Broker
cd /usr/local/rocketmq-all-4.7.1-bin-release
# 启动
nohup sh bin/mqbroker -c conf/broker.conf > bk.log 2>&1 &
# 停止
./bin/mqshutdown broker
  • 日志文件:/root/logs/rocketmqlogs

安装RocketMQ Console

  • 仓库地址:https://github.com/apache/rocketmq-externals.git
  • 软件版本:2.0.0
  • 模块名称:rocketmq-console
  • 安装包下载目录:需要下载代码并编译打包RocketMQ Console模块
  • 安装目录:/usr/local/rocketmq-all-4.7.1-bin-release/console
  • 启动成功后访问地址:http://192.168.1.49(本机IP):8080
# 编译模块rocketmq-console为一个jar
# 运行jar
mkdir /usr/local/rocketmq-all-4.7.1-bin-release/console
cd /usr/local/rocketmq-all-4.7.1-bin-release/console
nohup java -jar rocketmq-console-ng-2.0.0.jar --server.port=8080 --rocketmq.config.namesrvAddr=192.168.1.49(本机IP):9876 1>nohup.log 2>&1 &

你可能感兴趣的:(部署RocketMQ)