Centos at Docker cluster deployment RocketMQ

  • About RocketMQ

  RocketMQ Ali open source messaging middleware, support for distributed deployment, characterized by high concurrent high availability, in short, very cattle it, there are many details to his online community are also considered now more active, and will not introduce more (in fact, It is to understand not deep, not fraught).

  So powerful middleware course, going to experience some learning to learn, but as we have to learn to use, they come deployed environment again, so there is this installation procedure.

  • surroundings

  16G memory cloud virtual machine, Centos7.2,16G memory, because the performance is not high, so the limited test conditions may vary errata, please forgive me.

  Currently RocketMQ official support Centos and Alpine (very small operating system, it is suitable for the production of docker Mirror)

  The default system already installed docker, do not have the students go https://www.cnblogs.com/stulzq/p/7743073.html install it first, the need to set up a mirror to accelerate, after setting method generally installed Please refer to https://yq.aliyun.com/articles/29941

  • Start
  1. Download rocketmq-docker project address , the project contains Centos and alpine system creates a mirror script, you can simply modify
  2. Image-build into the directory, there can be seen a Docker-centos file, as shown in FIG.
  3. Open Dockerfile, found to rocketmq installation package to download, and the download from the Apache default master, it will be very slow, this image is downloaded into Tsinghua
    follows

    Modify the line about 50 to https://mirrors.tuna.tsinghua.edu.cn/apache/rocketmq/${ROCKETMQ_VERSION}/rocketmq-all-${ROCKETMQ_VERSION}-bin-release.zip,
    here to note that if you copy from mirror sites link back URL protocol name is not likely to get with ":", such as the mirror image of Tsinghua began as "http //",

  4. Save the file, execute build-image.sh

    Version here refers rocketmq version, BaseImage refers to the base image, where you can choose centos or alpine, here chose centos, rocketmq version 4.5.0.
    Meal after output, then the following tips explain our rocketmq image is successfully installed

    by

    docker images

    View mirror can see there is a rocketmq

    At this point we create a mirror on the end 

  5. MQ configuration file is created in the local
    configuration file is mainly broker configuration file, created here two broker master to form a broker cluster, the configuration of the two profiles, respectively, broker-a.conf and broker-b.conf
    below posted profiles
    broker-a.conf

    Cluster-rocketmq = brokerClusterName 
    brokerName = Broker-A 
    brokerId = 0 
    brokerIP1 = your server IP, if you want your message transmission outside the network, the external network need to paste the IP 
    deleteWhen = 04 
    fileReservedTime = 48 
    brokerRole = ASYNC_MASTER 
    flushDiskType = ASYNC_FLUSH 
    namesrvAddr = IP1 : 9876; IP2: 9877, 
    autoCreateTopicEnable = to true 
    the listenPort = 10911

    broker-b.conf

    brokerClusterName = rocketmq-cluster
    brokerName = broker-b
    brokerId = 0
    brokerIP1 = ip
    deleteWhen = 04
    fileReservedTime = 48
    brokerRole = ASYNC_MASTER
    flushDiskType = ASYNC_FLUSH
    namesrvAddr = ip1:9876;ip2:9877
    autoCreateTopicEnable = true
    listenPort = 10921

    NamesrvAddr above, if the broker can access the network posted within the network IP, and generally broker access nameserver is through the network.
    In the broker-b, the need to modify the main brokerName, the other can remain the same, but listenPort matching needs with ports in the back of docker-compose.yml, docker-compose.yml below will be posted   

  6. Created by docker-compose RocketMQ service
    k8s, swarm and what does not, what can only be maintained with a docker-compose life like this.
    By docker-compose, create two nameserver, two broker and monitoring console, are two broker a master pattern to form a cluster registry and data services, and advanced application filter after repeat
    docker-compose.yml
    version: '3.5'
    services:
     rmqnamesrv-a:
      image: rocketmqinc/rocketmq
      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
      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
      container_name: rmqbroker-a
      ports:
       - 10911:10911
       - 10912:10912
      volumes:
       - /opt/rocketmq/logs/broker-a:/opt/logs
       - /opt/rocketmq/store/broker-a:/opt/store
       - /etc/rocketmq/conf/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: "-Xms256m -Xmx256m"
      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
      container_name: rmqbroker-b
      ports:
       - 10921:10921
       - 10922:10922
      volumes:
       - /opt/rocketmq/logs/broker-b:/opt/logs
       - /opt/rocketmq/store/broker-b:/opt/store
       - /etc/rocketmq/conf/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: "-Xms256m -Xmx256m"
      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:9001
      environment:
       JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv-a:9876;rmqnamesrv-b:9877 -Dcom.rocketmq.sendMessageWithVIPChannel=false -Dserver.port=9001" 
      networks:
       rmq:
        aliases:
         - rmqconsole
      networks:
       rmq:
        aliases:
         - rmqbroker-b 
    networks:
     rmq:
      name: rmq
      driver: bridge

    NOTE:  Docker-compose.yml in volumes corresponding configuration items, the local directory should be created first, and configure permissions

  7. Start Service
    docker-compose up

    In docker-compose.yml the directory where the code is executed, you can start the whole service.
    After a good start, you can enter the console through a browser, access the address http: // consoleIp:. 9001 /
    port here I am with the 9001, the service can be modified by docker-compose.yml in rmqconsole

     

Guess you like

Origin www.cnblogs.com/jeff-winger/p/11415755.html