• Docker安装RocketMQ详细教程


    使用docker-compose 安装

    1.安装docker-compose

    1. #通过docker-compose version命令进行查看
    2. docker-compose version
    3. # 如果没有该命令则 走下面步骤进行安装docker-compose
    4. # 1.安装扩展源
    5. sudo yum -y install epel-release
    6. # 2.安装python-pip模块
    7. sudo yum -y install python-pip
    8. # 3.查看docker-compose版本
    9. docker-compose version
    10. # 提示未找到命令
    11. # 4.通过以命令进行安装
    12. cd /usr/local/bin/
    13. wget https://github.com/docker/compose/releases/download/1.14.0-rc2/docker-compose-Linux-x86_64
    14. rename docker-compose-Linux-x86_64 docker-compose docker-compose-Linux-x86_64
    15. chmod +x /usr/local/bin/docker-compose
    16. # 5.再通过docker-compose version命令进行查看

    2.创建容器目录

    1. mkdir rocketmq
    2. # 在rocketmq目录下创建该文件或目录 结构如下
    3. [root@localhost rocketmq]# tree
    4. .
    5. ├── conf
    6. │ └── broker.conf
    7. ├── docker-compose.yml
    8. ├── logs
    9. └── store

    docker-compose.yml内容

    1. version: '3.2'
    2. services:
    3. rmqserver:
    4. image: foxiswho/rocketmq:server
    5. container_name: rmqserver
    6. ports:
    7. - 9876:9876
    8. volumes:
    9. - ./logs:/opt/logs
    10. - ./store:/opt/store
    11. networks:
    12. rmq:
    13. aliases:
    14. - rmqserver
    15. rmqbroker:
    16. image: foxiswho/rocketmq:broker
    17. container_name: rmqbroker
    18. ports:
    19. - 10909:10909
    20. - 10911:10911
    21. volumes:
    22. - ./logs:/opt/logs
    23. - ./store:/opt/store
    24. - ./conf/broker.conf:/usr/local/docker/rocketmq/broker.conf
    25. environment:
    26. NAMESRV_ADDR: "rmqserver:9876"
    27. JAVA_OPTS: " -Duser.home=/opt"
    28. JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
    29. command: mqbroker -c /usr/local/docker/rocketmq/broker.conf
    30. depends_on:
    31. - rmqserver
    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=rmqserver:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
    43. depends_on:
    44. - rmqserver
    45. networks:
    46. rmq:
    47. aliases:
    48. - rmqconsole
    49. networks:
    50. rmq:
    51. driver: bridge

    broker.conf内容如下(brokerIP1=虚拟机ip)

    1. censed 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.182
    27. # 在发送消息时,自动创建服务器不存在的topic,默认创建的队列数
    28. defaultTopicQueueNums=4
    29. # 是否允许 Broker 自动创建 Topic,建议线下开启,线上关闭 !!!这里仔细看是 falsefalsefalse
    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

    3.启动容器

    docker-compose up -d

    4.访问控制台

     

    http://192.168.0.182:8080/
  • 相关阅读:
    生产者消费者模型
    有意思的开源项目分享(持续更新,勤劳的搬运工,只放一些我感兴趣的)
    爱上开源之golang入门至实战第四章函数(Func)(九)
    在PyCharm中畅游机器学习深海,以支持向量机探索图像识别新航程
    如何系统地自学Python?
    美格智能,从5G智能模组到车规级C-V2X|金球奖入围公示
    SpringBoot安全漏洞SQL注入和XSS攻击简介说明
    MySQL事务
    AI绘画:SD绘画实操过程-完美世界-火灵儿-少女制作教程(附资料及变现)
    如何基于surging架设流媒体视频推流(视频讲解)
  • 原文地址:https://blog.csdn.net/xf552527/article/details/126901237