centos7 安装rocketmq

rocketmq 官网地址:https://rocketmq.apache.org/zh/download

1、下载

wget https://dist.apache.org/repos/dist/release/rocketmq/5.2.0/rocketmq-all-5.2.0-bin-release.zip

2、解压

unzip rocketmq-all-5.2.0-bin-release.zip -d /data/

3、配置broker,新增brokerIP1和namesrvAddr

vim /data/rocketmq-all-5.2.0-bin-release/conf/broker.conf

brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH

brokerIP1=192.168.20.144
namesrvAddr=192.168.20.144:9876

4、修改rocket占用的内存

# 修改runserver.sh
vim /data/rocketmq-all-5.2.0-bin-release/bin/runserver.sh
choose_gc_options()
{
    # Example of JAVA_MAJOR_VERSION value : '1', '9', '10', '11', ...
    # '1' means releases before Java 9
    JAVA_MAJOR_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}' | awk -F '.' '{print $1}')
    if [ -z "$JAVA_MAJOR_VERSION" ] || [ "$JAVA_MAJOR_VERSION" -lt "9" ] ; then
      JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -Xmn500m -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 -XX:+PrintGCDateStamps"
      JAVA_OPT="${JAVA_OPT} -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=30m"
    else
      JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m"
      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
}

 

# 修改runbroker.sh
vim /data/rocketmq-all-5.2.0-bin-release/bin/runbroker.sh
JAVA_OPT="${JAVA_OPT} -server -Xms1g -Xmx1g"
choose_gc_options
JAVA_OPT="${JAVA_OPT} -XX:-OmitStackTraceInFastThrow"
JAVA_OPT="${JAVA_OPT} -XX:+AlwaysPreTouch"
JAVA_OPT="${JAVA_OPT} -XX:MaxDirectMemorySize=1g"

 

5、启动namesrv

nohup sh /data/rocketmq-all-5.2.0-bin-release/bin/mqnamesrv &> /data/rocketmq-all-5.2.0-bin-release/mqnamesrv.log  &

6、启动broker

nohup /data/rocketmq-all-5.2.0-bin-release/bin/mqbroker -n 0.0.0.0:9876 autoCreateTopicEnable=true &> /data/rocketmq-all-5.2.0-bin-release/mqbroker.log &

 

7、查看是否启动成功

[root@localhost bin]# jps 
22256 BrokerStartup
21938 NamesrvStartup
22569 Jps
[root@loc

 

8、部署可视化工具RocketMQ Dashboard,官网地址:https://rocketmq.apache.org/zh/download#rocketmq-dashboard。参考:https://blog.csdn.net/weixin_43811294/article/details/132307717

wget https://dist.apache.org/repos/dist/release/rocketmq/rocketmq-dashboard/1.0.0/rocketmq-dashboard-1.0.0-source-release.zip

9、解压

 unzip rocketmq-dashboard-1.0.0-source-release.zip -d /data/

10、打包。注意maven版本官方推荐3.2+

cd /data/rocketmq-dashboard-1.0.0/
mvn clean package -Dmaven.test.skip=true

11、修改jar包的namesrv地址配置

vim rocketmq-dashboard-1.0.0.jar
rocketmq:
  config:
    # if this value is empty,use env value rocketmq.config.namesrvAddr  NAMESRV_ADDR | now, default localhost:9876
    # configure multiple namesrv addresses to manage multiple different clusters
    namesrvAddrs:
      - 192.168.20.144:9876
    # if you use rocketmq version < 3.5.8, rocketmq.config.isVIPChannel should be false.default true
    isVIPChannel:
    # timeout for mqadminExt, default 5000ms
    timeoutMillis:
    # rocketmq-console's data path:dashboard/monitor
    dataPath: /tmp/rocketmq-console/data

 12、可视化面板开启账号密码登录,创建在rocketmq.config.dataPath指定的目录下创建 users.properties

vim rocketmq-dashboard-1.0.0.jar
rocketmq.config.dataPath=/data/config

rocketmq.config.loginRequired=true
mkdir config && cd config

vim users.properties

# 账号=密码,类型       0普通人员 1管理员
admin=sykj@2024,1

 

13、启动可视化面板

 

 nohup java -jar rocketmq-dashboard-1.0.0.jar &> rocketmq-dashboard.log &

 

关闭NameServer和Broker

/data/rocketmq-all-5.2.0-bin-release/bin/mqshutdown namesrv
/data/rocketmq-all-5.2.0-bin-release/bin/mqshutdown  broker

 

posted @ 2024-03-20 11:39  苦逼yw  阅读(545)  评论(0编辑  收藏  举报