Short Description:

Step by Step Recipe for Securing Kafka with Kerberos.

Article

I found it is a little tricky to get started with a Kerberos enabled Kafka cluster. I created this step by step recipe for securing Kafka with Kerberos, sending and receiving data on console. This is tested on HDP2.5.0 and Ambari 2.4.1.

  • Enabled Kerberos using the Ambari Kerberos setup wizard under Admin -- Kerberos menu.
  • On Ambari Kafka Config UI, change "listeners" property to "PLAINTEXTSASL://localhost:6667".
  • Restart Kafka as requested by Ambari.
  • Create a test topic in Kafka. Must use the kafka service user to do this.

  

$ cd /usr/hdp/current/kafka-broker/bin
$ sudo su kafka
$ kinit -k -t /etc/security/keytabs/kafka.service.keytab kafka/ip----.ap-northeast-.compute.internal $ ./kafka-topics.sh --zookeeper ip----.ap-northeast-.compute.internal: --create --topic foo --partitions --replication-factor Created topic "bar".
  • Grant permission to user. This can be done using Kafka native ACL mechanism or Apache Ranger. In the example, we use Kafka ACL. User bob needs to be existing in KDC.

    # Grant user bob as producer on topic foo
    ./kafka-acls.sh --authorizer-properties zookeeper.connect=ip----.ap-northeast-.compute.internal: \
    --add --allow-principal User:bob \
    --producer --topic foo Adding ACLs for resource `Topic:foo`:
    User:bob has Allow permission for operations: Describe from hosts: *
    User:bob has Allow permission for operations: Write from hosts: * Adding ACLs for resource `Cluster:kafka-cluster`:
    User:bob has Allow permission for operations: Create from hosts: * Current ACLs for resource `Topic:foo`:
    User:bob has Allow permission for operations: Describe from hosts: *
    User:bob has Allow permission for operations: Write from hosts: * # Grant user bob as consumer
    ./kafka-acls.sh --authorizer-properties zookeeper.connect=ip----.ap-northeast-.compute.internal: \
    --add --allow-principal User:bob \
    --consumer --topic foo --group * #--group后等跟等号,如--group=*。按照上面写法,只是赋给名称为connect-distributed.sh的groupid。因为kafka/bin下面第一个脚本是connect-distributed.sh
    
    Adding ACLs for resource `Topic:foo`:
    User:bob has Allow permission for operations: Read from hosts: *
    User:bob has Allow permission for operations: Describe from hosts: * Adding ACLs for resource `Group:connect-distributed.sh`:
    User:bob has Allow permission for operations: Read from hosts: * Current ACLs for resource `Topic:foo`:
    User:bob has Allow permission for operations: Read from hosts: *
    User:bob has Allow permission for operations: Describe from hosts: *
    User:bob has Allow permission for operations: Write from hosts: * Current ACLs for resource `Group:connect-distributed.sh`:
    User:bob has Allow permission for operations: Read from hosts: *
  • Confirm the above works using the kafka console producer and consumer scripts.

    # Switch to bob user and log in to KDC.
    $ kinit bob # Start console producer
    $ ./kafka-console-producer.sh --broker-list ip----.ap-northeast-.compute.internal: --topic foo --security-protocol PLAINTEXTSASL # On another terminal, start console consumer
    ./kafka-console-consumer.sh --zookeeper ip----.ap-northeast-.compute.internal: --topic foo --security-protocol PLAINTEXTSASL {metadata.broker.list=ip----.ap-northeast-.compute.internal:, request.timeout.ms=, client.id=console-consumer-, security.protocol=PLAINTEXTSASL} # Type something on the producer terminal, it should appears on the console terminal immediately.

Step by Step Recipe for Securing Kafka with Kerberos的更多相关文章

  1. Problem of Creating Topics in Kafka with Kerberos

    Hi, After enabled Kerberos using Ambari, I got problem creating topics in Kafka using the kafka-topi ...

  2. Step by step Dynamics CRM 2011升级到Dynamics CRM 2013

    原创地址:http://www.cnblogs.com/jfzhu/p/4018153.html 转载请注明出处 (一)检查Customizations 从2011升级到2013有一些legacy f ...

  3. Step by Step 创建一个新的Dynamics CRM Organization

    原创地址:http://www.cnblogs.com/jfzhu/p/4012833.html 转载请注明出处 前面演示过如何安装Dynamics CRM 2013,参见<Step by st ...

  4. Step by step Install a Local Report Server and Remote Report Server Database

    原创地址:http://www.cnblogs.com/jfzhu/p/4012097.html 转载请注明出处 前面的文章<Step by step SQL Server 2012的安装 &g ...

  5. Step by step Dynamics CRM 2013安装

    原创地址:http://www.cnblogs.com/jfzhu/p/4008391.html 转载请注明出处   SQL Server可以与CRM装在同一台计算机上,也可安装在不同的计算机上.演示 ...

  6. Step by step 活动目录中添加一个子域

    原创地址:http://www.cnblogs.com/jfzhu/p/4006545.html 转载请注明出处 前面介绍过如何创建一个域,下面再介绍一下如何在该父域中添加一个子域. 活动目录中的森林 ...

  7. SQL Server 维护计划实现数据库备份(Step by Step)(转)

    SQL Server 维护计划实现数据库备份(Step by Step) 一.前言 SQL Server 备份和还原全攻略,里面包括了通过SSMS操作还原各种备份文件的图形指导,SQL Server  ...

  8. 转:eclipse以及step into step over step return的区别

    首先来讲一下step into step over step return的区别: step into就是单步执行,遇到子函数就进入并且继续单步执行:(F5) step over是在单步执行时,在函数 ...

  9. [转]Bootstrap 3.0.0 with ASP.NET Web Forms – Step by Step – Without NuGet Package

    本文转自:http://www.mytecbits.com/microsoft/dot-net/bootstrap-3-0-0-with-asp-net-web-forms In my earlier ...

随机推荐

  1. 【译】MongoDb vs Mysql—以NodeJs为例

    亲爱的读者,您可能想知道为什么要写关于MongoDb和MySql这篇文章.那是因为我与NodeJs开发人员讨论在应用程序中使用哪种数据存储作为主要的数据存储方式. 我看过很多评论都在争论这个问题. 有 ...

  2. python3 进一步了解装饰器 NLP第四条

    还是先来抄一段NLP第四条: 四,只有感官经验塑造出来的世界,没有绝对的真实世界   每个人运用自己的感觉器官把资料摄入(摄入过程),由于感官运用是主观地有选择性的,因此不能,亦不需要把所有资料捕获. ...

  3. python从学渣到学沫的半月天

    今天又要引进一个新的知识点了,就是模块,可以直接引用的一个东西,从实用性来说很强大,不过还是需要记住模块的类型啊,如何应用还是需要学习和了解的.其中模块是分三种的,一种内置模块python内部提供的功 ...

  4. pandas 获取数据帧DataFrame的行、列数

    1.创建数据帧 import pandas as pd df = pd.DataFrame([[1, 'A', '3%' ], [2, 'B']], index=['row_0', 'row_1'], ...

  5. jenkins 自动化部署实战

    jenkins 作为一个自动化的集成工具,已经是必不可少的了.它里面提供各种插件,以及完备的基础流程设施,为大家的自动化集成之路提供了很多的方便.所以,我们有必要完整的实践一回.以切身体会到它的好处! ...

  6. Linux下Springboot解决`APR based Apache Tomcat Native library`提示

    最近转行做java,开发基于Springboot的项目,版本号为2.1.0.RELEASE. 启动应用,发现以下提示: The APR based Apache Tomcat Native libra ...

  7. GC参考手册 —— GC 算法(实现篇)

    学习了GC算法的相关概念之后, 我们将介绍在JVM中这些算法的具体实现.首先要记住的是, 大多数JVM都需要使用两种不同的GC算法 —— 一种用来清理年轻代, 另一种用来清理老年代. 我们可以选择JV ...

  8. SQL慢查询测试实践

    1.开启慢查询的目的 开启慢查询日志,可以让MySQL记录下查询超过指定时间的语句,通过定位分析性能的瓶颈,才能更好的优化数据库系统的性能. 2.设置mysql慢查询 方法一:全局变量设置(临时生效) ...

  9. 《HelloGitHub》第 28 期

    <HelloGitHub>第 28 期 兴趣是最好的老师,HelloGitHub 就是帮你找到兴趣! 简介 分享 GitHub 上有趣.入门级的开源项目. 这是一个面向编程新手.热爱编程. ...

  10. java~使用自己的maven本地仓库

    本地仓库 主要是一种缓存,当你使用远程仓库中下载组件后,它下一次会优先从本地进行加载,一般位于USER_HOME/.m2目录下,我们自己也可以建立公用的包,把包发布到本地仓库,自己在其它项目里直接可以 ...