2017-03-28 76 views
2

方面卡夫卡 - 动物园管理员 - ACL配置

我试图建立基于分布式日志系统卡夫卡(我知道有东西像现有... logstash),但我希望能够之后将一些风暴拓扑放到例如当流量变慢时发送通知。

设置

我有端口8082,其承载我的日志功能正在运行的服务器(wilfly群,keycloack认证)。我可以通过REST将loglines推送到此服务器。在幕后,一位卡夫卡制片人正在运行并传播讯息给卡夫卡。

  • 我有饲养员在端口2181
  • 我有一个经纪人在端口运行9092
  • 我有在的LogServer端口上运行8082

我server.properties(对于券商):

listeners=PLAINTEXT://localhost:9092 
authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer 
super.users=User:Bob;User:Alice;User:anonymous 

我的ACL配置:

call kafka\bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic testtopic 
call kafka\bin\windows\kafka-acls.bat --add --allow-principal User:anonymous --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect=localhost:2181 --allow-host http://localhost:8082 --operation Read --operation Write --topic testtopic 
call kafka\bin\windows\kafka-acls.bat --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:anonymous --consumer --topic testtopic --group group --allow-host http://localhost:8082 
call kafka\bin\windows\kafka-acls.bat --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:anonymous --producer --topic testtopic --allow-host http://localhost:8082 
call kafka\bin\windows\kafka-acls.bat --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:anonymous --producer --topic testtopic --allow-host 192.168.3.63 

我(JAVA)生产性能:

@Produces 
    private Producer<String, String> stringStringProducer(){ 
     Properties props = new Properties(); 
     props.put("bootstrap.servers", "localhost:9092"); 
     props.put("acks", "all"); 
     props.put("retries", 0); 
     props.put("batch.size", 16384); 
     props.put("linger.ms", 1); 
     props.put("buffer.memory", 33554432); 
     props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer"); 
     props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer"); 
     Producer<String, String> producer = null; 
     try { 
      producer = new KafkaProducer<>(props); 
      return producer; 
     } catch (Exception e) { 
      throw new RuntimeException(e); 
     } 
    } 

问题

当我尝试生产通过Java制作的消息(和控制台制片人),我得到:

[org.apache.kafka.clients.NetworkClient] (kafka-producer-network-thread | producer-6) Error while fetching metadata with correlation id 10 : {testtopic=UNKNOWN_TOPIC_OR_PARTITION} 

有谁知道我做错了什么?

首先解决

我设法授予127.0.0.1访问渡过这个错误消息:

call kafka\bin\windows\kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic testtopic 

call kafka\bin\windows\kafka-acls.bat --add --allow-principal User:anonymous --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect=localhost:2181 --allow-host http://localhost:8082 --operation Read --operation Write --topic testtopic 
call kafka\bin\windows\kafka-acls.bat --add --allow-principal User:ANONYMOUS --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect=localhost:2181 --allow-host 127.0.0.1 --operation Read --operation Write --topic testtopic 

call kafka\bin\windows\kafka-acls.bat --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:anonymous --consumer --topic testtopic --group group --allow-host http://localhost:8082 
call kafka\bin\windows\kafka-acls.bat --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:ANONYMOUS --consumer --topic testtopic --group group --allow-host 127.0.0.1 

call kafka\bin\windows\kafka-acls.bat --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:anonymous --producer --topic testtopic --allow-host http://localhost:8082 
call kafka\bin\windows\kafka-acls.bat --authorizer kafka.security.auth.SimpleAclAuthorizer --authorizer-properties zookeeper.connect=localhost:2181 --add --allow-principal User:ANONYMOUS --producer --topic testtopic --allow-host 127.0.0.1 

我发现这个问题通过查看日志文件(即去的log4j。属性在kafka文件夹中,并将log4j.logger.kafka.authorizer.logger属性更改为DEBUG。然后您将得到具体错误(即缺少权限)。

新问题

当我要生产的消息,我现在得到:

[2017-03-28 15:39:07,704] WARN Error while fetching metadata with correlation id 0 : {testtopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient) 
[2017-03-28 15:39:07,800] WARN Error while fetching metadata with correlation id 1 : {testtopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient) 
[2017-03-28 15:39:07,912] WARN Error while fetching metadata with correlation id 2 : {testtopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient) 
[2017-03-28 15:39:08,024] WARN Error while fetching metadata with correlation id 3 : {testtopic=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient) 

任何人知道如何解决这一问题?

解决

我添加了“无名氏”的经纪人配置(服务器中的超级用户。属性):

authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer 
super.users=User:Bob;User:Alice;User:ANONYMOUS 
#port = 9092 
#advertised.host.name = localhost 
#listeners=SASL_SSL://localhost:9092 
#security.inter.broker.protocol=SASL_SSL 
#sasl.mechanism.inter.broker.protocol=PLAIN 
#sasl.enabled.mechanisms=PLAIN 
host.name=127.0.0.1 
advertised.host.name=localhost 
advertised.port=9092 

回答

0

解决方案是在(更新)问题描述

2

,因为你已经在下面一行启用授权将出现问题可供选择:

authorizer.class.name=kafka.security.auth.SimpleAclAuthorizer 

但是,代理与运行User:ANONYMOUS,因为以下行:

listeners=PLAINTEXT://localhost:9092 

这就是,经纪人无法验证自己。在我的情况下(SSL认证),我必须执行以下操作:

  1. 使用security.inter.broker.protocol=SSL启用代理间安全性。经纪人(或多个)通过设置listeners=SSL://broker1:9092
  2. 禁用PLAINTEXT端口(注意,没有PLAINTEXT://broker1:9091
  3. 定义ACL在我的SSL证书定义使用kafka-acls.sh用户。
  4. 重新启动代理。

P. S.解答您的答案是不鼓励的。你可以阅读它的影响here

相关问题