天天看點

docker部署 MQ一、MQ

一、MQ

1、簡介

消息隊列 RocketMQ 版是阿裡雲基于 Apache RocketMQ 建構的低延遲、高并發、高可用、高可靠的分布式消息中間件。消息隊列 RocketMQ 版既可為分布式應用系統提供異步解耦和削峰填谷的能力,同時也具備網際網路應用所需的海量消息堆積、高吞吐、可靠重試等特性。
           

2、名詞

Topic:消息主題,一級消息類型,生産者向其發送消息。
生産者(producer):也稱為消息釋出者,負責生産并發送消息至 Topic。
生産者組(producer group):簡單來說就是多個發送同一類消息的生産者稱之為一個生産者組。
消費者(consumer):也稱為消息訂閱者,負責從 Topic 接收并消費消息。
消費者組(consumer group):和生産者類似,消費同一類消息的多個 Consumer 執行個體組成一個消費者組。
消息(message):生産者向 Topic 發送并最終傳送給消費者的資料和(可選)屬性的組合。
消息屬性:生産者可以為消息定義的屬性,包含 Message Key 和 Tag。
Group:一類生産者或消費者,這類生産者或消費者通常生産或消費同一類消息,且消息釋出或訂閱的邏輯一緻。
broker:RocketMQ核心子產品,接收并存儲消息,同僚提供push/pull接口将消息發送給consumer,多個主/從組成叢集,同時提供消息查詢功能,broker會将自己的topic配置資訊實時同步至nameserver
queue:Topic和Queue是1對多的關系,一個Topic下可以包含多個Queue,主要用于負載均衡。發送消息時,使用者隻指定Topic,Producer會根據Topic的路由資訊選擇具體發到哪個Queue上。Consumer訂閱消息時,會根據負載均衡政策決定訂閱哪些Queue的消息。
offset:RocketMQ在存儲消息時會為每個Topic下的每個Queue生成一個消息的索引檔案,每個Queue都對應一個Offset記錄目前Queue中消息條數。
nameserver:NameServer可以看作是RocketMQ的注冊中心,它管理兩部分資料:叢集的Topic-Queue的路由配置;Broker的實時配置資訊。其它子產品通過Nameserv提供的接口擷取最新的Topic配置和路由資訊。
           

3、消息發送模型

docker部署 MQ一、MQ

4、應用場景

削峰填谷
--諸如秒殺、搶紅包、企業開門紅等大型活動時皆會帶來較高的流量脈沖,或因沒做相應的保護而導緻系統超負荷甚至崩潰,或因限制太過導緻請求大量失敗而影響使用者體驗,消息隊列 RocketMQ 版可提供削峰填谷的服務來解決該問題。
異步解耦
--交易系統作為淘寶/天貓主站最核心的系統,每筆交易訂單資料的産生會引起幾百個下遊業務系統的關注,包括物流、購物車、積分、流計算分析等等,整體業務系統龐大而且複雜,消息隊列 RocketMQ 版可實作異步通信和應用解耦,確定主站業務的連續性。
順序收發
--細數日常中需要保證順序的應用場景非常多,例如證券交易過程時間優先原則,交易系統中的訂單建立、支付、退款等流程,航班中的旅客登機消息處理等等。與先進先出(First In First Out,縮寫 FIFO)原理類似,消息隊列 RocketMQ 版提供的順序消息即保證消息 FIFO。
分布式事務一緻性
--交易系統、支付紅包等場景需要確定資料的最終一緻性,大量引入消息隊列 RocketMQ 版的分布式事務,既可以實作系統之間的解耦,又可以保證最終的資料一緻性。
大資料分析
--資料在“流動”中産生價值,傳統資料分析大多是基于批量計算模型,而無法做到實時的資料分析,利用阿裡雲消息隊列 RocketMQ 版與流式計算引擎相結合,可以很友善的實作将業務資料進行實時分析。
分布式緩存同步
--天貓雙 11 大促,各個分會場琳琅滿目的商品需要實時感覺價格變化,大量并發通路資料庫導緻會場頁面響應時間長,集中式緩存因為帶寬瓶頸限制商品變更的通路流量,通過消息隊列 RocketMQ 版建構分布式緩存,實時通知商品資料的變化。
           

二、部署(雙主雙從)

主機A 部署

1、使用git克隆docker配置
選擇目錄:cd /home
克隆鏡像:git clone  https://github.com/foxiswho/docker-rocketmq.git
           
2、compose檔案

進入克隆後的目錄:/home/docker-rocketmq編輯compose檔案(docker-compose.yml)

version: '3.5'

services:
  rmqnamesrv:
    image: foxiswho/rocketmq:4.7.0
    container_name: rmqnamesrv
    ports:
      - 9876:9876
    volumes:
      - ./rmqs/logs:/opt/logs
      - ./rmqs/store:/opt/store
    environment:
      JAVA_OPT_EXT: "-Duser.home=/opt -Xms512M -Xmx512M -Xmn128m"
    command: ["sh","mqnamesrv"]
    networks:
        rmq:
          aliases:
            - rmqnamesrv
  
  rmqbroker-a:
    image: foxiswho/rocketmq:4.7.0
    container_name: rmqbroker-a
    ports:
      - 10911:10911
      - 10912:10912
    volumes:
      - ./rmq-a/logs:/opt/logs
      - ./rmq-a/store:/opt/store
      - ./rmq/brokerconf/broker-a.conf:/etc/rocketmq/broker.conf
      - /etc/hosts:/etc/hosts
    environment:
        JAVA_OPT_EXT: "-Duser.home=/opt -Xms512M -Xmx512M -Xmn128m"
    command: ["sh","mqbroker","-c","/etc/rocketmq/broker.conf","-n","rmqnamesrv1:9876;rmqnamesrv2:9876","autoCreateTopicEnable=true"]
#    depends_on:
#      - rmqnamesrv
    networks:
      rmq:
        aliases:
          - rmqbroker-a

  rmqbroker-b:
    image: foxiswho/rocketmq:4.7.0
    container_name: rmqbroker-b
    ports:
      - 10923:10923
      - 10924:10924
    volumes:
      - ./rmq-b/logs:/opt/logs
      - ./rmq-b/store:/opt/store
      - ./rmq/brokerconf/broker-b-s.conf:/etc/rocketmq/broker.conf
      - /etc/hosts:/etc/hosts
    environment:
        JAVA_OPT_EXT: "-Duser.home=/opt -Xms512M -Xmx512M -Xmn128m"
    command: ["sh","mqbroker","-c","/etc/rocketmq/broker.conf","-n","rmqnamesrv1:9876;rmqnamesrv2:9876","autoCreateTopicEnable=true"]
#    depends_on:
#      - rmqnamesrv
    networks:
      rmq:
        aliases:
          - rmqbroker-b

  rmqconsole:
    image: styletang/rocketmq-console-ng
    container_name: rmqconsole
    ports:
      - 8180:8080
    volumes: 
      - /etc/hosts:/etc/hosts
    environment:
        JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv1:9876;rmqnamesrv2:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
#    depends_on:
#      - rmqnamesrv
    networks:
      rmq:
        aliases:
          - rmqconsole

networks:
  rmq:
    name: rmq
    driver: bridge  
           
2、broker主節點配置

進入目錄:cd /home/docker-rocketmq/rmq/rmq/brokerconf

建立主節點配置檔案:vim broker-a.conf

檔案内容如下:

# 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.
 
#brokerClusterName=DefaultCluster
#brokerName=broker-a
#brokerId=0
#deleteWhen=04
#fileReservedTime=48
#brokerRole=ASYNC_MASTER
#flushDiskType=ASYNC_FLUSH
 
#所屬叢集名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此處不同的配置檔案填寫的不一樣
brokerName=broker-a
#0 表示 Master,>0 表示 Slave
brokerId=0
#nameServer位址,分号分割
#namesrvAddr=rmqnamesrv1:9876;rmqnamesrv2:9876
#在發送消息時,自動建立伺服器不存在的topic,預設建立的隊列數
defaultTopicQueueNums=4
#是否允許 Broker 自動建立Topic,建議線下開啟,線上關閉
autoCreateTopicEnable=true
#是否允許 Broker 自動建立訂閱組,建議線下開啟,線上關閉
autoCreateSubscriptionGroup=true
#Broker 對外服務的監聽端口
listenPort=10911
haListenPort=10912
#删除檔案時間點,預設淩晨 4點
deleteWhen=04
#檔案保留時間,預設 48 小時
fileReservedTime=720
#commitLog每個檔案的大小預設1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每個檔案預設存30W條,根據業務情況調整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#檢測實體檔案磁盤空間
diskMaxUsedSpaceRatio=88
#存儲路徑
#storePathRootDir=/home/rocketmq/store
#commitLog 存儲路徑
#storePathCommitLog=/home/rocketmq/store/commitlog
#消費隊列存儲路徑存儲路徑
#storePathConsumeQueue=/home/rocketmq/store/consumequeue
#消息索引存儲路徑
#storePathIndex=/home/rocketmq/store/index
#checkpoint 檔案存儲路徑
#storeCheckpoint=/home/rocketmq/store/checkpoint
#abort 檔案存儲路徑
#abortFile=/home/rocketmq/store/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 異步複制Master
#- SYNC_MASTER 同步雙寫Master
#- SLAVE
brokerRole=SYNC_MASTER
#刷盤方式
#- ASYNC_FLUSH 異步刷盤
#- SYNC_FLUSH 同步刷盤
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#發消息線程池數量
#sendMessageThreadPoolNums=128
#拉消息線程池數量
#pullMessageThreadPoolNums=128
#強制指定本機IP,需要根據每台機器進行修改。官方介紹可為空,系統預設自動識别,但多網卡時IP位址可能讀取錯誤
brokerIP1=114.114.114.114
           
3、broker備節點配置

進入目錄:cd /home/docker-rocketmq/rmq/rmq/brokerconf

建立主節點配置檔案:vim broker-b-s.conf

檔案内容如下:

# 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.
#brokerClusterName=DefaultCluster
#brokerName=broker-b
#brokerId=1
#deleteWhen=04
#fileReservedTime=48
#brokerRole=SLAVE
#flushDiskType=ASYNC_FLUSH
 
#所屬叢集名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此處不同的配置檔案填寫的不一樣
brokerName=broker-b
#0 表示 Master,>0 表示 Slave
brokerId=1
#nameServer位址,分号分割
#namesrvAddr=nameserver1:9876;nameserver2:9876
#在發送消息時,自動建立伺服器不存在的topic,預設建立的隊列數
defaultTopicQueueNums=4
#是否允許 Broker 自動建立Topic,建議線下開啟,線上關閉
autoCreateTopicEnable=true
#是否允許 Broker 自動建立訂閱組,建議線下開啟,線上關閉
autoCreateSubscriptionGroup=true
#Broker 對外服務的監聽端口
listenPort=10923
haListenPort=10924
#删除檔案時間點,預設淩晨 4點
deleteWhen=04
#檔案保留時間,預設 48 小時
fileReservedTime=720
#commitLog每個檔案的大小預設1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每個檔案預設存30W條,根據業務情況調整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#檢測實體檔案磁盤空間
diskMaxUsedSpaceRatio=88
#存儲路徑
#storePathRootDir=/home/rocketmq/store-s
#commitLog 存儲路徑
#storePathCommitLog=/home/rocketmq/store-s/commitlog
#消費隊列存儲路徑存儲路徑
#storePathConsumeQueue=/home/rocketmq/store-s/consumequeue
#消息索引存儲路徑
#storePathIndex=/home/rocketmq/store-s/index
#checkpoint 檔案存儲路徑
#storeCheckpoint=/home/rocketmq/store-s/checkpoint
#abort 檔案存儲路徑
#abortFile=/home/rocketmq/store-s/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushConsumeQueueLeastPages=2#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 異步複制Master
#- SYNC_MASTER 同步雙寫Master
#- SLAVE
brokerRole=SLAVE
#刷盤方式
#- ASYNC_FLUSH 異步刷盤
#- SYNC_FLUSH 同步刷盤
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#發消息線程池數量
#sendMessageThreadPoolNums=128
#拉消息線程池數量
#pullMessageThreadPoolNums=128
#強制指定本機IP,需要根據每台機器進行修改。官方介紹可為空,系統預設自動識别,但多網卡時IP位址可能讀取錯誤
brokerIP1=8.8.8.8
           
4、啟動腳本修改

進入目錄:cd /home/docker-rocketmq/rmq

編輯啟動腳本:vim start.sh

#!/usr/bin/env bash

# 建立目錄
mkdir -p ./rmqs/logs
mkdir -p ./rmqs/store
mkdir -p ./rmq/logs
mkdir -p ./rmq/store
mkdir -p ./rmq-a/logs
mkdir -p ./rmq-a/store
mkdir -p ./rmq-b/logs
mkdir -p ./rmq-b/store

# 設定目錄權限
chmod -R 777 ./rmqs/logs
chmod -R 777 ./rmqs/store
chmod -R 777 ./rmq/logs
chmod -R 777 ./rmq/store
chmod -R 777 ./rmq-a/logs
chmod -R 777 ./rmq-a/store
chmod -R 777 ./rmq-b/logs
chmod -R 777 ./rmq-b/store

# 下載下傳并啟動容器,且為 背景 自動啟動
docker-compose up -d

# 顯示 rocketmq 容器
docker ps |grep rocketmq
           
5、配置hosts檔案
114.11.44.11 rmqnamesrv1
114.11.44.12 rmqnamesrv2
           
6、啟動服務
cd /home/docker-rocketmq/rmq
./start.sh
           

主機B部署

1、使用git克隆docker配置
選擇目錄:cd /home
克隆鏡像:git clone  https://github.com/foxiswho/docker-rocketmq.git
           
2、compose檔案

​ 進入克隆後的目錄:/home/docker-rocketmq編輯compose檔案(docker-compose.yml)

version: '3.5'

services:
  rmqnamesrv:
    image: foxiswho/rocketmq:4.7.0
    container_name: rmqnamesrv
    ports:
      - 9876:9876
    volumes:
      - ./rmqs/logs:/opt/logs
      - ./rmqs/store:/opt/store
    environment:
      JAVA_OPT_EXT: "-Duser.home=/opt -Xms512M -Xmx512M -Xmn128m"
    command: ["sh","mqnamesrv"]
    networks:
        rmq:
          aliases:
            - rmqnamesrv
  
  rmqbroker-a:
    image: foxiswho/rocketmq:4.7.0
    container_name: rmqbroker-a
    ports:
      - 10911:10911
      - 10912:10912
    volumes:
      - ./rmq-a/logs:/opt/logs
      - ./rmq-a/store:/opt/store
      - ./rmq/brokerconf/broker-b.conf:/etc/rocketmq/broker.conf
      - /etc/hosts:/etc/hosts
    environment:
        JAVA_OPT_EXT: "-Duser.home=/opt -Xms512M -Xmx512M -Xmn128m"
    command: ["sh","mqbroker","-c","/etc/rocketmq/broker.conf","-n","rmqnamesrv1:9876;rmqnamesrv2:9876","autoCreateTopicEnable=true"]
    networks:
      rmq:
        aliases:
          - rmqbroker-a

  rmqbroker-b:
    image: foxiswho/rocketmq:4.7.0
    container_name: rmqbroker-b
    ports:
      - 10923:10923
      - 10924:10924
    volumes:
      - ./rmq-b/logs:/opt/logs
      - ./rmq-b/store:/opt/store
      - ./rmq/brokerconf/broker-a-s.conf:/etc/rocketmq/broker.conf
      - /etc/hosts:/etc/hosts
    environment:
        JAVA_OPT_EXT: "-Duser.home=/opt -Xms512M -Xmx512M -Xmn128m"
    command: ["sh","mqbroker","-c","/etc/rocketmq/broker.conf","-n","rmqnamesrv1:9876;rmqnamesrv2:9876","autoCreateTopicEnable=true"]
    networks:
      rmq:
        aliases:
          - rmqbroker-b

networks:
  rmq:
    name: rmq
    driver: bridge
           

2、broker主節點配置

進入目錄:cd /home/docker-rocketmq/rmq/rmq/brokerconf

建立主節點配置檔案:vim broker-b.conf

檔案内容如下:

# 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.
 
#brokerClusterName=DefaultCluster
#brokerName=broker-a
#brokerId=0
#deleteWhen=04
#fileReservedTime=48
#brokerRole=ASYNC_MASTER
#flushDiskType=ASYNC_FLUSH
 
#所屬叢集名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此處不同的配置檔案填寫的不一樣
brokerName=broker-b
#0 表示 Master,>0 表示 Slave
brokerId=0
#nameServer位址,分号分割
#namesrvAddr=nameserver1:9876;nameserver2:9876
#在發送消息時,自動建立伺服器不存在的topic,預設建立的隊列數
defaultTopicQueueNums=4
#是否允許 Broker 自動建立Topic,建議線下開啟,線上關閉
autoCreateTopicEnable=true
#是否允許 Broker 自動建立訂閱組,建議線下開啟,線上關閉
autoCreateSubscriptionGroup=true
#Broker 對外服務的監聽端口
listenPort=10911
haListenPort=10912
#删除檔案時間點,預設淩晨 4點
deleteWhen=04
#檔案保留時間,預設 48 小時
fileReservedTime=720
#commitLog每個檔案的大小預設1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每個檔案預設存30W條,根據業務情況調整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#檢測實體檔案磁盤空間
diskMaxUsedSpaceRatio=88
#存儲路徑
#storePathRootDir=/home/rocketmq/store
#commitLog 存儲路徑
#storePathCommitLog=/home/rocketmq/store/commitlog
#消費隊列存儲路徑存儲路徑
#storePathConsumeQueue=/home/rocketmq/store/consumequeue
#消息索引存儲路徑
#storePathIndex=/home/rocketmq/store/index
#checkpoint 檔案存儲路徑
#storeCheckpoint=/home/rocketmq/store/checkpoint
#abort 檔案存儲路徑
#abortFile=/home/rocketmq/store/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 異步複制Master
#- SYNC_MASTER 同步雙寫Master
#- SLAVE
brokerRole=SYNC_MASTER
#刷盤方式
#- ASYNC_FLUSH 異步刷盤
#- SYNC_FLUSH 同步刷盤
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#發消息線程池數量
#sendMessageThreadPoolNums=128
#拉消息線程池數量
#pullMessageThreadPoolNums=128
#強制指定本機IP,需要根據每台機器進行修改。官方介紹可為空,系統預設自動識别,但多網卡時IP位址可能讀取錯誤
brokerIP1=192.168.1.1
           
3、broker備節點配置

進入目錄:cd /home/docker-rocketmq/rmq/rmq/brokerconf

建立主節點配置檔案:vim broker-a-s.conf

檔案内容如下:

# 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.
#brokerClusterName=DefaultCluster
#brokerName=broker-b
#brokerId=1
#deleteWhen=04
#fileReservedTime=48
#brokerRole=SLAVE
#flushDiskType=ASYNC_FLUSH
 
#所屬叢集名字
brokerClusterName=rocketmq-cluster
#broker名字,注意此處不同的配置檔案填寫的不一樣
brokerName=broker-a
#0 表示 Master,>0 表示 Slave
brokerId=1
#nameServer位址,分号分割
#namesrvAddr=nameserver1:9876;nameserver2:9876
#在發送消息時,自動建立伺服器不存在的topic,預設建立的隊列數
defaultTopicQueueNums=4
#是否允許 Broker 自動建立Topic,建議線下開啟,線上關閉
autoCreateTopicEnable=true
#是否允許 Broker 自動建立訂閱組,建議線下開啟,線上關閉
autoCreateSubscriptionGroup=true
#Broker 對外服務的監聽端口
listenPort=10923
haListenPort=10924
#删除檔案時間點,預設淩晨 4點
deleteWhen=04
#檔案保留時間,預設 48 小時
fileReservedTime=720
#commitLog每個檔案的大小預設1G
mapedFileSizeCommitLog=1073741824
#ConsumeQueue每個檔案預設存30W條,根據業務情況調整
mapedFileSizeConsumeQueue=300000
#destroyMapedFileIntervalForcibly=120000
#redeleteHangedFileInterval=120000
#檢測實體檔案磁盤空間
diskMaxUsedSpaceRatio=88
#存儲路徑
#storePathRootDir=/home/rocketmq/store-s
#commitLog 存儲路徑
#storePathCommitLog=/home/rocketmq/store-s/commitlog
#消費隊列存儲路徑存儲路徑
#storePathConsumeQueue=/home/rocketmq/store-s/consumequeue
#消息索引存儲路徑
#storePathIndex=/home/rocketmq/store-s/index
#checkpoint 檔案存儲路徑
#storeCheckpoint=/home/rocketmq/store-s/checkpoint
#abort 檔案存儲路徑
#abortFile=/home/rocketmq/store-s/abort
#限制的消息大小
maxMessageSize=65536
#flushCommitLogLeastPages=4
#flushConsumeQueueLeastPages=2
#flushConsumeQueueLeastPages=2#flushCommitLogThoroughInterval=10000
#flushConsumeQueueThoroughInterval=60000
#Broker 的角色
#- ASYNC_MASTER 異步複制Master
#- SYNC_MASTER 同步雙寫Master
#- SLAVE
brokerRole=SLAVE
#刷盤方式
#- ASYNC_FLUSH 異步刷盤
#- SYNC_FLUSH 同步刷盤
flushDiskType=ASYNC_FLUSH
#checkTransactionMessageEnable=false
#發消息線程池數量
#sendMessageThreadPoolNums=128
#拉消息線程池數量
#pullMessageThreadPoolNums=128
#強制指定本機IP,需要根據每台機器進行修改。官方介紹可為空,系統預設自動識别,但多網卡時IP位址可能讀取錯誤
brokerIP1=12.12.12.12
           
4、啟動腳本修改

進入目錄:cd /home/docker-rocketmq/rmq

編輯啟動腳本:vim start.sh

#!/usr/bin/env bash

# 建立目錄
mkdir -p ./rmqs/logs
mkdir -p ./rmqs/store
mkdir -p ./rmq/logs
mkdir -p ./rmq/store
mkdir -p ./rmq-a/logs
mkdir -p ./rmq-a/store
mkdir -p ./rmq-b/logs
mkdir -p ./rmq-b/store

# 設定目錄權限
chmod -R 777 ./rmqs/logs
chmod -R 777 ./rmqs/store
chmod -R 777 ./rmq/logs
chmod -R 777 ./rmq/store
chmod -R 777 ./rmq-a/logs
chmod -R 777 ./rmq-a/store
chmod -R 777 ./rmq-b/logs
chmod -R 777 ./rmq-b/store

# 下載下傳并啟動容器,且為 背景 自動啟動
docker-compose up -d

# 顯示 rocketmq 容器
docker ps |grep rocketmq
           
5、配置hosts檔案
13.3.1.13 rmqnamesrv1
13.3.3.14 rmqnamesrv2
           
6、啟動服務
cd /home/docker-rocketmq/rmq
./start.sh