Docker-compose 安裝 RocketMq
阿新 • • 發佈:2022-01-03
1參考連結
https://www.jianshu.com/p/706588323276
2 docker-compose的安裝
https://www.cnblogs.com/mangoubiubiu/p/15236179.html
3 rockermq的docker-compose.yml
version: '3.5' services: rmqnamesrv: image: foxiswho/rocketmq:server container_name: rmqnamesrv ports: - 9876:9876 volumes: - ./data/logs:/opt/logs- ./data/store:/opt/store networks: rmq: aliases: - rmqnamesrv rmqbroker: image: foxiswho/rocketmq:broker container_name: rmqbroker ports: - 10909:10909 - 10911:10911 volumes: - ./data/logs:/opt/logs - ./data/store:/opt/store - ./data/brokerconf/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:- 8080:8080 environment: JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false -Duser.timezone='Asia/GuangZhou'" depends_on: - rmqnamesrv networks: rmq: aliases: - rmqconsole networks: rmq: name: rmq driver: bridge
4 brock.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=rmqnamesrv: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=192.168.56.13 # 在傳送訊息時,自動建立伺服器不存在的topic,預設建立的佇列數 defaultTopicQueueNums=4 # 是否允許 Broker 自動建立 Topic,建議線下開啟,線上關閉 !!!這裡仔細看是 false,false,false autoCreateTopicEnable=true # 是否允許 Broker 自動建立訂閱組,建議線下開啟,線上關閉 autoCreateSubscriptionGroup=true # Broker 對外服務的監聽埠 listenPort=10911 # 刪除檔案時間點,預設凌晨4點 deleteWhen=04 # 檔案保留時間,預設48小時 fileReservedTime=120 # commitLog 每個檔案的大小預設1G mapedFileSizeCommitLog=1073741824 # ConsumeQueue 每個檔案預設存 30W 條,根據業務情況調整 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 # 發訊息執行緒池數量 # sendMessageThreadPoolNums=128 # 拉訊息執行緒池數量 # pullMessageThreadPoolNums=128
一個要改動的點改成你自己虛擬機器的ip
在資料卷對映目錄下放置 broker.conf
5啟動
將docker-compose.yml 拖進虛擬機器
直接
docker-compose up -d
命令詳解
docker-compose up -d --build (up是執行 -d 是後臺執行 --build是重新構建)
6測試
這種安裝的沒有任何問題,可以收發訊息
之前這種https://www.cnblogs.com/mangoubiubiu/p/15733399.html
有問題連線超時 ,暫未找到原因