kafka常见操作(kafka_2.10-0.8.2.2)

kafka常见操作(版本:kafka_2.10-0.8.2.2)

服务操作

1. 启动kafka服务
./bin/kafka-server-start.sh -daemon config/server.properties

Topic操作

1. 创建Topic
batman:~/kafka_2.10-0.8.2.2$ ./bin/kafka-topics.sh --create --topic test-topic --partitions 2 --replication-factor 3 --zookeeper 192.168.103.46:2181
  • 说明:
2. 删除Topic
ubuntu@batman:~/kafka_2.10-0.8.2.2$ ./bin/kafka-topics.sh --delete --topic test-topic  --zookeeper 192.168.103.46:2181
Topic test-topic is marked for deletion.
Note: This will have no impact if delete.topic.enable is not set to true.

ubuntu@batman:~/kafka_2.10-0.8.2.2$ ./bin/kafka-topics.sh --list --zookeeper 192.168.103.46:2181
shiquan-topic
shiquan-topic3
test-topic - marked for deletion
  • 说明:看来没有真正的删除,如需delete后立即删除,要改配置的。
3. 显示当前所有Topic
ubuntu@batman:~/kafka_2.10-0.8.2.2$ ./bin/kafka-topics.sh --list --zookeeper 192.168.103.46:2181
test-topic
user-behavior-topic
wordcount
4. 显示指定Topic详细信息
ubuntu@batman:~/kafka_2.10-0.8.2.2$ ./bin/kafka-topics.sh --describe --topic test-topic --zookeeper 192.168.103.46:2181
Topic:test-topic    PartitionCount:2    ReplicationFactor:3 Configs:
    Topic: test-topic   Partition: 0    Leader: 2   Replicas: 2,0,1 Isr: 2,0,1
    Topic: test-topic   Partition: 1    Leader: 0   Replicas: 0,1,2 Isr: 0,1,2
5. 通过consumer客户端查看Topic内容
wonderwoman:~/kafka_2.10-0.8.2.2$ ./bin/kafka-console-consumer.sh --topic storm-topic --zookeeper 192.168.103.44:2181 --from-beginning
  • 说明:
--from-beginning                        If the consumer does not already have  
                                          an established offset to consume     
                                          from, start with the earliest        
                                          message present in the log rather    
                                          than the latest message.   
  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值