RocketMQ -docker 安裝

Github

rocketmq控制臺

安裝

[圖片上傳失敗...(image-671e7e-1598427691641)]

rocketmq 鏡像

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n6" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">docker pull apacherocketmq/rocketmq:4.5.0</pre>

broker

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n8" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">docker pull apacherocketmq/rocketmq:4.5.0</pre>

控制臺

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n10" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">docker pull styletang/rocketmq-console-ng</pre>

docker-compose.yml

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="yaml" cid="n12" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">version: '3'
services:
namesrv:
image: apacherocketmq/rocketmq:4.5.0
container_name: rmqnamesrv

重啟模式

restart: always

hostname: 你的ip
ports:

  • 9876:9876
    volumes:
  • ./data/namesrv/logs:/home/rocketmq/logs
    command: sh mqnamesrv
    enviroment:
    TZ: Asia/Shanghai

broker:
image: apacherocketmq/rocketmq:4.5.0
hostname: 119.23.190.71
container_name: rmqbroker
ports:

  • 10909:10909
  • 10911:10911
  • 10912:10912
    volumes:
  • ./data/broker/logs:/home/rocketmq/logs
  • ./data/broker/store:/home/rocketmq/store
  • ./conf/broker.conf:/home/rocketmq/rocketmq-4.5.0/conf/broker.conf
    command: sh mqbroker -n namesrv:9876 -c ../conf/broker.conf
    depends_on:
  • namesrv
    console:
    image: styletang/rocketmq-console-ng
    container_name: rocketmq-console-ng1
    hostname: 你的ip
    ports:
  • 8087:8080
    depends_on:
  • namesrv
    environment:
  • JAVA_OPTS= -Dlogging.level.root=info -Drocketmq.namesrv.addr=你的ip:9876
  • Dcom.rocketmq.sendMessageWithVIPChannel=false </pre>

broker.conf

<pre spellcheck="false" class="md-fences md-end-block ty-contain-cm modeLoaded" lang="" cid="n14" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; color: rgb(184, 191, 198); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">brokerClusterName = DefaultCluster # 設置broker的名字
brokerName = broker-a

master 0 slave用其他的

brokerId = 0

清理消息的時間

deleteWhen = 04

文件保留時長 默認48小時

fileReservedTime = 48

異步復制 SYNC_MASTER 同步復制

brokerRole = ASYNC_MASTER

刷盤策略 ASTNC_FLUSH 異步

SYNC_FLUSH 同步刷盤

flushDiskType = ASYNC_FLUSH

這個需要設置成 云主機 IP

brokerIP1 = 你的ip

listenProt= 10911

對外服務的端口 可以不設置</pre>

說明

這里需要注意 rocketmq broker 與 rokcetmq-console 都需要與 rokcetmq nameserver連接。使用 docker-compose 之后,上面三個 docker 容器將會一起編排,可以直接使用容器名代替容器 ip,如這里 nameserver 容器名 rmqnamesrv。

配置完成之后,運行 docker-compose up 啟動三個容器,啟動成功后,訪問 ip:8087,查看 mq 外部控制臺,如果可以看到以下信息

image

RocketMQ Broker 暴露的地址和端口(10909,10911)是基于容器的,會導致我們開發(fā)機無法連接,從而引發(fā) org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException: sendDefaultImpl call timeout 異常

解決方案是在 broker.conf 配置文件中增加 brokerIP1=宿主機IP 即可

最后編輯于
?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

友情鏈接更多精彩內(nèi)容