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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值