docker中怎么部署rocketmq集群

docker中怎么部署rocketmq集群,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:主机域名、网页空间、营销软件、网站建设、巍山网站维护、网站推广。

broker-a.conf

brokerClusterName = rocketmq-cluster
brokerName = broker-a
brokerId = 0
# 这里配置的宿主机外网IP
brokerIP1 = 192.168.1.254
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
# 外网IP
namesrvAddr=192.168.1.254:9876;192.168.1.254:9877
autoCreateTopicEnable=true
#Broker 对外服务的监听端口,和容器映射端口必须一致
listenPort = 10911
#Broker角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=ASYNC_MASTER
#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH

broker-b.conf

brokerClusterName = rocketmq-cluster
brokerName = broker-b
brokerId = 0
# 宿主机外网IP
brokerIP1 = 192.168.1.254
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
# 外网地址
namesrvAddr = 192.168.1.254:9876;192.168.1.254:9877
autoCreateTopicEnable=true
#Broker 对外服务的监听端口,和容器映射端口必须保持一致
listenPort = 11911
#Broker角色
#- ASYNC_MASTER 异步复制Master
#- SYNC_MASTER 同步双写Master
#- SLAVE
brokerRole=ASYNC_MASTER
#刷盘方式
#- ASYNC_FLUSH 异步刷盘
#- SYNC_FLUSH 同步刷盘
flushDiskType=ASYNC_FLUSH

docker-compose.xml

version: '3.5'
services:
  rmqnamesrv-a:
    image: rocketmqinc/rocketmq:4.5.0
    container_name: rmqnamesrv-a
    ports:
      - 9876:9876
    volumes:
      - /opt/rocketmq/logs/nameserver-a:/opt/logs
      - /opt/rocketmq/store/nameserver-a:/opt/store
    command: sh mqnamesrv
    networks:
        rmq:
          aliases:
            - rmqnamesrv-a

  rmqnamesrv-b:
    image: rocketmqinc/rocketmq:4.5.0
    container_name: rmqnamesrv-b
    ports:
      - 9877:9876
    volumes:
      - /opt/rocketmq/logs/nameserver-b:/opt/logs
      - /opt/rocketmq/store/nameserver-b:/opt/store
    command: sh mqnamesrv
    networks:
        rmq:
          aliases:
            - rmqnamesrv-b

  rmqbroker-a:
    image: rocketmqinc/rocketmq:4.5.0
    container_name: rmqbroker-a
    ports:
      - 10909:10909
      - 10911:10911
    volumes:
      - /opt/rocketmq/logs/broker-a:/opt/logs
      - /opt/rocketmq/store/broker-a:/opt/store
      - /home/rocketmq/broker-a/broker-a.conf:/opt/rocketmq-4.5.0/conf/broker.conf 
    environment:
        TZ: Asia/Shanghai
        NAMESRV_ADDR: "rmqnamesrv-a:9876"
        JAVA_OPTS: " -Duser.home=/opt"
        JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m"
    command: sh mqbroker -c /opt/rocketmq-4.5.0/conf/broker.conf autoCreateTopicEnable=true &
    links:
      - rmqnamesrv-a:rmqnamesrv-a
      - rmqnamesrv-b:rmqnamesrv-b
    networks:
      rmq:
        aliases:
          - rmqbroker-a

  rmqbroker-b:
    image: rocketmqinc/rocketmq:4.5.0
    container_name: rmqbroker-b
    ports:
      - 11909:11909
      - 11911:11911
    volumes:
      - /opt/rocketmq/logs/broker-b:/opt/logs
      - /opt/rocketmq/store/broker-b:/opt/store
      - /home/rocketmq/broker-b/broker-b.conf:/opt/rocketmq-4.5.0/conf/broker.conf 
    environment:
        TZ: Asia/Shanghai
        NAMESRV_ADDR: "rmqnamesrv-b:9876"
        JAVA_OPTS: " -Duser.home=/opt"
        JAVA_OPT_EXT: "-server -Xms256m -Xmx256m -Xmn256m"
    command: sh mqbroker -c /opt/rocketmq-4.5.0/conf/broker.conf autoCreateTopicEnable=true &
    links:
      - rmqnamesrv-a:rmqnamesrv-a
      - rmqnamesrv-b:rmqnamesrv-b
    networks:
      rmq:
        aliases:
          - rmqbroker-b
  rmqconsole:
    image: styletang/rocketmq-console-ng
    container_name: rmqconsole
    ports:
      - 9001:8080
    environment:
        JAVA_OPTS: -Drocketmq.namesrv.addr=rmqnamesrv-a:9876;rmqnamesrv-b:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false
    networks:
      rmq:
        aliases:
          - rmqconsole
networks:
  rmq:
    name: rmq
    driver: bridge

这里配置的容器端口映射,必须和配置文件配置的端口一致,因为客户端从nameserver取过来的broker地址就是配置文件里配置的brokerIP1:listenPort,所以容器启动的端口映射一定要一致,否则就访问不了,报错connect timeout

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注创新互联行业资讯频道,感谢您对创新互联的支持。


网页标题:docker中怎么部署rocketmq集群
新闻来源:http://scyanting.com/article/ghiies.html