kafka acl权限控制

1.对应的broken添加acl权限
vim serve.properties
末尾添加:
allow.everyone.if.no.acl.found=true
authorizer.class.name = kafka.security.auth.SimpleAclAuthorizer
super.users=User:root
2.开启(关闭)kafkabroker
kafka-server-start.sh -daemon config/server.properties
kafka-server-stop.sh
3.创建topic
kafka-topics.sh --create --zookeeper 78.79.12.9:2181 --replication-factor 1 --partitions 1 --topic com
kafka-topics.sh --create --zookeeper 78.79.12.9:2181 --replication-factor 1 --partitions 1 --topic cn
4.添加acl权限控制。给对应的主机/IP赋予某个topic的读写权限
在kafka1上执行
给78.79.12.9赋予对com写的权限:
kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --operation Write --allow-principal User:* --allow-host 78.79.12.9 --add --topic com
就可以在9节点上对com拥有写的权限,也就是说可以在9节点上创建生产者
查看权限:kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --list --topic com
给78.79.12.8赋予对com读的权限:
(在任意目录下执行即可)
kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --operation Read --allow-principal User:* --allow-host 78.79.12.9 --add --topic com
就可以在9节点上对com拥有读的权限,也就是说可以在9节点上创建消费者
给78.79.12.9赋予对com同时读写的权限:
kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --operation Write --operation Read --allow-principal User:* --allow-host 78.79.12.9 --add --topic com
就可以在9节点上对com拥有读与写的权限,也就是说可以在9节点上创建生产者和消费者
5.删除acl权限控制
删除和添加是一样的,—add换成—remove选项,要删除第一个例子中添加的,可以使用下面的命令:
kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --operation Write --allow-principal User:* --allow-host 78.79.12.9 --remove --topic com

6.具体acl权限参考acl列表:
具体参考文档网址:
http://blog.csdn.net/linux12a/article/details/77375274
http://blog.csdn.net/qq_25667523/article/details/51784966
http://orchome.com/185
来源: https://note.youdao.com/share/iframe.html
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
KafkaACL(Access Control List)用于控制Kafka集群中的客户端对topic、group、cluster等资源的访问权限。使用ACL可以保证集群的安全性。 以下是使用Kafka ACL的步骤: 1. 配置Kafka的server.properties文件,启用ACL: ``` authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer ``` 2. 创建ACL配置文件,指定具体的权限: ``` # 只允许test-topic的生产者写入数据 Topic:test-topic,Producer:Alice,Write # 只允许test-topic的消费者Bob消费数据 Topic:test-topic,Consumer:Bob,Read # 允许test-topic的所有用户读写 Topic:test-topic,User:*,Allow,Write,Read # 禁止所有Topic的所有用户读写 Topic:*,User:*,Deny,Write,Read ``` 3. 通过kafka-acls.sh命令行工具设置ACL: ``` # 给Alice授权在test-topic中写入数据 bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:alice --operation Write --topic test-topic # 给Bob授权在test-topic中读取数据 bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:bob --operation Read --topic test-topic # 给所有用户授权在test-topic中读写数据 bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:* --operation Write --operation Read --topic test-topic # 禁止所有用户在所有Topic中读写数据 bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --add --deny-principal User:* --operation Write --operation Read --topic * ``` 4. 验证ACL是否生效: ``` # 查看test-topic的ACL bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --list --topic test-topic # 查看Alice的授权信息 bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --list --principal User:alice # 查看Bob在test-topic中的权限 bin/kafka-acls.sh --authorizer-properties zookeeper.connect=localhost:2181 --list --topic test-topic --principal User:bob ``` 以上就是使用Kafka ACL的基本步骤。注意,ACL配置和设置需要谨慎操作,避免出现安全漏洞。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值