Docker部署rocketmq服务

Dokcer部署rocketmq服务

    • Docker run的方式部署
      • 1.安装nameserver
      • 2.安装broker服务器
      • 3.安装rocketmq控制台
    • Docker-compose的方式部署
      • 1.准备所需要的镜像文件
      • 2.编写docker-compose.yml文件
      • 3.安装docker-compose
      • 4.执行文件
    • 验证容器是否正常

Docker run的方式部署

1.安装nameserver

# 拉取镜像
docker pull rocketmqinc/rocketmq:4.3.0 

# 创建所需目录
mkdir -p /data/namesrv/logs
mkdir -p /data/namesrv/store


# 运行容器
docker run -d -p 9876:9876 -v /data/namesrv/logs:/root/logs -v /data/namesrv/store:/root/store --name rmqnamesrv -e "MAX_POSSIBLE_HEAP=100000000" rocketmqinc/rocketmq:4.3.0 sh mqnamesrv

2.安装broker服务器

# 创建对应目录
mkdir -p /data/broker/logs
mkdir -p /data/broker/store

# 编辑rocketmq配置文件(brokerIP1使用外网地址)
[root@localhost ~]# cat broker.conf 
brokerClusterName = DefaultCluster 
brokerName = broker-a 
brokerId = 0 
deleteWhen = 04 
fileReservedTime = 48 
brokerRole = ASYNC_MASTER 
flushDiskType = ASYNC_FLUSH 
brokerIP1 = 192.168.33.155

# 启动容器
docker run -d -p 10911:10911 -p 10909:10909 -v  /data/broker/logs:/root/logs -v  /data/broker/store:/root/store -v  /root/broker.conf:/opt/rocketmq-4.3.0/conf/broker.conf --name rmqbroker --link rmqnamesrv:namesrv -e "NAMESRV_ADDR=namesrv:9876" -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq:4.3.0 sh mqbroker -c /opt/rocketmq-4.3.0/conf/broker.conf

3.安装rocketmq控制台

# 拉取镜像
docker pull pangliang/rocketmq-console-ng 
# 运行容器
docker run -e "JAVA_OPTS=-Drocketmq.namesrv.addr=192.168.33.155:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8080:8080 -t pangliang/rocketmq-console-ng

Docker-compose的方式部署

1.准备所需要的镜像文件

docker pull rocketmqinc/rocketmq:4.3.0 
docker pull pangliang/rocketmq-console-ng

2.编写docker-compose.yml文件

version: '3.5'
services:
  rmqnamesrv:
    image: rocketmqinc/rocketmq:4.3.0
    container_name: rmqnamesrv
    ports:
      - 9876:9876
    volumes:
      - /opt/namesrv/logs:/opt/logs
      - /opt/namesrv/store:/opt/store
    environment:
    	TZ: Asia/Shanghai
    	JAVA_OPT_EXT: "-server -Xms512m -Xmx512m -Xmn256m"
    command: sh mqnamesrv
    networks:
        rmq:
          aliases:
            - rmqnamesrv
  rmqbroker:
    image: rocketmqinc/rocketmq:4.3.0
    container_name: rmqbroker
    ports:
      - 10911:10911
      - 10909:10909
    volumes:
      - /opt/broker/logs:/opt/logs
      - /opt/broker/store:/opt/store
      - /root/broker.conf:/opt/rocketmq-4.3.0/conf/broker.conf 
    environment:
    	TZ: Asia/Shanghai
        NAMESRV_ADDR: "rmqnamesrv:9876"
        MAX_POSSIBLE_HEAP: 200000000
        JAVA_OPT_EXT: "-server -Xms1g -Xmx1g -Xmn512m"
    command: sh mqbroker -c /opt/rocketmq-4.3.0/conf/broker.conf 
    links:
      - rmqnamesrv:namsrv
    networks:
      rmq:
        aliases:
          - rmqbroker
  rmqconsole:
    image: pangliang/rocketmq-console-ng
    container_name: rmqconsole
    ports:
      - 8080:8080
    environment:
    	TZ: Asia/Shanghai
        JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
    networks:
      rmq:
        aliases:
          - rmqconsole
networks:
  rmq:
    name: rmq
    driver: bridge

3.安装docker-compose

curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# 验证:
docker-compose --version
# docker-compose位于/wiz/wiz-learning/软件包

4.执行文件

docker-compose -f docker-compose.yml up -d

验证容器是否正常

  1. 查看容器状态是否正常,保证必须是UP状态
    在这里插入图片描述
  2. 查看namesrv和broker日志(关键字success)

在这里插入图片描述

  1. 使用浏览器打开rocketmq控制台

    访问:192.168.33.155:8080

Docker部署rocketmq服务_第1张图片

你可能感兴趣的:(Message,Queue)