1. 首先安装namesrv
1. docker pull rocketmqinc/rocketmq:latest // 拉去最新的镜像.
2.docker run -d -p 9876:9876 -v /usr/local/docker/rocketmq/data/namesrv/logs:/root/logs -v /usr/local/docker/rocketmq/data/namesrv/store:/root/store --name rmqnamesrv -"MAX_POSSIBLE_HEAP=100000000" rocketmqinc/rocketmq:latest sh mqnamesrv
//docker run 运行 -p 内外端口映射 -v 容器卷挂载
2.通过docker ps -a 查询正在运行的容器
- 可以看到rocketmqinc启动中
3.Broker配置
创建broker配置文件(可能需要切换全新 mac[sudo -s])
mkdir -p /usr/local/docker/rocketmq/conf //递归创建文件
cd /usr/local/docker/rocketmq/conf //进入文件位置
vim broker.conf (通过vim编辑文件 没有会自动创建)
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = 127.0.0.1
通过指定broker.conf配置文件来启动容器
docker run -d -p 10911:10911 -p 10909:10909 -v /usr/local/docker/rocketmq/data/broker/logs:/root/logs -v /usr/local/docker/rocketmq/data/broker/store:/root/store -v /usr/local/docker/rocketmq/conf/broker.conf:/opt/rocketmq-latest/conf/broker.conf --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq:latest sh mqbroker -c /opt/rocketmq-latest/conf/broker.conf
4.安装Console控制台(更加直观观察消息的情况)
docker pull pangliang/rocketmq-console-ng //拉取镜像
docker run -d -e "JAVA_OPTS=-Drocketmq.namesrv.addr=127.0.0.1:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8080:8080 -t pangliang/rocketmq-console-ng