简体   繁体   English

Kafka ACL:在一个命令中将用户添加到多个主题

[英]Kafka ACLs: Add user to multiple topics in one command

I have a Kafka server running in ACLs.我有一个在 ACL 中运行的 Kafka 服务器。 I can add User:Bob to topic test我可以将 User:Bob 添加到主题测试

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

but I want to add User:bob to topic1, topic2 and topic3.但我想将 User:bob 添加到 topic1、topic2 和 topic3。

Is there a way to add a user to multiple topics ACLs in one command?有没有办法在一个命令中将用户添加到多个主题 ACL? it is just to reduce the setup time (performance).这只是为了减少设置时间(性能)。

Thank you谢谢

You can write a small script: 您可以编写一个小脚本:

kafka-custom-acls.sh

#!/usr/bin/bash

for i in $@;
do
    bin/kafka-acls.sh --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:Bob --operation Read --topic $i
done

Invoke the script as follows 如下调用脚本

./kafka-custom-acls.sh topic1 topic2 topic3

you can give 2 --topic arguments such as:你可以给 2 --topic arguments 例如:

bin/kafka-acls.sh --add --allow-principal User:Bob --operation Read --topic test --topic test2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM