- num.partitions 和 default.replication.factor
num.partitions 当创建topic时,该topic的分区数
default.replication.factor 每个分区的副本数
- 分区在broker节点中如何存放
config/server.properties 中 log.dirs目录中存放分区数据和日志。
再来详细看看每个文件的作用,比如test-topic主题,只有一个分区,对应test-topic-0文件夹
test-topic-0]# tree
.
├── 00000000000000000000.index
├── 00000000000000000000.log
├── 00000000000000000000.timeindex
|—— 00000000000000000111.index
├── 00000000000000000111.log
├── 00000000000000000111.timeindex
└── leader-epoch-checkpoint
0 directories, 4 files
每个topic有多个分区,每个分区有多个或1个副本,每个副本对应log,每个log由多个logsegment构成。logsegment结构如上所示。
log以追加的方式写入,可能有多个logsegment,最后一个logsegment被称为active segment。当active segment大小达到一定条件,会重新生成新的segment作为新的active segment。