Hi,

After enabled Kerberos using Ambari, I got problem creating topics in Kafka using the kafka-topics.sh script. The topic was created, but its status is wrong without leader. It seems the topic is created with PLAINTEXT, while there is only PLAINTEXTSASL broker in the cluster after enabled Kerberos. The only configuration change I made is to chagne broker listener from 'PLAINTEXT://localhost:6667' to 'PLAINTEXTSASL://localhost:6667'. As posted in this question, I also changed the kafka-topics.sh to make it work with Kerberos. I am using HDP2.5.3.

  1. $ ./kafka-topics.sh --zookeeper ip-10-0-0-149.ap-northeast-1.compute.internal --create --partitions 1 --replication-factor 1 --topic mytopic
  2. Created topic "mytopic".
  3. $ ./kafka-topics.sh --zookeeper ip-10-0-0-149.ap-northeast-1.compute.internal --describe --topic mytopic
  4. Topic:mytopic PartitionCount:1 ReplicationFactor:1 Configs:
  5. Topic: mytopic Partition: 0 Leader: none Replicas: 1001 Isr:
 
 
 0
最佳解答

个解答,截止mthiele  · 2017年01月23日 02:24

When you use a script, command, or API to create a topic, an entry is created under ZooKeeper. The only user with access to ZooKeeper is the service account running Kafka (by default, kafka). Therefore, the first step toward creating a Kafka topic on a secure cluster is to run kinit, specifying the Kafka service keytab. The second step is to create the topic.

  1. Run kinit, specifying the Kafka service keytab. For example:

    kinit -k -t /etc/security/keytabs/kafka.service.keytab kafka/c6401.ambari.apache.org@EXAMPLE.COM

  2. Next, create the topic. Run the kafka-topics.sh command-line tool with the following options:

    /bin/kafka-topics.sh --zookeeper <hostname>:<port> --create --topic <topic-name> --partitions <number-of-partitions> --replication-factor <number-of-replicating-servers>

    For example:

    1. /bin/kafka-topics.sh --zookeeper c6401.ambari.apache.org:2181 --create --topic test_topic --partitions 2 --replication-factor 2
    2. Created topic "test_topic".
 
 
 0  Show 2 · 分享
 

个解答,截止yjiang  · 2017年01月26日 10:23

@dbains@mthiele@Daniel Kozlowski,

Thank you. It works when created as kafka user.

To summarize all the steps -- from Ambari configs, to creating topic, granting permission and testing on kafka console producer/consumer scripts, I created this article Step by Step Recipe for Securing Kafka with Kerberos. Hope it saves others' time :-)

 
 
 1 · 分享
 

个解答,截止amankumbare  · 2017年03月07日 16:59

@yjiang

If you try to create a topic as a non kafka user, it creates a topic but with no Leader and ISR. This is a known issue. According to me, the reason behind this could be the zookeeper acl's. Once topic is created in zookeeper, its acl's will not allow kafka to read details about it.

If you want to create a topic as a non kafka user you need to workaround by following below steps :

If you are not using Ranger :

1. Make sure "auto.create.topic.enable = true"

2. Give acl's for the user from which you want to create a topic, for ex :

# bin/kafka-acls.sh --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:Bob --producer --topic Test-topic

3. Do a kinit as a user from which you want to create topic.

4. Now try to produce messages to topic as that user :

# ./kafka-console-producer.sh --broker-list <hostname-broker>:6667 --topic Test-topic --security-protocol PLAINTEXTSASL

If you are using Ranger :

Instead of point 2 in above steps you will need to add a policy for the topic in ranger. Allow permissions for that user to produce, create, consumer. Restart kafka service. Then follow step 3 and 4 as mentioned above.

Hope this helps !!

 
 
 0 · 分享
 

个解答,截止dbains  · 2017年01月23日 18:21

@yjiang Yes, please try creating the topic as kafka user because when we use kafka-topics.sh to create a test topic, what this script does is to create a node in zookeeper path - /broker/topics/test

then brokers thread gets notified that a new node is created and broker then creates actual data for topic test that is the metadata and physical data. But notice that Brokers are kafka/host@REALM, so if a user other than kafka creates a topic it gets permission for example world:anyone:r sasl:xyz:crdwa

So the new node that is created in zookeeper path will have these permissions. Now when the broker gets alerted and tries to create metadata and physical data for this new topic, it wont be able to because broker principal is kafka but topic's is xyz

 
 
 0  Show 1 · 分享
 

个解答,截止Daniel Kozlowski  · 2017年01月23日 08:47

@yjiang

To answer your question -

---------------

When you use a script, command, or API to create a topic, an entry is created under ZooKeeper. The only user with access to ZooKeeper is the service account running Kafka (by default, kafka). Therefore, the first step toward creating a Kafka topic on a secure cluster is to runkinit, specifying the Kafka service keytab. The second step is to create the topic.

----------------

See more in here: http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.4.3/bk_secure-kafka-ambari/content/ch_secure-kafka-create-topics.html

I hope this helps.

最新文章

  1. 关于asp.net 开发的小技巧—让传值对象化
  2. c语言中三个点的解释 : variadic
  3. JavaScript Patterns 4.3 Returning Functions
  4. Rest服务
  5. Cocos手游录制插件:cocos-plugin
  6. Java之阶乘数的计算
  7. 遍历 集合 Dictionary 的时候修改集合 方法
  8. Aptana Studio 快捷键
  9. poj3537--Crosses and Crosses
  10. HDU 2393 Higher Math
  11. Windows Azure使用VS 2010的云应用开发过程
  12. input type=&#39;file&#39; 上传文件 判断图片的大小是否合格与witdh 和 height 是否合格
  13. 【java】-- java并发包总结
  14. Web项目发布的一些设置
  15. 664. Strange Printer
  16. Java 多线程(七) 线程间的通信——wait及notify方法
  17. MVC 之 初识(一)
  18. 洛谷 P1123 取数游戏
  19. 如何让 Xcode 在读写上提速100倍?
  20. centos重启redis后,数据丢失

热门文章

  1. css垂直居中方法总结
  2. 经典排序算法 — C# 版(上)
  3. 我所不知道的Makefile语法
  4. Python基础(数字,字符串方法)
  5. .Net Webapi SignalR与微信小程序的交互
  6. 是时候给大家介绍 Spring Boot/Cloud 背后豪华的研发团队了。
  7. 如何用cmake编译
  8. k8s集群监控(十一)--技术流ken
  9. vue-resource实现数据的绑定、添加、删除
  10. DSAPI 3张图片实现花开动画