Docker installation of RocketMQ and solutions to problems encountered during installation

Docker installation of RocketMQ and solutions to problems encountered during installation

This article mainly introduces the installation of rocketMQ4.4.0, which is mainly divided into four steps:
1. Pull the rocketmq image.
2. Create namesrv.
3. Create a broker node. What I am introducing here is how to create a single broker.
4. rocketMQ-console service, used to manage the management interface of rocketMQ.

Pull the rocketmq image

The docker command is as follows

docker pull rocketmqinc/rocketmq:4.4.0

Create namesrv

Docker Commands

docker run -d --name rmqnamesrv -p 9876:9876 -v C:\data\rocketmq\logs:/root/logs -v C:\data\rocketmq\store:/root/store -e "MAX_POSSIBLE_HEAP=100000000" rocketmqinc/rocketmq:4.4.0 sh mqnamesrv

Parameter Explanation

parameter describe
-d Start as a daemon process
- -name Set the name of the container
-p The container's 9876 port is mapped to the local machine's 9876 port
-v Map the container/root/logs (log file) directory to the corresponding path on the local machine/map the container/root/store (data storage) directory to the corresponding path on the local machine
-e Set the container's maximum heap memory to 100000000
rocketmqinc/rocketmq:4.4.0 Image name: version
sh Start the service mqnamesrv

Create a single broker node

Docker Commands

docker run -d --name rmqbroker --link rmqnamesrv:namesrv -p 10911:10911 -p 10909:10909 --privileged=true -v C:\data\broker\logs:/root/logs -v C:\data\broker\store:/root/store -v C:\data\broker\conf\broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf -e "NAMESRV_ADDR=namesrv:9876" -e "MAX_POSSIBLE_HEAP=200000000" rocketmqinc/rocketmq:4.4.0 sh mqbroker -c /opt/rocketmq-4.4.0/conf/broker.conf

Parameter Explanation

parameter describe
-d Start as a daemon process
- -name Set the name of the container
- -link Establish communication with the rmqnamesrv container
-p 10911:10911 Map the container's non-VIP communication port 10911 to the local port 10911
-p 10909:10909 Map the container's VIP communication port 1090 to the local port 10909
–privileged=true Set to allow mounting of private folders
-v Map the container /root/logs (log file) directory to the corresponding path on the local machine/map the container /root/store (data storage) directory to the corresponding path on the local machine/map the container /opt/rocketmq-4.4.0/conf/broker.conf configuration file to the corresponding path on the local machine (you can modify the broker.conf file on the local machine each time and restart the container)
-e “NAMESRV_ADDR=namesrv:9876” Specify the namesrv address as 9876 on this machine
-e “MAX_POSSIBLE_HEAP=200000000” Set the maximum heap memory of the broker service to 200000000
rocketmqinc/rocketmq:4.4.0 Image name: version
sh mqbroker Start the service mqbroker
-c /opt/rocketmq-4.4.0/conf/broker.conf Specify the configuration file to start the broker

broker.conf file configuration

#If there are many nodes, you can configure multiple brokerClusterName = DefaultCluster
#broker name, master and slave use the same name, indicating their master-slave relationship brokerName = broker-a
#0 means Master, and values ​​greater than 0 mean different slaves
brokerId = 0
#Indicates the time to delete the message. The default is 4:00 a.m. deleteWhen = 04
#The length of time to keep messages on disk, in hours fileReservedTime = 48
#There are three values: SYNC_MASTER, ASYNC_MASTER, SLAVE; SYNC and ASYNC represent the mechanism for synchronizing data between Master and Slave;
brokerRole = ASYNC_MASTER
#Flushing strategy, the value is: ASYNC_FLUSH, SYNC_FLUSH means synchronous flushing and asynchronous flushing; SYNC_FLUSH message returns a success status only after it is written to the disk, ASYNC_FLUSH is not needed;
flushDiskType = ASYNC_FLUSH
# Set the IP address of the server where the broker node is located namesrvAddr = local IP address: 9876
brokerIP1 = local ip address

If the namesrvAddr configuration is not added to the broker.conf configuration file, the following error will be reported when the program is run:

Exception in thread "main" org.apache.rocketmq.remoting.exception.RemotingTooMuchRequestException: sendDefaultImpl call timeout
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.sendDefaultImpl(DefaultMQProducerImpl.java:588)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1223)
at org.apache.rocketmq.client.impl.producer.DefaultMQProducerImpl.send(DefaultMQProducerImpl.java:1173)
at org.apache.rocketmq.client.producer.DefaultMQProducer.send(DefaultMQProducer.java:214)
at com.baojian.mob.base.producer.SyncProducer.main(SyncProducer.java:41)
15:22:31.455 [NettyClientSelector_1] INFO RocketmqRemoting - closeChannel: close the connection to remote address[] result: true
15:22:32.049 [NettyClientSelector_1] INFO RocketmqRemoting - closeChannel: close the connection to remote address[] result: true

rocketMQ-console service

Docker Commands

You can directly execute the docker run command instead of using the docker pull command to pull the image. If the image does not exist, the image will be pulled first and then docker run will be executed.

docker run -d --name rmqadmin -e "JAVA_OPTS=-Drocketmq.namesrv.addr=172.16.122.115:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false" -p 8081:8080 pangliang/rocketmq-console-ng

Parameter Description

describe illustrate
-d Start as a daemon process
- -name Set the name of the container
-e "JAVA_OPTS=-Drocketmq.namesrv.addr=172.16.122.115:9876 Set the IP address of the namesrv service
-Dcom.rocketmq.sendMessageWithVIPChannel=false" Send messages without using VIP channel
-p 8081:8080 Map port 8080 in the container to port 8081 on the host

After the rocketmq-console interface container runs successfully, use a browser to open http://127.0.0.1:8081 to enter the rokcetmq-console management interface and see the cluster information, indicating that rocketmq has been installed successfully.

insert image description here

Rocketmq-console producer interface error

insert image description here

Click Search and an error message appears because the producer uses producer.shutdown() to close the production group after creating it. You can log out with the following code.

insert image description here

This is the end of this article about installing rocketMQ in docker and solving problems during the installation process. For more information about installing rocketMQ in docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Docker-compose installation yml file configuration method
  • Detailed steps for installing ros2 in docker
  • The most detailed method to install docker on CentOS 8
  • Detailed process of installing logstash in Docker
  • The process of installing Docker on Windows Server 2016 and the problems encountered
  • Quick installation of Docker step-by-step tutorial

<<:  Summary of JavaScript custom object methods

>>:  A brief discussion on the definition and precautions of H tags

Recommend

WeChat applet development form validation WxValidate usage

I personally feel that the development framework ...

Vue example code using transition component animation effect

Transition document address defines a background ...

Detailed tutorial on installing and configuring MySql5.7 on Ubuntu 20.04

Table of contents 1. Ubuntu source change 2. Inst...

DIV common attributes collection

1. Property List Copy code The code is as follows:...

Use of Linux cal command

1. Command Introduction The cal (calendar) comman...

Six methods for nginx optimization

1. Optimize Nginx concurrency [root@proxy ~]# ab ...

Detailed explanation of how components communicate in React

1. What is We can split the communication between...

Angular environment construction and simple experience summary

Introduction to Angular Angular is an open source...

MySQL 8.0.12 Quick Installation Tutorial

The installation of MySQL 8.0.12 took two days an...

HTML dynamically loads css styles and js scripts example

1. Dynamically loading scripts As the demand for ...

Linux gzip command compression file implementation principle and code examples

gzip is a command often used in Linux systems to ...