docker-compose构建rocketmq消息队列-创新互联
1.docker-compose.yml 文件
分享题目:docker-compose构建rocketmq消息队列-创新互联
分享网址:http://pwwzsj.com/article/dggiii.html
version: '3'
services:
mqnamesrv:
image: apache/rocketmq:4.9.4
container_name: mqnamesrv
ports:
- "9876:9876"
environment:
JAVA_OPT: -server -Xms512m -Xmx512m
command: sh mqnamesrv
volumes:
- /usr/local/rocketmq/namesrv/logs:/home/rocketmq/logs/rocketmqlogs
mqbroker:
image: apache/rocketmq:4.9.4
container_name: mqbroker
ports:
- "10911:10911"
- "10909:10909"
- "10912:10912"
environment:
NAMESRV_ADDR: "mqnamesrv:9876"
JAVA_OPT_EXT: -server -Xms512M -Xmx512M -Xmn256m
command: ["sh","mqbroker","-c","/home/rocketmq/rocketmq-4.9.4/conf/broker.conf","-n","mqnamesrv:9876","autoCreateTopicEnable=true"]
depends_on:
- mqnamesrv
volumes:
- /usr/local/rocketmq/broker/conf/broker.conf:/home/rocketmq/rocketmq-4.9.4/conf/broker.conf
- /usr/local/rocketmq/broker/logs:/home/rocketmq/logs/rocketmqlogs
- /usr/local/rocketmq/broker/store:/home/rocketmq/store
mqconsole:
image: styletang/rocketmq-console-ng
container_name: mqconsole
ports:
- "9877:9877"
environment:
JAVA_OPTS: -Dserver.port=9877 -Drocketmq.namesrv.addr=mqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false
depends_on:
- mqnamesrv
2.broker.conf 配置# 所属集群名称,如果节点较多可以配置多个
brokerClusterName = DefaultCluster
#broker名称,master和slave使用相同的名称,表明他们的主从关系
brokerName = broker1
#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地址(**这个非常重要,主从模式下,从节点会根据主节点的brokerIP2来同步数据,如果不配置,主从无法同步,brokerIP1设置为自己外网能访问的ip,服务器双网卡情况下必须配置,比如阿里云这种,主
节点需要配置ip1和ip2,从节点只需要配置ip1即可)
# 此ip由使用环境决定 本机使用 127 局域网使用 192 外网使用 外网ip
brokerIP1 = 42.192.166.196
#nameServer地址,分号分割
#namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
namesrvAddr=mqnamesrv:9876
#Broker 对外服务的监听端口,
listenPort = 10911
#是否允许Broker自动创建Topic
autoCreateTopicEnable = true
#是否允许 Broker 自动创建订阅组
autoCreateSubscriptionGroup = true
#linux开启epoll
#useEpollNativeSelector = true
3.目录结构[root@VM-0-8-centos rocketmq]# ll
total 12
drwxrwxrwx 5 777 root 4096 Aug 30 20:15 broker # 配置文件
-rwxrwxrwx 1 777 root 1274 Aug 30 20:14 docker-compose.yml
drwxrwxrwx 3 777 root 4096 Aug 30 20:15 namesrv
# 查看broker 目录结构
[root@VM-0-8-centos rocketmq]# cd broker/
[root@VM-0-8-centos broker]# ll
total 12
drwxrwxrwx 2 777 root 4096 Dec 27 13:54 conf
drwxrwxrwx 3 777 root 4096 Dec 26 20:12 logs
drwxrwxrwx 6 777 root 4096 Aug 30 21:24 store
[root@VM-0-8-centos broker]#
# 查看conf 目录结构
[root@VM-0-8-centos broker]# cd conf/
[root@VM-0-8-centos conf]# ll
total 4
-rwxrwxrwx 1 777 root 1603 Aug 30 20:15 broker.conf
4.特别注意 使用官方镜像 需要给整个rocketmq 文件夹可读可写权限 否则应用无法连接
你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧
成都创新互联作为成都网站建设公司,专注网站建设公司、网站设计,有关成都定制网页设计方案、改版、费用等问题,行业涉及除甲醛等多个领域,已为上千家企业服务,得到了客户的尊重与认可。分享题目:docker-compose构建rocketmq消息队列-创新互联
分享网址:http://pwwzsj.com/article/dggiii.html