一、rocketmq集群模式介绍
RocketMQ支持多种集群策略
2m-2s-async(本文采用模式)-2主2从异步刷盘(吞吐量较大,但是消息可能丢失)
2m-2s-sync:2主2从同步刷盘(吞吐量会下降,但是消息更安全)
2m-noslave :2主无从(单点故障),然后还可以直接配置broker.conf,进行单点环境配置
dledger:用来实现主从切换的。集群中的节点会基于Raft协议随机选举出一个leader,
其他的就都是follower。通常正式环境都会采用这种方式来搭建集群。
二、配置文件说明
2.1 namesrv配置文件
内容:
2.2 broker配置文件
内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| brokerClusterName=rocketmq-cluster
brokerName=broker-a
brokerId=0
namesrvAddr=node1:9876
defaultTopicQueueNums=4
autoCreateTopicEnable=true
autoCreateSubscriptionGroup=true
listenPort=10911
deleteWhen=04
fileReservedTime=120
mapedFileSizeCommitLog=1073741824
mapedFileSizeConsumeQueue=300000
diskMaxUsedSpaceRatio=88
storePathRootDir=/app/rocketmq/store
storePathCommitLog=/app/rocketmq/store/commitlog
storePathConsumeQueue=/app/rocketmq/store/consumequeue
storePathIndex=/app/rocketmq/store/index
storeCheckpoint=/app/rocketmq/store/checkpoint
abortFile=/app/rocketmq/store/abort
maxMessageSize=65536
brokerRole=ASYNC_MASTER
flushDiskType=ASYNC_FLUSH
aclEnable=true
|
1
| vi broker-a-s.properties
|
修改brokerId和brokerRole
1 2
| brokerId=1 brokerRole=SLAVE
|
三、环境准备
节点 |
nameServer节点 |
broker节点 |
node1 |
nameserver |
|
node2 |
nameserver |
broker-a,broker-b-s |
node3 |
nameserver |
broker-a,broker-b-s |
四、启动服务
启动nameserver服务:
1
| nohup sh bin/mqnamesrv -c conf/namesrv.properties &
|
启动broker服务
1
| nohup sh bin/mqbroker -n localhost:8876 -c conf/broker.conf &
|