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的页面显示如下: