1.拉取镜像
这里选择4.4.0版本, 对应springboot中引入依赖的2.0.2版本
docker pull rocketmqinc/rocketmq:4.4.0
2.准备映射文件
//供namesrv服务使用
mkdir -p /docker/rocketmq/data/namesrv/logs
mkdir -p /docker/rocketmq/data/namesrv/store
//供broker服务使用
mkdir -p /docker/rocketmq/data/broker/logs
mkdir -p /docker/rocketmq/data/broker/store
mkdir -p /docker/rocketmq/conf
chmod -R 777 /docker
vi /docker/rocketmq/conf/broker.conf
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = *.*.*.*
3.启动容器
nameserver:
docker run -d --restart=always --name rmqnamesrv --privileged=true -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:4.4.0 sh mqnamesrv
broker:
docker run -d --restart=always --name rmqbroker --link rmqnamesrv:namesrv -p 10911:10911 -p 10909:10909 --privileged=true -v /docker/rocketmq/data/broker/logs:/root/logs -v /docker/rocketmq/data/broker/store:/root/store -v /docker/rocketmq/conf/broker.conf:/opt/docker/rocketmq/broker.conf -e "NAMESRV_ADDR=namesrv:9876" -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq:4.4.0 sh mqbroker -c /opt/docker/rocketmq/broker.conf
console:
docker run -d --restart=always --name rmqadmin -e "JAVA_OPTS=-Drocketmq.namesrv.addr=*.*.*.*:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8081:8080 pangliang/rocketmq-console-ng