首頁 > 軟體

使用Docker容器部署rocketmq單機的全過程

2022-04-03 13:00:29

查詢映象

docker search rocketmq
NAME                                 DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
foxiswho/rocketmq                    rocketmq                                        69                   
rocketmqinc/rocketmq                 Image repository for Apache RocketMQ            54                   
styletang/rocketmq-console-ng        rocketmq-console-ng                             37                   
apacherocketmq/rocketmq              Docker Image for Apache RocketMQ                21                   
apache/rocketmq     

拉取映象

docker pull foxiswho/rocketmq:server    #mq-server
...
docker pull foxiswho/rocketmq:broker    #mq-broker
...
docker pull styletang/rocketmq-console-ng   #使用者端
...

建立namesrv資料儲存路徑

mkdir -p /var/local/docker/rocketmq/namesrv/store /var/log/docker/rocketmq/namesrv

構建namesrv容器

docker run -d 
--restart=always 
--name rmqnamesrv 
-p 9876:9876 
-v /var/log/docker/rocketmq/namesrv:/var/log 
-v /var/local/docker/rocketmq/namesrv/store:/var/store 
-e "MAX_POSSIBLE_HEAP=100000000" 
foxiswho/rocketmq 
sh mqnamesrv

建立broker資料儲存路徑

mkdir -p /var/local/docker/rocketmq/broker/store /var/log/docker/rocketmq/broker

建立broker組態檔

mkdir -p /etc/docker/rocketmq/conf
touch broker.conf
vi broker.conf

broker.conf 內容如下:

vim /docker/rocketmq/conf/broker.conf
# 所屬叢集名稱,如果節點較多可以設定多個
brokerClusterName = DefaultCluster
#broker名稱,master和slave使用相同的名稱,表明他們的主從關係
brokerName = broker-a
#0表示Master,大於0表示不同的slave
brokerId = 0
#表示幾點做訊息刪除動作,預設是凌晨4點
deleteWhen = 04
#在磁碟上保留訊息的時長,單位是小時
fileReservedTime = 48
#有三個值:SYNC_MASTER,ASYNC_MASTER,SLAVE;同步和非同步表示Master和Slave之間同步資料的機制;
brokerRole = ASYNC_MASTER
#刷盤策略,取值為:ASYNC_FLUSH,SYNC_FLUSH表示同步刷盤和非同步刷盤;SYNC_FLUSH訊息寫入磁碟後才返回成功狀態,ASYNC_FLUSH不需要;
flushDiskType = ASYNC_FLUSH
# 設定broker節點所在伺服器的ip地址
brokerIP1 = 192.168.1.1  # 注意:改成你的IP地址

構建broker容器

docker run -d 
--restart=always  
--name rmqbroker 
--link rmqnamesrv:namesrv 
-p 10911:10911 
-p 10909:10909 
-v /var/local/docker/rocketmq/broker/store:/var/store 
-v /var/log/docker/rocketmq/broker:/var/logs 
-v /etc/docker/rocketmq/conf/broker.conf:/etc/rocketmq/conf/broker.conf 
-e "NAMESRV_ADDR=namesrv:9876" 
-e "MAX_POSSIBLE_HEAP=200000000" 
foxiswho/rocketmq:broker 
sh mqbroker -c /etc/rocketmq/conf/broker.conf

構建rocketmq-console-ng

docker run -d 
--name rmqconsole 
-p 8180:8080 
--restart=always 
--link rmqserver:namesrv 
-e "JAVA_OPTS=-Drocketmq.namesrv.addr=namesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" 
-t styletang/rocketmq-console-ng

到此這篇關於使用Docker容器部署rocketmq單機的文章就介紹到這了,更多相關Docker部署rocketmq內容請搜尋it145.com以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援it145.com!


IT145.com E-mail:sddin#qq.com