本地用docker快速搭建RocketMQ

本文旨在本地电脑使用docker快速搭建RocketMQ环境,用于调试,需要对docker有一定的认识。

摘要

  • 基本流程
  • 拉取rocketmq镜像
  • 配置文件
    • - broker配置文件
    • - stack.yml
  • 快速启动
  • 访问控制台
  • 参考文章

基本流程

拉取rocketmq镜像 -> 启动namesrv -> 启动broker -> 启动web控制台

拉取rocketmq镜像

docker pull rocketmqinc/rocketmq:4.4.0`

配置文件

- broker配置文件

先想好你要把rocketmq产生的文件放在电脑哪个位置,下面把这个位置称为[RmHome]。
在[RmHome]创建conf文件夹,在[RmHome]/conf中创建broker.conf文件,文件内容如下

brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = {本地外网 IP}

上面的brokerIP1处填本机ip(window用ipconfig命令行查看)

- stack.yml

在[RmHome]创建stack.yml文件,内容如下:

version: '3.1'

services:

  rmqnamesrv:
    image: rocketmqinc/rocketmq:4.4.0
    command: sh mqnamesrv
    restart: always
    environment:
      MAX_POSSIBLE_HEAP: 100000000
    networks:
      mq-network:
        aliases:
          - rmqnamesrv
    volumes:
      - ./namesrv/logs:/root/logs
      - ./namesrv/store:/root/store
    ports:
      - 9876:9876

  broker:
    image: rocketmqinc/rocketmq:4.4.0
    command: sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker.conf
    restart: always
    networks:
      mq-network:
        aliases:
          - broker
    environment:
      NAMESRV_ADDR: rmqnamesrv:9876
      MAX_POSSIBLE_HEAP: 200000000
    volumes:
      - ./broker/logs:/root/logs
      - ./broker/store:/root/store
      - ./conf/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf
    ports:
      - 10911:10911
      - 10909:10909
    depends_on:
      - rmqnamesrv
      
  console:
    image: styletang/rocketmq-console-ng
    environment:
      JAVA_OPTS: -Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false -Dserver.port=8888
    networks:
      mq-network:
        aliases:
          - console
    ports:
      - 8888:8888
    depends_on:
      - rmqnamesrv
      - broker
      
networks:
  mq-network:
    driver: bridge

快速启动

命令行在[RmHome]路径下敲以下命令:

docker-compose -f stack.yml up

访问控制台

http://localhost:8888

参考文章

https://www.cnblogs.com/kiwifly/p/11546008.html
https://github.com/apache/rocketmq-externals/tree/master/rocketmq-console

你可能感兴趣的:(Web,Java)