【KAFKA】使用星环大数据平台客户端操作kafka的topic

网友投稿 359 2022-11-18

【KAFKA】使用星环大数据平台客户端操作kafka的topic

前置条件

从星环大数据平台下载kafka的配置文件。如下载的配置为kafka1,把该kafka1放入到/etc目录下并给kafka1目录进行如下赋权:

chmod 755 -R /etc/kafka1

配置环境变量

在对应用户的环境变量中添加如下内容:

export KAFKA_OPTS="-Djava.security.auth.login.config=/etc/kafka1/conf/jaas.conf -Djava.security.krb5.conf=/etc/kafka1/conf/krb5.conf -Dsun.security.krb5.debug=true"export KAFKA_HEAP_OPTS="-Djava.security.auth.login.config=/etc/kafka1/conf/jaas.conf -Djava.security.krb5.conf=/etc/kafka1/conf/krb5.conf -Dsun.security.krb5.debug=true"

在consumer.properties、producer.properties添加如下内容

进入TDH-Client/kafka/config目录下找到consumer.properties、producer.properties,然后在两个文件中添加如下内内容:

security.protocol=SASL_PLAINTEXTsasl.mechanism=GSSAPIsasl.kerberos.service.name=kafka

使用TDH-Client操作kafka的Topic

以下所有命令都是在进入到TDH-Client/kafka/bin目录执行的。

创建topic

./kafka-topics.sh --create --zookeeper localhost:2181 --topic testwel --replication-factor 1 --partitions 1

#查看test主题详细信息./kafka-topics.sh --zookeeper localhost:2181 -describe -topic testwel

向主题写入数据

#交互式写入./kafka-console-producer.sh --broker-list localhost:9092 --topic testwel --producer.config ../config/producer.properties

hello.txt的内容如下:

1,2,3,41,2,3,41,2,3,41,2,3,41,2,3,4

#把文件数据写入kafka./kafka-console-producer.sh --broker-list localhost:9092 --topic testwel --producer.config ../config/producer.properties < hello.txt

从主题读书据

./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic testwel --consumer.config ../config/consumer.properties --from-beginning

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:如何实现ABB机器人和视觉系统间的TCP/IP通讯呢?
下一篇:Spring&nbsp;Boot打开URL出现signin问题的解决
相关文章

 发表评论

暂时没有评论,来抢沙发吧~