1. 程式人生 > 其它 >docker rocketMQ 詳細 三分鐘搞定

docker rocketMQ 詳細 三分鐘搞定

首先你要有docker

開始:

1 查詢映象 docker search rocketmq

 

 

2 檢視 映象版本,可直接下載最後版本

curl https://registry.hub.docker.com/v1/repositories/foxiswho/rocketmq/tags\
| tr -d '[\[\]" ]' | tr '}' '\n'\
| awk -F: -v image='foxiswho/rocketmq' '{if(NR!=NF && $3 != ""){printf("%s:%s\n",image,$3)}}'

 

 

 

 

 

 3 docker pull foxiswho/rocketmq:server-4.7.0

開啟:

docker run -d -p 10911:10911 -p 10909:10909 \
--name rmqbroker --link rmqserver:namesrv \
 -e "NAMESRV_ADDR=namesrv:9876" \
 -e "JAVA_OPTS=-Duser.home=/opt" \
 -e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m" \
 foxiswho/rocketmq:broker-4.7.0

4 啟動broker:

  建立 broker 配置檔案掛載資料夾

  mkdir -p /usr/data/rocketMQ/data/broker/logs

  mkdir -p /usr/data/rocketMQ/data/broker/store

  mkdir -p /usr/data/rocketMQ/data/broker/conf/

新增 broker 配置檔案,在 /usr/data/rocketMQ/data/broker/conf 目錄下建立 broker.conf 檔案,內容如下:

  brokerClusterName = DefaultCluster
  brokerName = broker-a
  brokerId = 0
  deleteWhen = 04
  fileReservedTime = 48
  brokerRole = ASYNC_MASTER
  flushDiskType = ASYNC_FLUSH
  brokerIP1 = ip

啟動

docker run -d -p 10911:10911 -p 10909:10909 \
--name rmqbroker --link rmqserver:namesrv \
-e "NAMESRV_ADDR=namesrv:9876" -e "JAVA_OPTS=-Duser.home=/opt" \
-e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m" \
-v /usr/data/rocketMQ/data/broker/logs:/root/logs \
-v /usr/data/rocketMQ/data/broker/store:/root/store \
-v /usr/data/rocketMQ/data/broker/conf/broker.conf:/etc/rocketmq/broker.conf \
foxiswho/rocketmq:broker-4.7.0

5:安裝控制檯

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

再通過瀏覽器訪問localhost:18848,console的頁面顯示如下: