RocketMQ learning process (3)----RocketMQ deployment (docker version)

RocketMQ deployment (docker version)

insert image description here

1. Preparations before deployment

  1. A linux machine. (I am using a centos7 server of Aliyun here)
  2. The docker environment and related simple knowledge.
  3. Some simple knowledge of computer networks. (It can help you fully understand why it is deployed like this)
    The docker deployment is very simple and fast, and the focus is on the characteristics of different networks. If you understand the characteristics of different networks, you can deploy related services with twice the result with half the effort.

Follow the link to learn the basic three basic networks in my last blog.
blog address

Reference documents:

  1. RocketMQ github official documentation https://github.com/apache/rocketmq
  2. Docker quickly builds RokcetMQ for short

2. Deployment process

Note: The official tutorial is directly on the host network, which is the same as the host network, so there is no need to open ports, and try not to open multiple containers. Multiple containers need to change ports. For multiple containers, please use the bridge mode.

2.1. Start the name server

docker run -it --net=host apache/rocketmq ./mqnamesrv

The startup is relatively simple and does not require any additional configuration files.

2.2. Start broker

  1. Create broker configuration (unlike nameserver, broker needs to manually configure broker address for routing registration.)

If you have started the broker, but you need to configure the address that the broker authenticates in the route, otherwise the consumer cannot be directed to the correct route.

The error is shown below
insert image description here

The ip here should be filled with the external network ip as much as possible ( note : the personal computer generally does not have a public network ip, so you can only fill in the local computer first, so that the program should also run on the local computer), because the middleware communication is generally not limited to one On the host, different hosts and even different locations are normal,

  1. Create broker mount related folders
mkdir -p /usr/dockerrocketmq/rmqbroker01/logs
mkdir -p /usr/dockerrocketmq/rmqbroker01/conf
mkdir -p /usr/dockerrocketmq/rmqbroker01/store
vi /usr/dockerrocketmq/rmqbroker01/conf/broker.conf
  1. Create a broker configuration file
    insert image description here
#nameserver的外网ip地址,这个一般为9876端口,这个配置项也可以不要,启动的时候指定
namesrvAddr=ip:port
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
#broker主机所在的外网ip,非常关键
brokerIP1 = ip
listenPort=10911
  1. create container
docker run -it --net=host -v  /usr/data/broker/logs:/root/logs -v  /usr/dockerrocketmq/rmqbroker01/store:/root/store -v  /usr/dockerrocketmq/rmqbroker01/conf/broker.conf:/opt/rocketmq-4.9.4/conf/broker.conf --name rmqbroker   rocketmqinc/rocketmq sh mqbroker -n ip:9876 -c /opt/rocketmq-4.9.4/conf/broker.conf

Although it is very long, the core idea is to mount three volumes, and the conf volume must be mounted, otherwise it is easy to not recognize the external network ip, resulting in a semi-disabled state of the middleware!

2.3. Start the socketmq-dashboard (it is not necessary to deploy, but it is recommended for novices to deploy)

docker run -e "JAVA_OPTS=-Drocketmq.namesrv.addr=外网ip:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8082:8080 -t pangliang/rocketmq-console-ng

I have something on 8080 here, so I changed it to port 8082.

insert image description here
insert image description here

You're done!

Guess you like

Origin blog.csdn.net/faker1234546/article/details/130411342