Project address: Docker-Rocketmq-cluster

1, the profile

Rocket-mq cluster environment with docker-image+docker-compose is a local rocket-MQ cluster environment with 2Broker (6node)+2name-server

Rocket-mq version: 4.8.0

Go – client version: go get – u – v github.com/apache/rocketmq-client-go/[email protected]

Rocker-mq Official documentation: Documentation links

Learning Documents:

  • Source code environment construction
  • CommitLog&&ConsumerQueue&&IndexFile&& delay queue source analysis
  • The broker learning
  • The name – server learning
  • Rocket-mq vs. Kafka
  • Advantages and disadvantages of various clustering modes

2, the characteristics of

1. Support rocket-MQ cluster building through local Docker environment

2, support horizontal expansion of multiple nodes, easy to view

3. Rocketmq-console startup support for Web-UI

3. Questions:

1, the rocketMQ shell script problem, the main cause of the RocketMQ startup script shell problem is not standardized, you can see github.com/apache/rock…

2, remember to modify the JVM parameters when starting, otherwise the local cluster will instantly explode when starting, a single Broker memory is 8GB, you can control the JVM startup parameters through the environment variable JAVA_OPT_EXT, or docker container memory is insufficient, directly killed process.

3. Remember that the total memory of the computer allocated to Docker should not be too small. The following is the Docker configuration information of my machine

➜  ~ docker info
Containers: 55
 Running: 0
 Paused: 0
 Stopped: 55
Images: 323
Server Version: 18.09.2
##...OSType: Linux Architecture: x86_64 CPUs: 4 Total Memory: 5.818GiB Name: Linuxkit-025000000001 ID: 5JBH:7VOE:3R3W:6G4I:6NXD:AXGN:MI2Z:DNUI:7BZ5:KRT6:NC5T:AJGE Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): true File Descriptors: 24 Goroutines: 50 System Time: The 2021-02-07 T08: instructed. 936909812 z EventsListeners: 2##...
Copy the code

4. Project Catalog

➜ rocket_mq git:(master) go onto university and those who qualify can go onto university. ├── Makefile ## ├─ broker-01 ## 1university 3 Node ├─ broker-02 ├─ broker-03 ├─ Docker-compose.yML # Docker-compose Start Script ├─ Image # Rocket MQ Local Image ├─ Nameserver - 01 # # name - server two nodes └ ─ ─ nameserver - 02Copy the code

You can scale multiple nodes horizontally by modifying local files

5, start,

1. Broker configuration

In the case of broker-01, the configuration file is in broker-01/conf/broker.conf, so the start parameter is mqbroker-c conf/broker.conf, remember that a Broker must have at least three nodes. BrokerId =0 is not required to manually specify brokerId=0 as master. The advantage of DLeger is that it automatically selects the leader as Kafka does.

# # # # # # # # # # # # # # # # # # # # # # # broker configuration # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Cluster concept not clear at present
brokerClusterName = RaftCluster
The name of the broker
brokerName=RaftNode00
If dLeger mode is used, the default value is -1, so it is not configured
# brokerId=-1
# local network adapter IP address, (if you are on the Intranet, you can not set this, because we need to write your local eth0 network adapter, remember to change)
brokerIP1=192.168.1.4
Listen on port 10911 by default
listenPort=10911
# the name - server configuration
namesrvAddr=nameserver-01:9876; nameserver-02:9876
# Automatic creation of topics is not allowed
autoCreateTopicEnable=false
# # # # # # # # # # # # # # # # # DLeger configuration # # # # # # # # # # # # # # # # # # # # # # # # # #
Whether to enable DLegerCommitLog
enableDLegerCommitLog=true
BrokerName better be the same as brokerName
dLegerGroup=RaftNode00
dLegerPeers=n0-broker-01:40911; n1-broker-02:40911
dLegerSelfId=n0
sendMessageThreadPoolNums=4
Copy the code

The complete configuration can be seen as: Broker

2. Configure nameserver

Since name-server configuration is not very many, the default configuration can be used. (Since we deploy an instance on a single machine, there is no need to consider environment conflicts, and it is not recommended to put name-Server and Broker on the same machine.)

The default configuration is name-server

3,dLegerPattern deployment

This paper adopts dLeger mode, the specific mode can be seen,github.com/apache/rock… To be highly available, each broker must have at least three nodes (as determined by its election mechanism). See below for down simulation

The overall architecture is: 2N + 1M + 2S, the cluster can be expanded at will

Machine node role broker-name note
nameserver-01 nameserver
nameserver-02 nameserver
broker-01 broker RaftNode00 Select Master without specifying brokerId
broker-02 broker RaftNode00
broker-03 broker RaftNode00
➜ rocket_MQ docker exec -it a629EE26b7a9 mqadmin clusterList -n "nameserver-01:9876; nameserver-02:9876" RocketMQLog:WARN No appenders could be found for logger (io.netty.util.internal.PlatformDependent0).  RocketMQLog:WARN Please initialize the logger system properly.#Cluster Name     #Broker Name #BID #Addr #Version #InTPS(LOAD) #OutTPS(LOAD) #PCWait(ms) #Hour #SPACERaftCluster RaftNode00 0 172.15.64.10:10911 V4_8_0 0.00(0,0ms) 0.00(0,0ms) 0 447918.62-1.0000 RaftCluster RaftNode00 2 172.15.64.10:10912 V4_8_0 0.00(0,0ms) 0.00(0,0ms) 0 447918.62-1.0000 RaftCluster RaftNode00 3 172.15.64.10:10913 V4_8_0 0.00(0,0ms) 0.00(0,0ms) 0 447918.62-1.0000Copy the code

4. Advantages and disadvantages of other deployment modes

Official documentation: github.com/apache/rock…

Other documents: Cluster mode

5, start,

1, go to the docker directory, then go to the image directory and execute make

Docker-compose –compatibility up -d: docker-compose –compatibility up -d: docker-compose –compatibility up -d: docker-compose –compatibility up -d

➜  rocket_mq make run                
docker-compose --compatibility up -d
Creating network "rocket_mq_default" with the default driver
Creating rocket_mq_broker-01_1        ... done
Creating rocket_mq_nameserver-02_1    ... done
Creating rocket_mq_broker-03_1        ... done
Creating rocket_mq_rocketmq-console_1 ... done
Creating rocket_mq_broker-02_1        ... done
Creating rocket_mq_nameserver-01_1    ... done
Copy the code

2. View broker nodes

➜ Rocket_MQ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a629EE26b7A9 RocketMQ :v4.8.0 "mqbroker-c The conf/br..." 2 minutes ago Up 2 minutes 9876/tcp, 10911/tcp, 0.0.0.0:10912->10912/ TCP Rocket_MQ_broker-02_1 6dbbec743077 RocketMQ :v4.8.0 "mqNAMesrv" 2 minutes ago Up 2 minutes Rocketmq :v4.8.0 "MQbroker -C conf/br..." 2 minutes ago Up 2 minutes 9876/tcp, 0.0.0.0:10911->10911/ TCP Rocket_MQ_broker-01_1 BAD3443FD2b7 RocketMQ :v4.8.0 "mqNAMesrv" 2 minutes ago Up 2 minutes 10911/tcp, 0.0.0.0:9872->9876/ TCP rocket_MQ_nameserver-02_1 6CB53d20f162 ApacherocketMQ/RocketMQ-console :2.0.0 "sh -c 'Java $JAVA_O..." 2 minutes ago Up 2 minutes 0.0.0.0:8080->8080/ TCP Rocket_MQ_Rocketmq-console_1 10AE582153EB RocketMQ :v4.8.0 "mqbroker-c The conf/br..." 2 minutes ago Up 2 minutes 9876/ TCP, 10911/ TCP, 0.0.0.0:10913->10913/ TCP rocket_mq_broker-03_1Copy the code

3. Check the resource usage of the Docker node

➜ rocket_mq git:(master) qualify docker stats --no-stream CONTAINER ID NAME CPU % MEM USAGE/LIMIT MEM % NET I/O BLOCK I/O PIDS a629EE26b7a9 Rocket_MQ_broker-02_1 34.21% 373.6MiB / 512MiB 72.96% 1.66MB / 1.16MB 41.6MB / 8.95MB 158 6dbbec743077 Rocket_mq_nameserver-01_1 0.28% 131.9MiB / 256MiB 51.52% 843kB / 419kB 5.63MB / 8.96MB 41 e9ffbeba13bd Rocket_mq_broker-01_1 35.53% 390.1MiB / 512MiB 76.20% 1.49MB / 3.67MB 9.45MB / 8.95MB 160 BAD3443FD2b7 Rocket_mq_nameserver-02_1 0.30% 149.4MiB / 256MiB 58.38% 860kB / 442kB 30.5MB / 8.96MB 41 6CB53D20f162 Rocket_mq_rocketmq-console_1 0.56% 240.6MiB / 256MiB 93.97% 1.45MB / 924kB 124MB / 46.4MB 43 10ae582153eb Rocket_mq_broker-03_1 38.44% 401.4MiB / 512MiB 78.40% 1.65MB / 1.15MB 2.95MB / 8.95MB 158Copy the code

4. Check the total memory usage (this is the memory usage of 6 Docker containers)

➜ rocket_mq git: (master) ✗ docker stats - no - stream | awk '{print $4}' | sed '1 d | awk' {} a + = $1 END {printf "% sM \ n", a} ' 1676.9 MCopy the code