接上文配置kerberos之后继续配置acl。
server.properties添加如下内容
#acl
allow.everyone.if.no.acl.found=false
super.users=User:kafka
authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer
重启kafka集群。
授权catcher92用户既有生产者、又有消费者权限
/opt/kafka/bin/kafka-acls.sh --authorizer-properties zookeeper.connect=hadoop03:2181/kafka --add --allow-principal User:catcher92 --producer --consumer --topic=test7 --group=*
授权p10用户有消费者权限
/opt/kafka/bin/kafka-acls.sh --authorizer-properties zookeeper.connect=hadoop03:2181/kafka --add --allow-principal User:p10 --consumer --topic=test7 --group=*
其中是User是catcher92而不是kerberos中的用户catcher92/user是因为kafka中默认的sasl.kerberos.principal.to.local.rules配置会将{username}/{hostname}@{REALM}映射为{username}。