我想通过java应用程序授予对kafka主题的访问权限,就像我们通过kafka-acls.sh一样。我只想通过java api运行命令。
String[] cmdPArm = {"--authorizer-properties","zookeeper.connect=vmw201:2181/
kafka","--add","--allow-principal","User:Alice","--operation","Write","--topic
","test"};AclCommand.main(cmdPArm);
但是在操作之后,会出现错误,没有授权授权。我的集群已将keberos部署为身份验证系统。如何将超级用户的身份引入代码?
执行ACL命令时出错:
org.apache.zookeeper.KeeperException $ NoAuthException:KeeperErrorCode = NoAuth for / kafka-acl / Topic / test org.I0Itec.zkclient.exception.ZkException: org.apache.zookeeper.KeeperException $ NoAuthException:KeeperErrorCode = NoAuth for / kafka-acl / Topic / test at org.I0Itec.zkclient.exception.ZkException.create(ZkException.java:68) 在 org.I0Itec.zkclient.ZkClient.retryUntilConnected(ZkClient.java:995) 在 org.I0Itec.zkclient.ZkClient.writeDataReturnStat(ZkClient.java:1138) 在org.I0Itec.zkclient.ZkClient.writeData(ZkClient.java:1133)at org.I0Itec.zkclient.ZkClient.writeData(ZkClient.java:1101)at at kafka.utils.ZkUtils.updatePersistentPath(ZkUtils.scala:411)at at kafka.security.auth.SimpleAclAuthorizer.addAcls(SimpleAclAuthorizer.scala:173) 在 kafka.admin.AclCommand $$ anonfun $ addAcl $ 1 $$ anonfun $ $申请3.apply(AclCommand.scala:89) 在 kafka.admin.AclCommand $$ anonfun $ addAcl $ 1 $$ anonfun $ $申请3.apply(AclCommand.scala:86) 在 scala.collection.TraversableLike $ WithFilter $$ anonfun $ $的foreach 1.适用(TraversableLike.scala:772) 在scala.collection.immutable.Map $ Map1.foreach(Map.scala:109)at scala.collection.TraversableLike $ WithFilter.foreach(TraversableLike.scala:771) 在 kafka.admin.AclCommand $$ anonfun $ addAcl $ 1.适用(AclCommand.scala:86) 在 kafka.admin.AclCommand $$ anonfun $ addAcl $ 1.适用(AclCommand.scala:80) 在kafka.admin.AclCommand $ .withAuthorizer(AclCommand.scala:74)at at kafka.admin.AclCommand $ .addAcl(AclCommand.scala:80)at kafka.admin.AclCommand $ .main(AclCommand.scala:48)at kafka.admin.AclCommand.main(AclCommand.scala)at kafka.acl.KafkaAcl.main(KafkaAcl.java:15)引起: org.apache.zookeeper.KeeperException $ NoAuthException:KeeperErrorCode = NoAuth for / kafka-acl / Topic / test at org.apache.zookeeper.KeeperException.create(KeeperException.java:113) 在 org.apache.zookeeper.KeeperException.create(KeeperException.java:51) 在org.apache.zookeeper.ZooKeeper.setData(ZooKeeper.java:1270)at org.I0Itec.zkclient.ZkConnection.writeDataReturnStat(ZkConnection.java:133) 在org.I0Itec.zkclient.ZkClient $ 13.call(ZkClient.java:1142)at org.I0Itec.zkclient.ZkClient.retryUntilConnected(ZkClient.java:985) ......还有17个