docker-compose.yml
Note: Start RocketMQ Server + Broker + Console needs at least 2G memory
version: '3.5'
services:
rmqnamesrv:
image: foxiswho/rocketmq:server
container_name: rmqnamesrv
ports:
- 9876:9876
volumes:
- ./data/logs:/opt/logs
- ./data/store:/opt/store
networks:
rmq:
aliases:
- rmqnamesrv
rmqbroker:
image: foxiswho/rocketmq:broker
container_name: rmqbroker
ports:
- 10909:10909
- 10911:10911
volumes:
- ./data/logs:/opt/logs
- ./data/store:/opt/store
- ./data/brokerconf/broker.conf:/etc/rocketmq/broker.conf
environment:
NAMESRV_ADDR: "rmqnamesrv:9876"
JAVA_OPTS: " -Duser.home=/opt"
JAVA_OPT_EXT: "-server -Xms128m -Xmx128m -Xmn128m"
command: mqbroker -c /etc/rocketmq/broker.conf
depends_on:
- rmqnamesrv
networks:
rmq:
aliases:
- rmqbroker
rmqconsole:
image: styletang/rocketmq-console-ng
container_name: rmqconsole
ports:
- 8080:8080
environment:
JAVA_OPTS: "-Drocketmq.namesrv.addr=rmqnamesrv:9876 -Dcom.rocketmq.sendMessageWithVIPChannel=false"
depends_on:
- rmqnamesrv
networks:
rmq:
aliases:
- rmqconsole
networks:
rmq:
name: rmq
driver: bridge
broker.conf
RocketMQ Broker requires a configuration file, in accordance with the above Compose configuration, we need to create a configuration file called broker.conf in ./data/brokerconf/ directory, as follows:
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Belongs to a cluster name
brokerClusterName=DefaultCluster
broker name, pay attention here to fill in a different configuration file is not the same, if used in broker-a.properties: broker-a,
In broker-b.properties using: broker-b
brokerName=broker-a
0 for Master,> 0 represents Slave
brokerId=0
nameServer addresses, separated by semicolons
namesrvAddr=rocketmq-nameserver1:9876;rocketmq-nameserver2:9876
启动IP,如果 docker 报 com.alibaba.rocketmq.remoting.exception.RemotingConnectException: connect to <192.168.0.120:10909> failed
1 solution plus a producer.setVipChannelEnabled (false) ;, solution 2 brokerIP1 set the host IP, do not use the internal docker IP
brokerIP1=192.168.0.253
When sending a message, the server automatically creates a topic does not exist, the number of queues created by default
defaultTopicQueueNums=4
Whether to allow the Broker to automatically create Topic, turn on the advice of the line, the line is closed! ! ! Here is a closer look false, false, false
autoCreateTopicEnable=true
Whether to allow the Broker to automatically create a subscription group, the advice line open, online close
autoCreateSubscriptionGroup=true
Broker listening port external services
listenPort=10911
Delete files point in time, the default 4:00
deleteWhen=04
File retention time, default 48 hours
fileReservedTime = 120
CommitLog default size of each file 1G
mapedFileSizeCommitLog=1073741824
ConsumeQueue default file save 30W each strip, adjusted according to business conditions
mapedFileSizeConsumeQueue=300000
destroyMapedFileIntervalForcibly=120000
redeleteHangedFileInterval=120000
Detect physical file disk space
diskMaxUsedSpaceRatio = 88
Storage path
storePathRootDir=/home/ztztdata/rocketmq-all-4.1.0-incubating/store
commitLog storage path
storePathCommitLog=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/commitlog
Consumer queue storage
storePathConsumeQueue=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/consumequeue
Message index storage path
storePathIndex=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/index
checkpoint file storage path
storeCheckpoint=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/checkpoint
abort file storage path
abortFile=/home/ztztdata/rocketmq-all-4.1.0-incubating/store/abort
The message size limit
maxMessageSize=65536
flushCommitLogLeastPages=4
flushConsumeQueueLeastPages=2
flushCommitLogThoroughInterval=10000
flushConsumeQueueThoroughInterval=60000
Broker Role
- ASYNC_MASTER asynchronous replication Master
- SYNC_MASTER synchronous dual-write Master
- SLAVE
brokerRole=ASYNC_MASTER
Brush pan mode
- ASYNC_FLUSH asynchronous brush disc
- SYNC_FLUSH brush disc Synchronization
flushDiskType=ASYNC_FLUSH
Message number of threads pool
sendMessageThreadPoolNums=128
The number of threads to pull messages pool
pullMessageThreadPoolNums=128
RocketMQ console
Visit http: // rmqIP: 8080 login console