1. 程式人生 > 其它 >Docker 安裝rocketmq

Docker 安裝rocketmq

Docker 安裝rocketmq

1.拉取映象

#拉取映象 
docker pull rocketmqinc/rocketmq

2.建立資料掛載目錄

mkdir -p  /docker/rocketmq/data/namesrv/logs   /docker/rocketmq/data/namesrv/store
mkdir -p  /docker/rocketmq/data/broker/logs   /docker/rocketmq/data/broker/store /docker/rocketmq/conf

3.啟動NameServer

docker run -d \
--restart=always \
--name rmqnamesrv \
-p 9876:9876 \
-v /docker/rocketmq/data/namesrv/logs:/root/logs \
-v /docker/rocketmq/data/namesrv/store:/root/store \
-e "MAX_POSSIBLE_HEAP=100000000" \
rocketmqinc/rocketmq \
sh mqnamesrv 

4.編輯配置檔案

vi /docker/rocketmq/conf/broker.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 = 39.105.18

5.啟動broker

docker run -d  \
--restart=always \
--name rmqbroker \
--link rmqnamesrv:namesrv \
-p 10911:10911 \
-p 10909:10909 \
-v  /docker/rocketmq/data/broker/logs:/root/logs \
-v  /docker/rocketmq/data/broker/store:/root/store \
-v /docker/rocketmq/conf/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf \
-e "NAMESRV_ADDR=namesrv:9876" \
-e "MAX_POSSIBLE_HEAP=200000000" \
rocketmqinc/rocketmq \
sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker.conf

6.部署RocketMQ的管理工具

RocketMQ提供了UI管理工具,名為rocketmq-console,我們選擇docker安裝

#拉取映象 
docker pull pangliang/rocketmq-console-ng
#建立並啟動容器 
docker run -d \
--restart=always \
--name rmqadmin \
-e "JAVA_OPTS=-Drocketmq.namesrv.addr=39.105.18:9876 \
-Dcom.rocketmq.sendMessageWithVIPChannel=false" \
-p 8082:8080 \
pangliang/rocketmq-console-ng

通過瀏覽器進行訪問:http://39.105.18:8082/