Docker Desktop搭建RocketMQ的圖文步驟
上一節(jié)我們講到了怎么在本地安裝Docker Desktop,安裝完了之后我們需要在docker上面部署一些自己需要的東西,比如MySQL,Redis還有我們本節(jié)介紹的RocketMQ,由于MySQL和Redis的安裝非常的簡單,我們就直接跳過了。
RocketMQ需要安裝三個組件,這三個組件又需要能夠互相通信連接的,考慮到分開部署進行配置連接信息比較麻煩(有很多博客都是說怎么一個個的搭建),這里我們采用docker-compose進行配置部署,簡單方便的直接搞定。
第一步:
我們在自己電腦的任意盤創(chuàng)建docker-compose.yml配置文件。

如圖所示我直接放在了D盤下面,看我的目錄大家也知道還需要建立三個空文件夾conf、logs、store。
docker-compose.yml 文件內容如下:
version: '3.5'
services:
rmqnamesrv:
image: foxiswho/rocketmq:server
container_name: rmqnamesrv
ports:
- 9876:9876
volumes:
- ./logs:/opt/logs
- ./store:/opt/store
networks:
rmq:
aliases:
- rmqnamesrv
rmqbroker:
image: foxiswho/rocketmq:broker
container_name: rmqbroker
ports:
- 10909:10909
- 10911:10911
volumes:
- ./logs:/opt/logs
- ./store:/opt/store
- ./conf/broker.conf:/etc/rocketmq/broker.conf
environment:
NAMESRV_ADDR: "rmqnamesrv:9876"
JAVA_OPTS: " -Duser.home=/opt"
JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
command: mqbroker -c /etc/rocketmq/broker.conf
depends_on:
- rmqnamesrv
networks:
rmq:
aliases:
- rmqbroker
rmqconsole:
image: styletang/rocketmq-console-ng
container_name: rmqconsole
ports:
- 8090:8080 ## 可以自己修改端口號,我這里改成不常用的8090
environment:
JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
depends_on:
- rmqnamesrv
networks:
rmq:
aliases:
- rmqconsole
networks:
rmq:
name: rmq
driver: bridge
第二步:
編寫broker.conf配置文件里面的內容,該配置文件在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 # broker 名字,注意此處不同的配置文件填寫的不一樣,如果在 broker-a.properties 使用: broker-a, # 在 broker-b.properties 使用: broker-b brokerName=broker-a # 0 表示 Master,> 0 表示 Slave brokerId=0 # nameServer地址,分號分割 # namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876 # 啟動IP,如果 docker 報 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed # 解決方式1 加上一句 producer.setVipChannelEnabled(false);,解決方式2 brokerIP1 設置宿主機IP,不要使用docker 內部IP brokerIP1=www.xiong.com # 在發(fā)送消息時,自動創(chuàng)建服務器不存在的topic,默認創(chuàng)建的隊列數(shù) defaultTopicQueueNums=4 # 是否允許 Broker 自動創(chuàng)建 Topic,建議線下開啟,線上關閉 ?。?!這里仔細看是 false,false,false autoCreateTopicEnable=true # 是否允許 Broker 自動創(chuàng)建訂閱組,建議線下開啟,線上關閉 autoCreateSubscriptionGroup=true # Broker 對外服務的監(jiān)聽端口 listenPort=10911 # 刪除文件時間點,默認凌晨4點 deleteWhen=04 # 文件保留時間,默認48小時 fileReservedTime=120 # commitLog 每個文件的大小默認1G mapedFileSizeCommitLog=1073741824 # ConsumeQueue 每個文件默認存 30W 條,根據(jù)業(yè)務情況調整 mapedFileSizeConsumeQueue=300000 # destroyMapedFileIntervalForcibly=120000 # redeleteHangedFileInterval=120000 # 檢測物理文件磁盤空間 diskMaxUsedSpaceRatio=88 # 存儲路徑 # storePathRootDir=/home/ztztdata/rocketmq-all-4.1.0-incubating/store # commitLog 存儲路徑 # storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog # 消費隊列存儲 # storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue # 消息索引存儲路徑 # storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index # checkpoint 文件存儲路徑 # storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint # abort 文件存儲路徑 # abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort # 限制的消息大小 maxMessageSize=65536 # flushCommitLogLeastPages=4 # flushConsumeQueueLeastPages=2 # flushCommitLogThoroughInterval=10000 # flushConsumeQueueThoroughInterval=60000 # Broker 的角色 # - ASYNC_MASTER 異步復制Master # - SYNC_MASTER 同步雙寫Master # - SLAVE brokerRole=ASYNC_MASTER # 刷盤方式 # - ASYNC_FLUSH 異步刷盤 # - SYNC_FLUSH 同步刷盤 flushDiskType=ASYNC_FLUSH # 發(fā)消息線程池數(shù)量 # sendMessageThreadPoolNums=128 # 拉消息線程池數(shù)量 # pullMessageThreadPoolNums=128
在這個配置文件中我們需要修改 brokerIP1=www.xiong.com
我們將其更改為我們本機的ip,可以利用ipconfig進行查看。
在這里我修改了本地的hosts映射,將IP映射到www.xiong.com,就可以直接使用域名訪問了。
修改完以后我們直接在docker-compose.yml文件所在的位置輸入命令docker-compose up即可啟動。
再查看我們的Docker Desktop就會發(fā)現(xiàn)RocketMQ已經(jīng)配置好了

在瀏覽器中輸入http://www.xiong.com:8090/即可看到管理頁面

到此這篇關于Docker Desktop搭建RocketMQ的圖文步驟的文章就介紹到這了,更多相關Docker Desktop搭建RocketMQ內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Docker制作MySQL鏡像并使用`/docker-entrypoint-initdb.d/`問題
這篇文章主要介紹了Docker制作MySQL鏡像并使用`/docker-entrypoint-initdb.d/`問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-05-05
解決docker啟動容器失敗:cannot?access‘/docker-entrypoint-initdb.d/‘:
這篇文章主要介紹了解決docker啟動容器失敗:cannot?access‘/docker-entrypoint-initdb.d/‘:Operation?not?permitted,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-05-05

