简体   繁体   中英

Kafka ACLs: Add user to multiple topics in one command

I have a Kafka server running in ACLs. I can add User:Bob to topic test

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.

Is there a way to add a user to multiple topics ACLs in one command? 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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