Spring Cloud Alibaba 异步通信 - 基于 Docker 安装 RocketMQ

docker-compose.yml

注意:启动 RocketMQ Server + Broker + Console 至少需要 2G 内存

  1. version: '3.5'
  2. services:
  3. rmqnamesrv:
  4. image: foxiswho/rocketmq:server
  5. container_name: rmqnamesrv
  6. ports:
  7. - 9876:9876
  8. volumes:
  9. - ./data/logs:/opt/logs
  10. - ./data/store:/opt/store
  11. networks:
  12. rmq:
  13. aliases:
  14. - rmqnamesrv
  15. rmqbroker:
  16. image: foxiswho/rocketmq:broker
  17. container_name: rmqbroker
  18. ports:
  19. - 10909:10909
  20. - 10911:10911
  21. volumes:
  22. - ./data/logs:/opt/logs
  23. - ./data/store:/opt/store
  24. - ./data/brokerconf/broker.conf:/etc/rocketmq/broker.conf
  25. environment:
  26. NAMESRV_ADDR: "rmqnamesrv:9876"
  27. JAVA_OPTS: " -Duser.home=/opt"
  28. JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
  29. command: mqbroker -c /etc/rocketmq/broker.conf
  30. depends_on:
  31. - rmqnamesrv
  32. networks:
  33. rmq:
  34. aliases:
  35. - rmqbroker
  36. rmqconsole:
  37. image: styletang/rocketmq-console-ng
  38. container_name: rmqconsole
  39. ports:
  40. - 8080:8080
  41. environment:
  42. JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
  43. depends_on:
  44. - rmqnamesrv
  45. networks:
  46. rmq:
  47. aliases:
  48. - rmqconsole
  49. networks:
  50. rmq:
  51. name: rmq
  52. driver: bridge

broker.conf

RocketMQ Broker 需要一个配置文件,按照上面的 Compose 配置,我们需要在 ./data/brokerconf/ 目录下创建一个名为 broker.conf 的配置文件,内容如下:

  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # 所属集群名字
  16. brokerClusterName=DefaultCluster
  17. # broker 名字,注意此处不同的配置文件填写的不一样,如果在 broker-a.properties 使用: broker-a,
  18. # 在 broker-b.properties 使用: broker-b
  19. brokerName=broker-a
  20. # 0 表示 Master,> 0 表示 Slave
  21. brokerId=0
  22. # nameServer地址,分号分割
  23. # namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
  24. # 启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed
  25. # 解决方式1 加上一句 producer.setVipChannelEnabled(false);,解决方式2 brokerIP1 设置宿主机IP,不要使用docker 内部IP
  26. # brokerIP1=192.168.0.253
  27. # 在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
  28. defaultTopicQueueNums=4
  29. # 是否允许 Broker 自动创建 Topic,建议线下开启,线上关闭 !!!这里仔细看是 false,false,false
  30. autoCreateTopicEnable=true
  31. # 是否允许 Broker 自动创建订阅组,建议线下开启,线上关闭
  32. autoCreateSubscriptionGroup=true
  33. # Broker 对外服务的监听端口
  34. listenPort=10911
  35. # 删除文件时间点,默认凌晨4点
  36. deleteWhen=04
  37. # 文件保留时间,默认48小时
  38. fileReservedTime=120
  39. # commitLog 每个文件的大小默认1G
  40. mapedFileSizeCommitLog=1073741824
  41. # ConsumeQueue 每个文件默认存 30W 条,根据业务情况调整
  42. mapedFileSizeConsumeQueue=300000
  43. # destroyMapedFileIntervalForcibly=120000
  44. # redeleteHangedFileInterval=120000
  45. # 检测物理文件磁盘空间
  46. diskMaxUsedSpaceRatio=88
  47. # 存储路径
  48. # storePathRootDir=/home/ztztdata/rocketmq-all-4.1.0-incubating/store
  49. # commitLog 存储路径
  50. # storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog
  51. # 消费队列存储
  52. # storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue
  53. # 消息索引存储路径
  54. # storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index
  55. # checkpoint 文件存储路径
  56. # storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint
  57. # abort 文件存储路径
  58. # abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort
  59. # 限制的消息大小
  60. maxMessageSize=65536
  61. # flushCommitLogLeastPages=4
  62. # flushConsumeQueueLeastPages=2
  63. # flushCommitLogThoroughInterval=10000
  64. # flushConsumeQueueThoroughInterval=60000
  65. # Broker 的角色
  66. # - ASYNC_MASTER 异步复制Master
  67. # - SYNC_MASTER 同步双写Master
  68. # - SLAVE
  69. brokerRole=ASYNC_MASTER
  70. # 刷盘方式
  71. # - ASYNC_FLUSH 异步刷盘
  72. # - SYNC_FLUSH 同步刷盘
  73. flushDiskType=ASYNC_FLUSH
  74. # 发消息线程池数量
  75. # sendMessageThreadPoolNums=128
  76. # 拉消息线程池数量
  77. # pullMessageThreadPoolNums=128

RocketMQ 控制台

访问 http://rmqIP:8080 登入控制台

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

智慧浩海

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值