Installation and Use of RocketMQ in Docker

Time:2019-8-3

Searching for RocketMQ images can be done through docker hub.docker.com or through docker search command under Linux. However, after the recent firewall upgrade, the opening of foreign websites is very slow. Searching by command is more convenient. Docker commands must be root users or users. Users with root privileges. The query operation is as follows:


docker search rocketmq

The following results can be obtained:

 

Mirrors are plentiful, but it seems that none of them are officially released. I’ll just pick one, such as foxiswho / rocketmq. Here’s a shell command to view all versions of the current image:


curl https://registry.hub.docker.com/v1/repositories/foxiswho/rocketmq/tags\
| tr -d '[\[\]" ]' | tr '}' '\n'\
| awk -F: -v image='foxiswho/rocketmq' '{if(NR!=NF && $3 != ""){printf("%s:%s\n",image,$3)}}'

If you want to view other images, you just need to replace the image name foxiswho/rocketmq with other images, and execute the command to get the following results:

The following is the step-by-step start of nameserver and broker.

Start NameServer:


docker run -d -p 9876:9876 --name rmqserver foxiswho/rocketmq:server-4.5.1

Start broker:


docker run -d -p 10911:10911 -p 10909:10909\
 --name rmqbroker --link rmqserver:namesrv\
 -e "NAMESRV_ADDR=namesrv:9876" -e "JAVA_OPTS=-Duser.home=/opt"\
 -e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m"\
 foxiswho/rocketmq:broker-4.5.1

The default configuration file path in the Broker container is:


/etc/rocketmq/broker.conf

The local configuration file can also be specified by the – V parameter:


docker run -d -p 10911:10911 -p 10909:10909\
 --name rmqbroker --link rmqserver:namesrv\
 -e "NAMESRV_ADDR=namesrv:9876" -e "JAVA_OPTS=-Duser.home=/opt"\
 -e "JAVA_OPT_EXT=-server -Xms128m -Xmx128m"\
 -v /conf/broker.conf:/etc/rocketmq/broker.conf \
 foxiswho/rocketmq:broker-4.5.1

If all goes well, Name Server and Broker will be installed in a moment. Rocketmq console is also an essential tool for management convenience. Find the version that needs to be started by querying above. The way to start is as follows:


docker run -d --name rmqconsole -p 8180:8080 --link rmqserver:namesrv\
 -e "JAVA_OPTS=-Drocketmq.namesrv.addr=namesrv:9876\
 -Dcom.rocketmq.sendMessageWithVIPChannel=false"\
 -t styletang/rocketmq-console-ng

Then check the startup by following commands:


docker ps|grep rocketmq

The results are as follows:

Then access localhost: 8180 through browser. The page of console is shown as follows:

 

The above is the whole content of this article. I hope it will be helpful to everyone’s study, and I hope you will support developpaer more.

Recommended Today

Analysis of new data type instances of ES6 learning notes

An example of this paper describes the new data types of ES6 learning notes. To share with you for your reference, as follows: 1. Data deconstruction assignment 1. Deconstruction and assignment of arrays Basic usage: let [key1, key2…] = [value1, Value2…] Let [name, age, sex] = [‘xiaoming ‘, 24,’ male ‘]; console.log(name); console.log(age); console.log(sex); Note […]