gpt4 book ai didi

apache-kafka - 多代理,多服务器群集中的Kafka生产者无法写入新创建的主题

转载 作者:行者123 更新时间:2023-12-04 15:51:27 26 4
gpt4 key购买 nike

我有一个带有2个代理的Kafka集群,每个代理都在各自的(AWS)服务器上(我使用intstructions here设置了集群)。我正在使用SASL(但未加密)。在运行代理2的服务器2上,我创建了一个主题:

KAFKA_OPTS="-Djava.security.auth.login.config=/home/kafka/kafka_2.11-1.0.0/config/jaas.conf -Djava.security.krb5.conf=/etc/krb5.conf" \
bin/kafka-topics.sh --create \
--zookeeper zookeeper-server-01.eigenroute.com:2181,zookeeper-server-02.eigenroute.com:2181,zookeeper-server-03.eigenroute.com:2181/apps/kafka-cluster-demo \
--replication-factor 2 --partitions 9 --topic another-test-topic

似乎成功了,因为描述主题表明它至少是创建的:
KAFKA_OPTS="-Djava.security.auth.login.config=/home/kafka/kafka_2.11-1.0.0/config/jaas.conf -Djava.security.krb5.conf=/etc/krb5.conf" \
bin/kafka-topics.sh --describe \
--zookeeper zookeeper-server-01.eigenroute.com:2181,zookeeper-server-02.eigenroute.com:2181,zookeeper-server-03.eigenroute.com:2181/apps/kafka-cluster-demo
Topic:another-test-topic PartitionCount:9 ReplicationFactor:2 Configs: MarkedForDeletion:true
Topic: another-test-topic Partition: 0 Leader: none Replicas: 2,1 Isr:
Topic: another-test-topic Partition: 1 Leader: none Replicas: 1,2 Isr:
Topic: another-test-topic Partition: 2 Leader: none Replicas: 2,1 Isr:
Topic: another-test-topic Partition: 3 Leader: none Replicas: 1,2 Isr:
Topic: another-test-topic Partition: 4 Leader: none Replicas: 2,1 Isr:
Topic: another-test-topic Partition: 5 Leader: none Replicas: 1,2 Isr:
Topic: another-test-topic Partition: 6 Leader: none Replicas: 2,1 Isr:
Topic: another-test-topic Partition: 7 Leader: none Replicas: 1,2 Isr:
Topic: another-test-topic Partition: 8 Leader: none Replicas: 2,1 Isr:

如您所见,此主题未分配任何领导者,也没有同步的副本。我已将写入权限分配给生产者:
KAFKA_HEAP_OPTS="-Djava.security.auth.login.config=/home/kafka/kafka_2.11-1.0.0/config/jaas.conf -Dsun.security.krb5.debug=true -Djava.security.krb5.conf=/etc/krb5.conf -Xmx256M -Xms128M" \
bin/kafka-acls.sh --authorizer-properties \
zookeeper.connect=zookeeper-server-01.eigenroute.com:2181,zookeeper-server-02.eigenroute.com:2181,zookeeper-server-03.eigenroute.com:2181/apps/kafka-cluster-demo \
--add --allow-principal User:producer1 --producer --topic another-test-topic
...
Current ACLs for resource `Topic:another-test-topic`:
User:producer1 has Allow permission for operations: Describe from hosts: *
User:producer1 has Allow permission for operations: Write from hosts: *

但是,我的生产者无法写这个话题:
KAFA_HEAP_OPTS="-Djava.security.krb5.conf=/etc/krb5.conf -Dsun.security.krb5.debug=true" \
bin/kafka-console-producer.sh \
--broker-list server-01.eigenroute.com:9092,server-02.eigenroute.com:9092 \
--topic another-test-topic --producer.config config/sasl-producer.properties
>this is a test message
[2018-01-07 21:16:02,650] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 1 : {another-test-topic=UNKNOWN_TOPIC_OR_PARTITION} (org.apache.kafka.clients.NetworkClient)

ZooKeeper节点上此主题的ACL是:
[zk: zookeeper-server-03.eigenroute.com:2181(CONNECTED) 8] getAcl /apps/kafka-cluster-demo/brokers/topics/another-test-topic
'world,'anyone
: r
'sasl,'kafka/server-02.eigenroute.com@EIGENROUTE.COM
: cdrwa

我觉得很奇怪... kafka/server-01.eigenroute.com@EIGENROUTE.COM(代理1的Kerberos主体)不应该具有与 kafka/server-02.eigenroute.com@EIGENROUTE.COM(代理2的Kerberos主体)相同的权限吗?

有人可以建议为什么制片人看不到被授权写的主题吗?

更新:以下是对@Vladimir Nabokov提供的答案中的问题的回答:
  • 我在任何一个代理的节点上都没有看到分区主题:

    kafka @ server-02:/var/log/kafka $ ls -alhtr
    总计124K
    -rw-r--r-- 1 kafka kafka 0 Jan 7 23:27 .lock
    -rw-r--r-- 1 kafka kafka 0 Jan 7 23:27 cleaner-offset-checkpoint
    -rw-r--r-- 1 kafka kafka 54 Jan 7 23:27 meta.properties
    drwxr-xr-x 7 root root 4.0K 1月9日06:25 ..
    drwxr-xr-x 2 kafka kafka 4.0K 1月18日05:30 __consumer_offsets-29
    ...
    drwxr-xr-x 2 kafka kafka 4.0K 1月18日05:30 __consumer_offsets-1
    -rw-r--r-- 1 kafka kafka 600 Jan 18 05:56复制偏移量检查点
    -rw-r--r-- 1 kafka kafka 600 Jan 18 05:56恢复点-偏移量-检查点
    -rw-r--r-- 1 kafka kafka 4 Jan 18 05:56 log-start-offset-checkpoint
    drwxr-xr-x 27 kafka kafka 4.0K 1月18日05:56。


  • kafka@server-01:/var/log/kafka$ ls -alhtr
    total 124K
    -rw-r--r-- 1 kafka kafka 0 Jan 7 23:26 .lock
    -rw-r--r-- 1 kafka kafka 0 Jan 7 23:26 cleaner-offset-checkpoint
    -rw-r--r-- 1 kafka kafka 54 Jan 7 23:26 meta.properties
    drwxr-xr-x 7 root root 4.0K Jan 17 06:25 ..
    drwxr-xr-x 2 kafka kafka 4.0K Jan 18 05:30 __consumer_offsets-0
    ...
    drwxr-xr-x 2 kafka kafka 4.0K Jan 18 05:30 __consumer_offsets-32
    -rw-r--r-- 1 kafka kafka 600 Jan 18 05:58 recovery-point-offset-checkpoint
    -rw-r--r-- 1 kafka kafka 4 Jan 18 05:58 log-start-offset-checkpoint
    -rw-r--r-- 1 kafka kafka 600 Jan 18 05:59 replication-offset-checkpoint
    drwxr-xr-x 27 kafka kafka 4.0K Jan 18 05:59 .
  • 用户kafka是运行kafka服务器的用户,是两个代理上/var/log/kafka/目录的所有者:

    kafka @ server-02:~/kafka_2.11-1.0.0/confkafka@server-01:/var/log $ ll/var/log |格雷普·卡夫卡
    drwxr-xr-x 27卡夫卡kafka 4096 Jan 18 05:49 kafka
    ig $ ll/var/log | grep kafka
  • 对于这两个代理而言,telnet似乎都在工作:

    sjamal-> telnet服务器-01.eigenroute.com 9092
    正在尝试54.175.56.39 ...
    已连接到server-01.eigenroute.com。
    转义字符为'^]'。
    ^ CConnection被外部主机关闭。
    [〜/projects/microservices/kafka-tutorial/kafka_2.11-1.0.0]
    sjamal-> telnet服务器-02.eigenroute.com 9092
    正在尝试18.221.32.34 ...
    已连接到server-02.eigenroute.com。
    转义字符为'^]'。
    ^ CConnection被外部主机关闭。
  • 不需要-他们可以互相看到:

    kafka @ server-02:〜/kafka_2.11-1.0.0/config $主机server-01.eigenroute.com
    server-01.eigenroute.com的地址为54.175.56.39
    kafka @ server-01:/var/log $主机server-02.eigenroute.com
    server-02.eigenroute.com的地址为18.221.32.34
  • 我试过了。使用者没有收到任何消息:

    [2018-01-18 00:45:31,931]警告[Consumer clientId = consumer-1,groupId = console-consumer-95024]提取关联ID为7022的元数据时出错:{another-test-topic = UNKNOWN_TOPIC_OR_PARTITION}(组织apache.kafka.clients.NetworkClient)
    [2018-01-18 00:45:32,063]警告[Consumer clientId = consumer-1,groupId = console-consumer-95024]提取关联ID为7024的元数据时出错:{another-test-topic = UNKNOWN_TOPIC_OR_PARTITION}(组织apache.kafka.clients.NetworkClient)
    [2018-01-18 00:45:32,194]警告[Consumer clientId = consumer-1,groupId = console-consumer-95024]提取关联ID为7025的元数据时出错:{another-test-topic = UNKNOWN_TOPIC_OR_PARTITION}(组织apache.kafka.clients.NetworkClient)
    [2018-01-18 00:45:32,327]警告[Consumer clientId = consumer-1,groupId = console-consumer-95024]提取关联ID为7026的元数据时出错:{another-test-topic = UNKNOWN_TOPIC_OR_PARTITION}(组织apache.kafka.clients.NetworkClient)

  • drwxr-xr-x 27卡夫卡kafka 4096 Jan 18 05:44卡夫卡

    很抱歉,格式错误-我粘贴了代码并点击了“代码”按钮,但它不是以代码格式进行格式化,我不知道为什么。

    更新#2:针对弗拉基米尔·纳博科夫(Vladimir Nabokov)在其回答中的评论,我正在粘贴正在使用的生产者和使用者配置和命令:
    // sasl-producer.properties
    bootstrap.servers=server-01.eigenroute.com:9092
    compression.type=none
    security.protocol=SASL_PLAINTEXT
    sasl.mechanism=GSSAPI
    sasl.kerberos.service.name=kafka
    sasl.jaas.config=com.sun.security.auth.module.Krb5LoginModule required \
    useKeyTab=true \
    storeKey=true \
    keyTab="/path/to/producer1.whatever.keytab" \
    principal="producer1/whatever@EIGENROUTE.COM";

    // sasl-consumer.properties
    bootstrap.servers=server-01.eigenroute.com:9092
    security.protocol=SASL_PLAINTEXT
    sasl.mechanism=GSSAPI
    sasl.kerberos.service.name=kafka
    sasl.jaas.config=com.sun.security.auth.module.Krb5LoginModule required \
    useKeyTab=true \
    storeKey=true \
    keyTab="/path/to/consumer1.whatever.keytab" \
    principal="consumer1/whatever@EIGENROUTE.COM";

    # producer command
    KAFA_HEAP_OPTS="-Djava.security.krb5.conf=/etc/krb5.conf -Dsun.security.krb5.debug=true" bin/kafka-console-producer.sh --broker-list server-01.eigenroute.com:9092,server-02.eigenroute.com:9092 --topic another-test-topic --producer.config config/sasl-producer.properties

    # consumer command
    KAFA_HEAP_OPTS="-Djava.security.krb5.conf=/etc/krb5.conf -Dsun.security.krb5.debug=true" bin/kafka-console-consumer.sh --bootstrap-server server-01.eigenroute.com:9092,server-02.eigenroute.com:9092 --topic another-test-topic --consumer.config config/sasl-consumer.properties --from-beginning

    最佳答案

    这个错误:

    WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 1 : {another-test-topic=UNKNOWN_TOPIC_OR_PARTITION} (org.apache.kafka.clients.NetworkClient)



    这并不表示您没有写该主题。

    这仅表示该主题是"new"主题。

    1)检查一下,可能是数据已经写在数据目录中了,可以看到cd data_dir/topic/partition在外观上,寻找增长的文件。 (在所有分区的两台服务器上查看)

    2)检查,可能是data_dir没有权限为您的kafka用户写入?

    3)从生产机器“telnet kafka_host kafka_port”检查,可能是生产者未在网络中看到您的kafka服务器

    4)在生产者代理和kafka代理上,输入/etc/hosts并将IP映射到所有3台计算机的主机名。他们不仅需要彼此知道IP,还需要知道主机名到IP的映射(DNS服务是替代方法)

    5)
    与消费者建立联系,并尝试消费您的主题。

    关于apache-kafka - 多代理,多服务器群集中的Kafka生产者无法写入新创建的主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48143483/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com