下载源码
https://github.com/apache/rocketmq.git,选择版本5.1.0
。
配置环境变量和创建配置文件
ROCKETMQ_HOME=D:\tools\mq\rocketmq_dev
- 在
ROCKETMQ_HOME
的目录中创建conf和store目录 - 在conf目录下面创建
broker.conf
,内容如下
# 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.
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
# 这是nameserver的启动地址,broker会基于该nameserver进行通信
namesrvAddr=127.0.0.1:9876
# 这是存储路径,你设置为你的rocketmq运行目录的store子目录
storePathRootDir=D:/tools/mq/rocketmq_dev/store
# 这是commitLog的存储路径
storePathCommitLog=D:/tools/mq/rocketmq_dev/store/commitlog
# consume queue文件的存储路径
storePathConsumeQueue=D:/tools/mq/rocketmq_dev/store/consumequeue
# 消息索引文件的存储路径
storePathIndex=D:/tools/mq/rocketmq_dev/store/index
# checkpoint文件的存储路径
storeCheckpoint=D:/tools/mq/rocketmq_dev/store/checkpoint
# abort文件的存储路径
abortFile=D:/tools/mq/rocketmq_dev/store/abort
启动NameServer
执行NamesrvStartup
的main方法。日志打印
The Name Server boot success. serializeType=JSON, address 0.0.0.0:9876
启动Broker
在Program arguments中配置-c "D:\tools\mq\rocketmq_dev\conf\broker.conf"
,日志打印
The broker[broker-a, 10.132.17.10:10911] boot success. serializeType=JSON and name server is 127.0.0.1:9876