一、初步了解和使用kafka
首先的kafka的位置
cd /usr/hdp/current/kafka-broker
在目录下执行以下操作
(1)查看topic
[root@sandbox-hdp kafka-broker]# bin/kafka-topics.sh --zookeeper sandbox-hdp.hortonworks.com:2181 --list
ATLAS_ENTITIES
ATLAS_HOOK
__consumer_offsets
(2)创建topic
bin/kafka-topics.sh --zookeeper sandbox-hdp.hortonworks.com:2181 --create --topic orders --partitions 3 --replication-factor 1
(3)设置topic消息保存时间
bin/kafka-topics.sh --zookeeper sandbox-hdp.hortonworks.com:2181 --alter --topic orders --config retention.ms=100000
另外就是储存位置
如图所示:
在自己创建的kafka-logs下存放,根据分区生成对应数量的orders-n(此处为3 个)
(4)删除topic
kafka-topics.sh --zookeeper sandbox-hdp.hortonworks.com:2181 --delete --topic orders
此时使用删除命令后,再次查看发现并没有删除,是因为kafka配置中加了锁,不允许删除
想要删除,就修改如下位置为true,然后保存 restart后就可以删除topic了