1. Install docker
1) Install docker
# 删除旧版本
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
# 设置源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 安装指定版本
curl https://releases.rancher.com/install-docker/18.09.sh | sh
# 开机启动
systemctl enable docker
2) Install docker-compose
sudo curl -L https://github.com/docker/compose/releases/download/1.25.1-rc1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose \
&& chmod +x /usr/local/bin/docker-compose
or
curl -L "https://get.daocloud.io/docker/compose/releases/download/1.27.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
## 加上许可权限
chmod +x /usr/local/bin/docker-compose
2. Install rocketmq
1. Prepare the configuration file
1) Create docker-compose.yml
version: '3'
services:
# rocket mq name server
rmqnamesrv:
image: apache/rocketmq:4.9.4
restart: always
container_name: rocket-server
# environment:
# JAVA_OPT_EXT: "-server -Xms64m -Xmx64m -Xmn64m"
# volumes:
# 映射本地目录权限一定要设置为 777 权限,否则启动不成功
# - ../volumes/data/rocket/server/logs:/home/rocketmq/logs
networks:
- rocketmq
ports:
- 9876:9876
command: sh mqnamesrv
# rocket mq broker
rmqbroker:
image: apache/rocketmq:4.9.4
restart: always
container_name: rocket-broker
volumes:
# 映射本地目录权限一定要设置为 777 权限,否则启动不成功
# - ../volumes/data/rocket/broker/logs:/home/rocketmq/logs
# - ../volumes/data/rocket/broker/store:/home/rocketmq/store
- ./config/broker.conf:/opt/rocketmq-4.9.4/conf/broker.conf
environment:
- NAMESRV_ADDR=rmqnamesrv:9876
# - JAVA_OPTS:=-Duser.home=/opt
- JAVA_OPT_EXT=-server -Xms64m -Xmx64m -Xmn64m
depends_on:
- rmqnamesrv
networks:
- rocketmq
ports:
- 10909:10909
- 10911:10911
command: sh mqbroker -c /opt/rocketmq-4.9.4/conf/broker.conf
# rocket console 这个可以不需要
rmqdashboard:
image: apacherocketmq/rocketmq-dashboard:1.0.0
restart: always
container_name: rocket-dashboard
environment:
- JAVA_OPTS=-Drocketmq.config.namesrvAddr=rmqnamesrv:9876 -Dserver.port=8180 -Drocketmq.config.isVIPChannel=false
# - JAVA_OPT_EXT=-Xms128m -Xmx128m -Xmn128m
depends_on:
- rmqnamesrv
networks:
- rocketmq
ports:
- 8180:8180
networks:
rocketmq:
driver: bridge
2) Create a directory config in the folder at the same level, and create a file broker.conf in it. The contents of the file are as follows:
brokerClusterName=DefaultCluster
brokerName=broker-a
brokerId=0
deleteWhen=04
fileReservedTime=48
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
## 注意:brokerIP1 要设置成自己服务器的ip
brokerIP1=192.168.56.110
Note: brokerIP1 should be set to the ip of its own server
2. Start
The related image will be downloaded automatically during the startup process
docker-compose -f docker-compose.yml up -d
3. stop
docker-compose -f docker-compose.yml down
4. Access
After the startup is successful, enter http://IP address: 8180 in the browser to access the rocketmq console
3. Server configuration
NameServer configuration
name | describe | Parameter Type | Defaults | effective value | importance |
---|---|---|---|---|---|
rocketmqHome | RocketMQ home directory, the default user home directory | String | |||
namesrvAddr | NameServerAddress | String | |||
kvConfigpath | The path of the kv configuration file, including the configuration information of the sequence message topic | String | |||
configStorePath | NameServer configuration file path, it is recommended to use -c to specify the NameServer configuration file path | String | |||
clusterTest | Whether to support cluster testing, the default is false | boolean | |||
orderMessageEnable | Whether to support sequential messages, the default is false | boolean | |||
Network Configuration Properties
name | describe | Parameter Type | Defaults | effective value | importance |
---|---|---|---|---|---|
accessMessageInMemorymaxRatio | Ratio of access messages in memory | int | 40(%) | ||
adminBrokerThreadPoolNums | The number of threads in the server processing console management command thread pool | int | 16 | ||
autoCreateSubscriptionGroup | Whether to automatically create consumer groups | boolean | true | true/false | |
autoCreateTopicEnable | Whether to automatically create topics | boolean | |||
bitMapLengthConsumeQueueExt | ConsumeQueue extension filter bitmap size | int | 112 | ||
brokerClusterName | Broker cluster name | String | TestCluster | ||
brokerFastFailureEnable | Whether to support broker fast failure If it is true, it means that the thread pool for sending messages will be cleared immediately, the message will pull the queued tasks in the thread pool, and return a system error directly | boolean | true | ||
brokerId | brokerID 0 means the master node is greater than 0 means the slave node | int | 0 | ||
brokerIP1 | Broker service address | String | |||
brokerIP2 | BrokerHAIP address, address for slave synchronization message | String | |||
brokerName | Broker server name morning server hostname | String | broker-a | ||
brokerPermission | Broker permissions default to 6, which means readable and writable | int | 6 | ||
brokerRole | Broker role, divided into ASYNC_MASTER SYNC_MASTER, SLAVE | enum | ASYNC_MASTER | ||
brokerTopicEnable | Whether the broker name can be used as the principal | boolean | |||
channelNotActiveInterval | long | ||||
checkCRCOnRecover | Whether to check the CRC when restoring files | boolean | |||
cleanFileForciblyEnable | Whether to support forced deletion of expired files | boolean | |||
cleanResourceInterval | Clear expired file thread scheduling frequency | int | |||
clientAsyncSemaphoreValue | How often the client invokes the invokeAsyncImpl method | int | |||
clientCallbackExecutorThreads | The number of client execution callback threads | int | |||
clientChannelMaxIdleTimeSeconds | The maximum waiting time for each channel of the client | int | |||
clientCloseSocketIfTimeout | Does the client need to wait to close the socket? | boolean | false | ||
clientManagerThreadPoolQueueCapacity | Client management thread pool task queue initial size | int | 1000000 | ||
clientManageThreadPoolNums | Server handles client management (number of heartbeat registration and deregistration threads) | int | 32 | ||
clientOnewaySemaphoreValue | The client controls the call to the invokeOnewayImpl method | int | |||
clientPooledByteBufAllocatorEnable | 客户端池化内存是否开启 | boolean | |||
clientSocketRcvBufSize | 客户端socket接收缓冲区大小 | long | |||
clientSocketSndBufSize | 客户端socket发送缓冲区大小 | long | |||
clientWorkerThreads | worker线程数 | int | |||
clusterTopicEnable | 集群名称是否可用在主题使用 | boolean | |||
commercialBaseCount | |||||
commercialBigCount | |||||
commercialEnable | |||||
commercialTimerCount | |||||
commitCommitLogLeastPages | 一次提交至少需要脏页的数量,默认4页,针对 commitlog文件 | int | |||
commitCommitLogThoroughInterval | Commitlog两次提交的最大间隔,如果超过该间隔,将忽略commitCommitLogLeastPages直接提交 | int | 200 | ||
commitIntervalCommitLog | commitlog提交频率 | int | 200 | ||
compressedRegister | 是否开启消息压缩 | boolean | |||
connectTimeoutMillis | 链接超时时间 | long | 3000 | ||
consumerFallbehindThreshold | 消息消费堆积阈值默认16GB在disableConsumeifConsumeIfConsumerReadSlowly为true时生效 | long | 17179869184 | ||
consumerManagerThreadPoolQueueCapacity | 消费管理线程池任务队列大小 | int | 1000000 | ||
consumerManageThreadPoolNums | 服务端处理消费管理 获取消费者列表 更新消费者进度查询消费进度等 | int | 32 | ||
debugLockEnable | 是否支持 PutMessage Lock锁打印信息 | boolean | false | ||
defaultQueryMaxNum | 查询消息默认返回条数,默认为32 | int | 32 | ||
defaultTopicQueueNums | 主体在一个broker上创建队列数量 | int | 8 | ||
deleteCommitLogFilesInterval | 删除commitlog文件的时间间隔,删除一个文件后等一下再删除一个文件 | int | 100 | ||
deleteConsumeQueueFilesInterval | 删除consumequeue文件时间间隔 | int | 100 | ||
deleteWhen | 磁盘文件空间充足情况下,默认每天什么时候执行删除过期文件,默认04表示凌晨4点 | string | 04 | ||
destroyMapedFileIntervalForcibly | 销毁MappedFile被拒绝的最大存活时间,默认120s。清除过期文件线程在初次销毁mappedfile时,如果该文件被其他线程引用,引用次数大于0.则设置MappedFile的可用状态为false,并设置第一次删除时间,下一次清理任务到达时,如果系统时间大于初次删除时间加上本参数,则将ref次数一次减1000,直到引用次数小于0,则释放物理资源 | int | 120000 | ||
disableConsumeIfConsumerReadSlowly | 如果消费组消息消费堆积是否禁用该消费组继续消费消息 | boolean | false | ||
diskFallRecorded | 是否统计磁盘的使用情况,默认为true | boolean | true | ||
diskMaxUsedSpaceRatio | commitlog目录所在分区的最大使用比例,如果commitlog目录所在的分区使用比例大于该值,则触发过期文件删除 | int | 75 | ||
duplicationEnable | 是否允许重复复制,默认为 false | boolean | false | ||
enableCalcFilterBitMap | 是否开启比特位映射 | boolean | false | ||
enableConsumeQueueExt | 是否启用ConsumeQueue扩展属性 | boolean | false | ||
enablePropertyFilter | 是否支持根据属性过滤 如果使用基于标准的sql92模式过滤消息则改参数必须设置为true | boolean | false | ||
endTransactionPoolQueueCapacity | 处理提交和回滚消息线程池线程队列大小 | int | |||
endTransactionThreadPoolNums | 处理提交和回滚消息线程池 | int | 24 | ||
expectConsumerNumUseFilter | 布隆过滤器参数 | int | 32 | ||
fastFailIfNoBufferInStorePool | 从 transientStorepool中获取 ByteBuffer是否支持快速失败 | boolean | false | ||
fetchNamesrvAddrByAddressServer | 是否支持从服务器获取nameServer | boolean | false | ||
fileReservedTime | 文件保留时间,默认72小时,表示非当前写文件最后一次更新时间加上filereservedtime小与当前时间,该文件将被清理 | String | 120 | ||
filterDataCleanTimeSpan | 清除过滤数据的时间间隔 | long | 86400000 | ||
filterServerNums | broker服务器过滤服务器数量 | int | 0 | ||
filterSupportRetry | 消息过滤是否支持重试 | boolean | false | ||
flushCommitLogLeastPages | 一次刷盘至少需要脏页的数量,针对commitlog文件 | int | 4 | ||
flushCommitLogTimed | 表示await方法等待FlushIntervalCommitlog,如果为true表示使用Thread.sleep方法等待 | boolean | false | ||
flushConsumeQueueLeastPages | 一次刷盘至少需要脏页的数量,默认2页,针对 Consume文件 | int | 2 | ||
flushConsumeQueueThoroughInterval | Consume两次刷盘的最大间隔,如果超过该间隔,将忽略 | int | 60000 | ||
flushConsumerOffsetHistoryInterval | fushConsumeQueueLeastPages直接刷盘 | int | 60000 | ||
flushConsumerOffsetInterval | 持久化消息消费进度 consumerOffse.json文件的频率ms | int | 5000 | ||
flushDelayOffsetInterval | 延迟队列拉取进度刷盘间隔。默认10s | long | 10000 | ||
flushDiskType | 刷盘方式,默认为 ASYNC_FLUSH(异步刷盘),可选值SYNC_FLUSH(同步刷盘) | enum | ASYNC_FLUSH | ||
flushIntervalCommitLog | commitlog刷盘频率 | int | 500 | ||
flushIntervalConsumeQueue | consumuQueue文件刷盘频率 | int | 1000 | ||
flushLeastPagesWhenWarmMapedFile | 用字节0填充整个文件的,每多少页刷盘一次。默认4096页,异步刷盘模式生效 | int | 4096 |
参考
- https://rocketmq.apache.org/zh/docs/4.x/