安裝Rocketmq

北方姆Q發表於2024-12-06

本次要求是單機版

1.首先需要安裝完成JDK環境

2.下載所需要版本包及dashboard包

[root@app-bj-ali-ecs1 ~]# wget https://dist.apache.org/repos/dist/release/rocketmq/5.1.4/rocketmq-all-5.1.4-bin-release.zip
[root@app-bj-ali-ecs1 ~]# wget https://dist.apache.org/repos/dist/release/rocketmq/rocketmq-dashboard/1.0.0/rocketmq-dashboard-1.0.0-source-release.zip
[root@app-bj-ali-ecs1 ~]# unzip rocketmq-all-5.1.4-bin-release.zip
[root@app-bj-ali-ecs1 ~]# unzip rocketmq-dashboard-1.0.0-source-release.zip
[root@app-bj-ali-ecs1 ~]# ls
rocketmq-all-5.1.4-bin-release  rocketmq-all-5.1.4-bin-release.zip  rocketmq-dashboard-1.0.0  rocketmq-dashboard-1.0.0-source-release.zip
[root@app-bj-ali-ecs1 ~]# mv rocketmq-all-5.1.4-bin-release /usr/local/
[root@app-bj-ali-ecs1 ~]# mv rocketmq-dashboard-1.0.0 /usr/local/

3.配置rocketmq namesrv

[root@app-bj-ali-ecs1 ~]# cd /usr/local/
[root@app-bj-ali-ecs1 local]# vim rocketmq-all-5.1.4-bin-release/conf/namesrv.properties # 新增一個檔案,名字必須是namesrv.properties!!!
[root@app-bj-ali-ecs1 local]# cat rocketmq-all-5.1.4-bin-release/conf/namesrv.properties
listenPort=8028    # 開啟一個監聽埠即可

4.配置rocketmq broker

[root@app-bj-ali-ecs1 ~]# mkdir -p /data/mqbroker/store # 後面佇列資料都會放在這個目錄裡
[root@app-bj-ali-ecs1 local]# cat rocketmq-all-5.1.4-bin-release/conf/broker.conf
# 追加下列內容
namesrvAddr=172.18.169.29:8028    # 換成自己的ip跟剛才namesrv的port
brokerIP1=172.18.169.29     # 換成自己的ip
listenPort=8029        # 換成自己監聽的port,與namesrv不同
storePathRootDir=/data/mqbroker/store   # 剛才建立的資料目錄
storePathCommitLog=/data/mqbroker/store/commitlog
storePathConsumerQueue=/data/mqbroker/store/consumequeue
storePathIndex=/data/mqbroker/store/index
storeCheckpoint=/data/mqbroker/store/checkpoint
abortFile=/data/mqbroker/store/abort

5.安裝dashboard

[root@app-bj-ali-ecs1 ~]# cd /usr/local/rocketmq-dashboard-1.0.0/
[root@app-bj-ali-ecs1 rocketmq-dashboard-1.0.0]# mvn clean package -Dmaven.test.skip=true
[root@app-bj-ali-ecs1 rocketmq-dashboard-1.0.0]# cd /usr/local/
[root@app-bj-ali-ecs1 local]# mv rocketmq-all-5.1.4-bin-release rocketmq
[root@app-bj-ali-ecs1 local]# mv rocketmq-dashboard-1.0.0/target/rocketmq-dashboard-1.0.0.jar rocketmq/  # 將編譯好的dashboard jar包放進統一目錄
[root@app-bj-ali-ecs1 local]# vim rocketmq/conf/application.properties # 注意這裡是寫在了rocketmq目錄裡
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

server.address=0.0.0.0
server.port=8031

### SSL setting
#server.ssl.key-store=classpath:rmqcngkeystore.jks
#server.ssl.key-store-password=rocketmq
#server.ssl.keyStoreType=PKCS12
#server.ssl.keyAlias=rmqcngkey

#spring.application.index=true
spring.application.name=rocketmq-dashboard
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
logging.level.root=INFO
logging.config=classpath:logback.xml
#if this value is empty,use env value rocketmq.config.namesrvAddr  NAMESRV_ADDR | now, you can set it in ops page.default localhost:9876
rocketmq.config.namesrvAddr=172.18.169.29:8028     # 改成自己的namesrv ip port
#if you use rocketmq version < 3.5.8, rocketmq.config.isVIPChannel should be false.default true
rocketmq.config.isVIPChannel=
#timeout for mqadminExt, default 5000ms
rocketmq.config.timeoutMillis=
#rocketmq-console's data path:dashboard/monitor
# rocketmq.config.dataPath=/tmp/rocketmq-console/data
#set it false if you don't want use dashboard.default true
rocketmq.config.enableDashBoardCollect=true
#set the message track trace topic if you don't want use the default one
rocketmq.config.msgTrackTopicName=
rocketmq.config.ticketKey=ticket

#Must create userInfo file: ${rocketmq.config.dataPath}/users.properties if the login is required
rocketmq.config.loginRequired=true
rocketmq.config.dataPath=/usr/local/rocketmq/conf
[root@app-bj-ali-ecs1 local]# cat rocketmq/conf/users.properties # 需要放在剛才的rocketmq.config.dataPath裡
#定義管理員 
admin
=admin,1
#定義普通使用者
user1
=user1
user2
=user2

6.建立便利指令碼

[root@app-bj-ali-ecs1 rocketmq]# cat start-namesrv.sh
#!/bin/sh
export SRV_NAME="namesrv"
ROCKETMQ_HOME=/usr/local/rocketmq
${ROCKETMQ_HOME}/bin/mqnamesrv -n 172.18.169.29:8028 -c ${ROCKETMQ_HOME}/conf/namesrv.properties  >>logs/rocketmqlogs/${SRV_NAME}.log &

[root@app-bj-ali-ecs1 rocketmq]# cat start-broker.sh
#!/bin/sh
export SRV_NAME="broker"
ROCKETMQ_HOME=/usr/local/rocketmq
${ROCKETMQ_HOME}/bin/mqbroker -c ${ROCKETMQ_HOME}/conf/broker.conf >>logs/rocketmqlogs/${SRV_NAME}.log &

[root@app-bj-ali-ecs1 rocketmq]# cat start-dashboard.sh
#!/bin/sh
SRV_NAME="dashboard"
JAVA_HOME=/usr/local/jdk1.8.0_361    # 換成你的java
ROCKETMQ_HOME=/usr/local/rocketmq
$JAVA_HOME/bin/java -server -Xms256m -Xmx256m -jar ${ROCKETMQ_HOME}/rocketmq-dashboard-1.0.0.jar  --spring.config.location=${ROCKETMQ_HOME}/conf/application.properties >>logs/rocketmqlogs/${SRV_NAME}.log &

[root@app-bj-ali-ecs1 rocketmq]# cat stop-namesrv.sh
#!/bin/sh
export SRV_NAME="namesrv"
ROCKETMQ_HOME=/usr/local/rocketmq
${ROCKETMQ_HOME}/bin/mqshutdown namesrv -c ${ROCKETMQ_HOME}/conf/namesrv.properties

[root@app-bj-ali-ecs1 rocketmq]# cat stop-broker.sh
#!/bin/sh
export SRV_NAME="broker"
ROCKETMQ_HOME=/usr/local/rocketmq
${ROCKETMQ_HOME}/bin/mqshutdown broker -c ${ROCKETMQ_HOME}/conf/broker.conf

[root@app-bj-ali-ecs1 rocketmq]# cat stop-dashboard.sh
#!/bin/sh
SRV_NAME="dashboard"
JAVA_HOME=/usr/local/jdk1.8.0_361
PID=`jps -l | grep dash | awk '{print $1}'`
if [ -z "$PID" ]; then
    echo "Process ${SRV_NAME} is not running."
else
    echo "stop ${SRV_NAME}"
    kill -9 $PID && echo "Process ${SRV_NAME} stop successful..."
fi

7.頁面登入驗證

相關文章