• lmtoo
    2019-08-17
    No JAAS configuration section named 'Client' was found in specified JAAS configuration file: '/usr/local/kafka/config/kafka-broker.jaas'. Will continue connection to Zookeeper server without SASL authentication, if Zookeeper server allows it.
     1
     2
  • 明翼
    2019-08-17
    老师说的这SCRAM认证用户名和密码直接保存在zookeeper上的,如果zookeeper不做安全控制,岂不是失去意义了?目前我们没有做认证的,研究过一段时间的ssl认证,很麻烦,还影响性能

    作者回复: 不是明文保存的。当然做ZooKeeper的认证也是很有必要的

    
     2
  • 其实我很屌
    2019-08-19
    老师你好,我们生产上kafka总是发生leader切换,频率大概和zk fsync的告警日志一致,请问有经验吗?zk隔一段时间会有个fsync慢的告警日志,然后差不多同一个时间点,收到partition leader切换的告警

    作者回复: 查看一下磁盘的性能,以及可以查一下文件系统的vm.dirty_ratio,看看是不是flush频率过高导致的

    
     1
  • 杰洛特
    2019-12-31
    老师,请问再java代码里怎么使用认证?比如 producer,是配置好了 conf 文件,然后传入参数吗?
    Properties props = new Properties();
    props.put("producer.config", "<your_path>/producer.conf");
    Producer<String, String> producer = new KafkaProducer<>(props)
    类似这样可以吗?

    作者回复: 可以使用这样的方式: consumerProperties.put("sasl.jaas.config", "org.apache.kafka.common.security.scram.ScramLoginModule required username=\"reader2\" password=\"reader-pwd\";");

    
    
  • 星亦辰
    2019-12-20
    有没有 哪个大佬 使用 SCRAM-SHA-512 的Python 消费客户端实践?
    这边实现了好几个版本,总是失败。
    
    
  • HuAng
    2019-12-08
    做了认证后,使用 bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 3 --partitions 3 --topic test 创建主题失败
    提示错误:
    [2019-12-08 12:20:39,172] INFO [SocketServer brokerId=0] Failed authentication with /127.0.0.1 (Unexpected Kafka request of type METADATA during SASL handshake.) (org.apache.kafka.common.network.Selector)
    [2019-12-08 12:20:39,587] INFO [SocketServer brokerId=0] Failed authentication with /127.0.0.1 (Unexpected Kafka request of type METADATA during SASL handshake.) (org.apache.kafka.common.network.Selector)
    [2019-12-08 12:20:39,998] INFO [SocketServer brokerId=0] Failed authentication with /127.0.0.1 (Unexpected Kafka request of type METADATA during SASL handshake.) (org.apache.kafka.common.network.Selector)

    展开

    作者回复: 什么版本的Kafka呢?另外是否设置了security.protocol=sasl_plaintext

     1
    
  • pain
    2019-11-26
    这个应该用的不多吧
    
    
  • James
    2019-11-19
    还没做过,后续应该会做
    
    
  • 昀溪
    2019-10-24
    顺序是Broker是停止的,然后修改配置文件,创建用户,之后启动Broker。

    我是单台环境 2.2.0
    Broker server.properties 除了下面的其他都是默认配置

    listeners=SASL_PLAINTEXT://172.16.247.100:9092
    sasl.enabled.mechanisms=SCRAM-SHA-256
    sasl.mechanism.inter.broker.protocol=SCRAM-SHA-256
    security.inter.broker.protocol=SASL_PLAINTEXT

    # 这里我使用的是sasl.jaas.config配置形式,而不是kafka_server_jaas.conf形式
    # 官网中http://kafka.apache.org/documentation/#security_jaas_broker支持这种配置方式
    listener.name.sasl_plaintext.scram-sha-256.sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required \
       username="admin" \
       password="admin-secret";

    创建admin账号
    ./kafka-configs.sh --zookeeper localhost:2181 --alter --add-config \
    'SCRAM-SHA-256=[password=admin-secret],SCRAM-SHA-512=[password=admin-secret]' \
    --entity-type users --entity-name admin

    创建完我再ZK中的 config\users节点可以看到这个用户.

    启动后的server.log,日志里kafka成功注册到zk节点
    [2019-10-24 10:25:52,210] INFO Registered broker 0 at path /brokers/ids/0 with addresses: ArrayBuffer(EndPoint(172.16.247.100,9092,ListenerName(SASL_PLAINTEXT),SASL_PLAINTEXT)), czxid (broker epoch): 148 (kafka.zk.KafkaZkClient)

    [2019-10-24 10:25:52,462] INFO [KafkaServer id=0] started (kafka.server.KafkaServer)
    [2019-10-24 10:25:52,582] INFO [SocketServer brokerId=0] Failed authentication with /172.16.247.100 (Authentication failed during authentication due to invalid credentials with SASL mechanism SCRAM-SHA-256) (org.apache.kafka.common.network.Selector)
    [2019-10-24 10:25:52,583] INFO [Controller id=0, targetBrokerId=0] Failed authentication with srv01.contoso.com/172.16.247.100 (Authentication failed during authentication due to invalid credentials with SASL mechanism SCRAM-SHA-256) (org.apache.kafka.common.network.Selector)
    [2019-10-24 10:25:52,584] ERROR [Controller id=0, targetBrokerId=0] Connection to node 0 (srv01.contoso.com/172.16.247.100:9092) failed authentication due to: Authentication failed during authentication due to invalid credentials with SASL mechanism SCRAM-SHA-256 (org.apache.kafka.clients.NetworkClient)
    展开

    作者回复: 我觉得你可以试一下jaas文件的方式,看看整个流程能否走通。如果可以,说明还是参数指定jaas设置的问题。总之先窄化可能的问题点

     2
    
  • 昀溪
    2019-10-23
    老师我按上面的方式配置,Kafka起来了,但是日志全是错误
    [2019-10-23 14:46:39,465] ERROR [Controller id=0, targetBrokerId=0] Connection to node 0 (srv01.contoso.com/172.16.247.100:9092) failed authentication due to: Authentication failed during authentication due to invalid credentials with SASL mechanism SCRAM-SHA-256 (org.apache.kafka.clients.NetworkClient)
    [2019-10-23 14:46:39,578] INFO [SocketServer brokerId=0] Failed authentication with /172.16.247.100 (Authentication failed during authentication due to invalid credentials with SASL mechanism SCRAM-SHA-256) (org.apache.kafka.common.network.Selector)
    [2019-10-23 14:46:39,578] INFO [Controller id=0, targetBrokerId=0] Failed authentication with srv01.contoso.com/172.16.247.100 (Authentication failed during authentication due to invalid credentials with SASL mechanism SCRAM-SHA-256) (org.apache.kafka.common.network.Selector)
    展开

    作者回复: 能把配置的命令发下吗?

     1
    
  • 昀溪
    2019-10-23
    老师,您讲的上面的例子中,reader和writer用户只是做了认证,没有做授权,它们默认的权限是什么呢?如果不授权就能收发消息么?

    作者回复: 默认没有任何权限。不授权不能收发消息

    
    
  • godtrue
    2019-09-23
    打卡,中间学习有断档,感觉模式了,学习还是得持续+专注。
    
    
  • 知易
    2019-08-28
    老师求助,,win10环境
    执行命令:
    .\bin\windows\kafka-configs.bat --zookeeper localhost:2181 --alter --add-config 'SCRAM-SHA-256=[iterations=8192,password=admin],SCRAM-SHA-512=[password=admin]' --ent
    ity-type users --entity-name admin
    报错如下:
    requirement failed: Unknown Dynamic Configuration: Set('SCRAM-SHA-256).
    网上搜了很久,没有找到解决方案,,请老师解惑。感谢
    展开

    作者回复: 似乎是个已知问题,最好不要在Windows平台上跑Kafka,问题超多而且还无法解决

     1
    
  • 🤡
    2019-08-23
    老胡,看到你的博客园了,什么时候把你的博客地址全分享出来,让大家学习下呗
    
    
  • Nic-愛
    2019-08-19
    老师,对于多个消费者,每个消费者分配的消息数量一样,每个消费者消费完的数据最快和最慢的大概有3s的差距,出现这个消费快慢差距会有哪些原因呢

    作者回复: 如果你确定是3s的差距,看看是不是这个consumer参数导致的:group.initial.rebalance.delay.ms。当前这个参数值默认是3秒。

    
    
  • Geek_edc612
    2019-08-19
    (1)之前做kafak/ Sasl-Plain认证,几经转折才发现,这个认证用户跟linux用户名没关系,而且不能动态添加减少用户,最重要的是租户可以自己修改acl权限,目前也只是把客户端的kafka-topics.sh给禁用了,一叶障目吧,=。=;
    (2)还有就是sasl-plain这个acl权限感觉肯定,明明给认证用户a赋予了所有topic的在所有host的读写权限,但重启时发现有部分topic突然无法消费写入了,提示没权限,再重启就好了;
    (3)接(2)情况,还有就是用kafka-acls.sh去查看topic的所有acl权限时,有的acl完全为空,但是用户a还能写入消费数据,这块完全不懂
    (4)目前kafa-acls.sh 只是用的基础的 Write和Read权限,像Cluster这个权限不知道干啥用的,其他的了解也不深入
    (5)最后就是做kafka sasl plain 认证的时候给zk也加了认证,具体如下:
    zkserver.sh加入这个
    "-Djava.security.auth.login.config=/opt/beh/core/zookeeper/conf/kafka_zoo_jaas.conf" \
    zoo.cfg加入这个:
    authProvider.1=org.apache.zookeeper.server.auth.SASLAuthenticationProvider
    requireClientAuthScheme=sasl
    jaasLoginRenew=3600000
    但是有点疑惑的就是不知道zk 这个认证是用在那块的?我发现加不加kafka sasl plain都能正常用
    展开
    
    
  • 玉剑冰锋
    2019-08-19
    胡老师,kafka平滑升级后面会讲吗?

    作者回复: 可能涉及不是很多。有什么问题只管问吧

    
    
我们在线,来聊聊吧