这篇文章主要介绍“怎么使用Docker容器部署rocketmq单机”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“怎么使用Docker容器部署rocketmq单机”文章能帮助大家解决问题。
查询镜像
docker search rocketmqNAME DESCRIPTION STARS OFFICIAL AUTOMATEDfoxiswho/rocketmq rocketmq 69 rocketmqinc/rocketmq Image repository for Apache RocketMQ 54 styletang/rocketmq-console-ng rocketmq-console-ng 37 apacherocketmq/rocketmq Docker Image for Apache RocketMQ 21 apache/rocketmq
拉取镜像
docker pull foxiswho/rocketmq:server #mq-server...docker pull foxiswho/rocketmq:broker #mq-broker...docker pull styletang/rocketmq-console-ng #客户端...
创建namesrv数据存储路径
mkdir -p /var/local/docker/rocketmq/namesrv/store /var/log/docker/rocketmq/namesrv
构建namesrv容器
docker run -d \--restart=always \--name rmqnamesrv \-p 9876:9876 \-v /var/log/docker/rocketmq/namesrv:/var/log \-v /var/local/docker/rocketmq/namesrv/store:/var/store \-e "MAX_POSSIBLE_HEAP=100000000" \foxiswho/rocketmq \sh mqnamesrv
创建broker数据存储路径
mkdir -p /var/local/docker/rocketmq/broker/store /var/log/docker/rocketmq/broker
创建broker配置文件
mkdir -p /etc/docker/rocketmq/conftouch broker.confvi broker.conf
broker.conf 内容如下:
vim /docker/rocketmq/conf/broker.conf# 所属集群名称,如果节点较多可以配置多个brokerClusterName = DefaultCluster#broker名称,master和slave使用相同的名称,表明他们的主从关系brokerName = broker-a#0表示Master,大于0表示不同的slavebrokerId = 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 = 192.168.1.1 # 注意:改成你的IP地址
构建broker容器
docker run -d \--restart=always \ --name rmqbroker \--link rmqnamesrv:namesrv \-p 10911:10911 \-p 10909:10909 \-v /var/local/docker/rocketmq/broker/store:/var/store \-v /var/log/docker/rocketmq/broker:/var/logs \-v /etc/docker/rocketmq/conf/broker.conf:/etc/rocketmq/conf/broker.conf \-e "NAMESRV_ADDR=namesrv:9876" \-e "MAX_POSSIBLE_HEAP=200000000" \foxiswho/rocketmq:broker \sh mqbroker -c /etc/rocketmq/conf/broker.conf
构建rocketmq-console-ng
docker run -d \--name rmqconsole \-p 8180:8080 \--restart=always \--link rmqserver:namesrv \-e "JAVA_OPTS=-Drocketmq.namesrv.addr=namesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" \-t styletang/rocketmq-console-ng
关于“怎么使用Docker容器部署rocketmq单机”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注编程网行业资讯频道,小编每天都会为大家更新不同的知识点。