您的位置:首页 > 运维架构

Kafka命令详解(一)---topic相关

2017-06-05 11:22 148 查看
1、create 

创建一个topic

bin/kafka-topics.sh --zookeeper ip:port --create --topic backtest --partitions 3  --replication-factor 2

2、list

List all available topics.

bin/kafka-topics.sh --zookeeper ip:port --list

3、delete

Delete a topic

4、delete-config

5 topic configuration override to be removed for an existing topic (see the list of configurations under the --config option).

4、describe

List details for the given topics.

bin/kafka-topics.sh --zookeeper ip:port --describe --topic backtest

6、partitions <Integer: # of partitions>

The number of partitions for the topic being created or altered 

(WARNING:If partitions are increased for a topic that has a key, the partition logic or ordering of the messages will be affected

partitions指定topic分区数:

分区数,控制topic将分片成多少个log。可以显示指定,如果不指定则会使用broker(server.properties)中的num.partitions配置的数量

分区数也限制了consumer的并行度,即限制了并行consumer消息的线程数不能大于分区数

分区数或者或是单台服务器上的分区数过多,会增加不可用及延迟的风险。因为多的分区数,意味着需要打开更多的文件句柄、增加点到点的延时、增加客户端的内存消耗。

7、replication-factor <Integer:replication factor>            

The replication factor for each partition in the topic being created.

replication-factor指定topic每个分区的副本数

replication factor 控制消息保存在几个broker(服务器)上,一般情况下等于broker的个数。

如果没有在创建时显示指定或通过API向一个不存在的topic生产消息时会使用broker(server.properties)中的default.replication.factor配置的数量

8、topic <String: topic>                  

The topic to be create, alter or describe. Can also accept a regular expression except for --create option

9、zookeeper <String: urls>               

REQUIRED: The connection string for the zookeeper connection in the form host:port. Multiple URLS can be given to allow fail-over.       

10、alter

Alter the number of partitions,replica assignment, and/or configuration for the topic.

11、config

A topic configuration override for the topic being created or altered.The following is a list of valid         

configurations:                      

cleanup.policy                        

compression.type                      

delete.retention.ms                   

file.delete.delay.ms                  

flush.messages                        

flush.ms                              

follower.replication.throttled.       

replicas                             

index.interval.bytes                  

leader.replication.throttled.replicas 

max.message.bytes                     

message.format.version                

message.timestamp.difference.max.ms   

message.timestamp.type                

min.cleanable.dirty.ratio             

min.compaction.lag.ms                 

min.insync.replicas                   

preallocate                           

retention.bytes                       

retention.ms                          

segment.bytes                         

segment.index.bytes                   

segment.jitter.ms                     

segment.ms                            

unclean.leader.election.enable        

See the Kafka documentation for full details on the topic configs.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  topic kafka