文章目录
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、拉取镜像
OK,开始拉取镜像,具体的原理及框架结构说明大家可以自行找度娘哈,我这边仅给步骤哈
docker pull foxiswho/rocketmq:broker-4.7.0 docker pull foxiswho/rocketmq:server-4.7.0 docker pull styletang/rocketmq-console-ng
4、创建数据存储路径
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
5、构建namesrv容器
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 "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" \ -e "JAVA_OPTS=-Duser.home/opt" \ foxiswho/rocketmq:server-4.7.0 \ sh mqnamesrv
6、创建broker配置文件
vi /docker/rocketmq/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 = ***.**.**.** # 磁盘使用达到95%之后,生产者再写入消息会报错 CODE: 14 DESC: service not available now, maybe disk full diskMaxUsedSpaceRatio=95
7、构建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.7.0/conf/broker.conf \ -e "NAMESRV_ADDR=namesrv:9876" \ -e "JAVA_OPTS=-Duser.home=/opt" \ -e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m -Xmn128m" \ foxiswho/rocketmq:broker-4.7.0 \ sh mqbroker -c /opt/rocketmq-4.7.0/conf/broker.conf
8、创建rockermq-console服务
docker run -d \ --restart=always \ --name rmqadmin \ # ***.**.**.**这个我配置的服务器的内网地址 -e "JAVA_OPTS=-Drocketmq.namesrv.addr=***.**.**.**:9876 \ -Dcom.rocketmq.sendMessageWithVIPChannel=false" \ -p 8082:8080 \ styletang/rocketmq-console-ng