kafka常用指令(一)

一.  常用指令\

1.      啓動kafka服務

bin/kafka-server-start.sh config/server.properties &

2.      關閉kafka服務

bin/kafka-server-stop.sh

3.      查看主題topics

[root@dn1 bin]#./kafka-topics.sh --list -zookeeper dn1

ATLAS_ENTITIES

ATLAS_HOOK

__consumer_offsets

ambari_kafka_service_check

4.      添加主題topic

[root@dn1 bin]# ./kafka-topics.sh --create --zookeeperdn1:2181,dn2:2181 --replication-factor 1 --partitions 1 --topic test

Created topic "test"

5.      查看topic描述

[root@dn1 bin]# ./kafka-topics.sh--describe --zookeeper localhost:2181 --topic test

Topic:test      PartitionCount:1        ReplicationFactor:1     Configs:

    Topic: test     Partition: 0    Leader: 1001    Replicas: 1001  Isr: 1001

6.      生產者發佈消息

[root@dn1 bin]# ./kafka-console-producer.sh --broker-listdn1:6667,dn2:6667 --topic test

OSendMessage 1

Send Message 2

7.      消費者讀取消息

[root@dn1bin]# ./kafka-console-consumer.sh --zookeeper dn1:2181,dn2:2181 --topic test--from-beginning

Using theConsoleConsumer with old consumer is deprecated and will be removed in a futuremajor release. Consider using the new consumer by passing [bootstrap-server]instead of [zookeeper].

{metadata.broker.list=dn1.hadoop:6667,request.timeout.ms=30000, client.id=console-consumer-9264,security.protocol=PLAINTEXT}

SendMessage 1

Send Message 2


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章