RocketMQ of Broker

A, Broker Introduction

Broker 是 RocketMQ 的核心,大部分 "重量级" 工作都是由 Broker 完成的,如:
    * 接收 Producer 发送的消息
    * 处理 Consumer的消费消息请求
    * 消息的持久化存储
    * 消息的 HA 机制
    * 服务器过滤功能
    ......

Second, the message storage structure

RocketMQ message storing ConsumeQueue and CommitLog with the completion.

2.1 ConsumeQueue

* ConsumeQueue 是消息的逻辑队列,类似数据库的索引文件,存储着指向物理存储的地址。每个 Topic 下的每个 MessageQueue 都有一个对应的 ConsumeQueue 文件。 

* 文件所在路径: ${$storeRoot}\consumequeue\${topicName}\${queueId}\${fileName}。

2.2 CommitLog

* CommitLog 是物理存储文件,每个 Broker 上的 CommitLog 被本机器所有的 ConsumeQueue 共享。
    
* 文件所在路径:${user.homt}\store\${commitlog}\${fileName}。    

2.3 storage order

RocketMQ 通过一些机制来保证,尽量向 CommitLog 中顺序写入,但是可以随机读取。

Third, high availability mechanism

Broker cluster by Master and Slave fit high availability, by Broker setting parameters in the configuration file brokerId to distinguish between the Master or Slave :

* brokerId 等于 0 表示这个 Broker 是 Master;
* brokerId 大于 0 表示这个 Broker 是 Slave;

Master supports read and write operations, Slave only supports read operations.

Fourth, synchronized asynchronous brush disc brush plate

4.1 What is the brush plate?

* RocketMQ 消息存储方式为内存+磁盘存储;
* 刷盘是指将内存的数据写入到磁盘中的操作;
* 刷盘分为同步刷盘和异步刷盘    

4.2 Asynchronous brush plate

当执行消息写入操作时,当消息写入到内存中时,就返回写成功状态。当内存中的消息量积累到一定量时,统一触发写磁盘动作。

4.3 synchronous brush plate

当执行消息写入操作时,同步写入内存和磁盘中后才返回写成功状态。

4.4 brush disc arranged

通过 Broker配置文件中的 fulshDiskType 参数配置:
    * SYNC_FLUSH:同步刷盘
    * ASYNC_FLUSH:异步刷盘    

We recommend the use of asynchronous brush plate form.

Fifth, synchronous and asynchronous replication

5.1 What is copy?

Broker 集群有 Master 和 Slave 两种角色,消息需要从 Master 复制到 Slave 上; 

5.2 Asynchronous Replication

当执行消息写入操作时,只要 Master写成功即可反馈给客户端成功状态

5.3 Replication

当执行消息写入操作时, Master和 Slave 均写成功才反馈给客户端成功状态

5.4 replication configuration

通过 Broker配置文件中的 brokerRole 参数配置:
    * ASYNC_MASTER:异步复制
    * SYNC_MASTER:同步复制
    * SLAVE

Recommended SYNC_MASTER form.

Guess you like

Origin www.cnblogs.com/markLogZhu/p/12586133.html