关于默认端口
broker的默认端口有3个,10911, 10912, 10909。
10911是remotingServer使用的监听端口,remotingServer主要处理以下三类消息:
- producer发送的消息
- conumser在消费失败或者消费超时发送的消息
- consumer拉取消息
10912是主broker用于监听从broker请求的监听端口。
10909是fastRemotingServer使用的监听端口,与remotingServer相似,但是不包含处理拉取消息的请求。在vipChannelEnabled开启时,producer,consumer发送消息才发送到fastRemotingServer
1. 单机部署
1.1 下载与安装
所需环境: Jdk、Maven
RocketMQ需要maven来编译,所以该环境必须先安装好maven。
(1)下载资源
进入rocketMq的官网,进行资源下载。下载地址为:RocketMq.apache.org
版本说明:
- Binary和Source和两个的区别在于一个是编译好的(Binary),另一个是没有编译好的(Source)
- Binary版本已经编译好,是可以直接使用的 RocketMQ 软件包
(2)安装
将软件解压到本地目录,路径自选。
(3)配置环境变量
- 变量名:ROCKETMQ_HOME
- 变量值:D:\rocketMq\rocketmq-all-5.0.0-bin-release
(4)修改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 #当前节点为master,即单主
flushDiskType = ASYNC_FLUSH
autoCreateTopicEnable = true
brokerIP1=172.29.176.1
namesrvAddr=172.29.176.1:9876
defaultTopicQueueNums=4
autoCreateSubscriptionGroup=true
listenPort=10911
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=88
storePathRootDir=D:/rocketMq/rocketmq-all-5.0.0-bin-release/store
storePathCommitLog=D:/rocketMq/rocketmq-all-5.0.0-bin-release/store/commitlog
storePathConsumeQueue=D:/rocketMq/rocketmq-all-5.0.0-bin-release/store/consumequeue
storePathIndex=D:/rocketMq/rocketmq-all-5.0.0-bin-release/store/index
storeCheckpoint=D:/rocketMq/rocketmq-all-5.0.0-bin-release/store/checkpoint
abortFile=D:/rocketMq/rocketmq-all-5.0.0-bin-release/store/abort
maxMessageSize=65536
创建相应的目录:
cd D:/rocketMq/rocketmq-all-5.0.0-bin-release
mkdir store
mkdir logs
cd store
mkdir commitlog
(5)修改RocketMQ的name server 运行端口
在 conf/ 目录下创建 namesrv.properties 文件,并填写以下内容
listenPort=9876
(6)启动 nameserver
进入rocketmq的bin目录执行:
start D:\rocketMq\rocketmq-all-5.0.0-bin-release\bin\mqnamesrv.cmd
启动成功后,弹出的窗口不要关闭
(7)启动 broker
进入rocketmq的bin目录执行
start D:\rocketMq\rocketmq-all-5.0.0-bin-release\bin\mqbroker.cmd -n 127.0.0.1:9876 -c D:\rocketMq\ro