[Docker application articles] Docker installs RocketMQ
Install Docker on CentOS 7.4
1. Older versions of Docker are called docker or docker-engine, if you have installed these, please uninstall them:
yum remove -y docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
2. Install some necessary tools:
yum install -y yum-utils device-mapper-persistent-data lvm2
3. Added Docker
repository
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
4. Install Docker-ce (Community Edition)
yum install -y docker-ce
5. Start Docker
systemctl enable docker
Docker install RocketMQ
Technology Architecture
The RocketMQ architecture is mainly divided into four parts, as shown in the figure above:
- Producer: The role of message publishing, which supports distributed cluster deployment. The Producer selects the corresponding Broker cluster queue for message delivery through the MQ load balancing module. The delivery process supports fast failure and low latency.
- Consumer: The role of message consumption, which supports distributed cluster deployment. It supports two modes of push and pull to consume messages. At the same time, it also supports cluster mode and broadcast mode consumption. It provides a real-time message subscription mechanism, which can meet the needs of most users.
- NameServer: NameServer is a very simple topic routing registry, its role is similar to the zookeeper in Dubbo, and it supports the dynamic registration and discovery of Broker. It mainly includes two functions: Broker management, NameServer accepts the registration information of the Broker cluster and saves it as the basic data of routing information. Then provide a heartbeat detection mechanism to check whether the Broker is still alive; routing information management, each NameServer will save the entire routing information about the Broker cluster and queue information for client queries. Then Producer and Conumser can know the routing information of the entire Broker cluster through the NameServer, so as to deliver and consume messages. NameServer is also usually deployed in a cluster, and the instances do not communicate with each other. Broker registers its own routing information with each NameServer, so each NameServer instance saves a complete routing information. When a NameServer goes offline for some reason, Broker can still synchronize its routing information to other NameServers, and Producer and Consumer can still dynamically perceive the routing information of Broker.
- BrokerServer: Broker is mainly responsible for message storage, delivery and query, as well as service high availability guarantee. In order to realize these functions, Broker includes the following important sub-modules.
- Remoting Module: The entire Broker entity is responsible for processing requests from clients.
- Client Manager: responsible for managing the client (Producer/Consumer) and maintaining the Topic subscription information of the Consumer
- Store Service: Provides a convenient and simple API interface to handle message storage to physical hard disk and query functions.
- HA Service: High availability service, providing data synchronization function between Master Broker and Slave Broker.
- Index Service: Index service for messages delivered to Broker according to a specific Message key to provide fast query of messages
Install
1. Search and query the rocketmq image in the remote warehouse
docker search rocketmq
2. The foxiswho/rockermq mirror has the most stars, so pull and run the mirror. Create a NameServer container and start it, the port uses the default port of RecketMQ
docker run -d -p 9876:9876 --name rmqserver foxiswho/rocketmq:server-4.5.1
3. Create a broker container and start it, because Broker needs to be configured and needs to be modified, so when creating a broker container, use the configuration file of the host machine for future modification.
vim /usr/local/java_study/roketmq/conf/broker.conf
brokerIP1 = 192.168.56.10
: the ip address of the virtual machine
brokerIP1 = 192.168.56.10
listenPort = 10911
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
enablePropertyFilter=true
4. Create and 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" -v /usr/local/java_study/roketmq/conf/broker.conf:/etc/rocketmq/broker.conf foxiswho/rocketmq:broker-4.5.1
5. Docker install the visual management page of RocketMQ
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
Access: http://192.168.56.10:8180/#/ RocketMQ visual interface console