风暴/Kafka-无法获取Kafka的偏移滞后

dgsult0t  于 2021-06-07  发布在  Kafka
关注(0)|答案(0)|浏览(168)

我正在运行一个storm拓扑,它在aws ubuntu服务器14.04 lts示例上从kafka获得tweets消息,该示例有4个节点-nimbus、一个supervisor、一个kafka zookeeper节点、一个zookeeper(用于storm群集)。我的storm ui已经启动并运行,我可以提交拓扑。我有两个代理,但我只使用代理。id=0一个。我在一个主题下发了推特。我的Kafka服务器也运行良好。
我以这种方式创建了Kafka主题:
bin/kafka-topics.sh--创建--缩放器localhost:2181/kafka --复制因子1--分区1--主题twitter1
我困惑的是:

SpoutConfig kafkaConfig = new SpoutConfig(kafkaHosts, topicName+"-0", "/kafka", topicName+"-0");

我想我的错误是从这一点上冒出来的。完整代码为:

import org.apache.storm.tuple.Fields;
import org.apache.storm.kafka.BrokerHosts;
import org.apache.storm.kafka.KafkaSpout;
import org.apache.storm.kafka.SpoutConfig;
import org.apache.storm.kafka.ZkHosts;
import java.util.Arrays;
import org.apache.storm.Config;
import org.apache.storm.StormSubmitter;
import org.apache.storm.spout.SchemeAsMultiScheme;
import org.apache.storm.topology.TopologyBuilder;
import org.apache.storm.kafka.StringScheme;

public class TwitterTopology{
    public static void main(String[] args) {
        String topicName = "twitter1";
        String topologyName = args[0];
        String kafkaIp = "xxx.31.xxx.207"; //hiding the IPs here. This is the IP for my kafka-zk node. Is this ok?
        String nimbusHost = "xxx.31.xxx.70";
        String kafkaHost = kafkaIp + ":9092";
        BrokerHosts kafkaHosts = new ZkHosts(kafkaHost);
        SpoutConfig kafkaConfig = new SpoutConfig(kafkaHosts, topicName, "/kafka", topicName);
        kafkaConfig.scheme = new SchemeAsMultiScheme(new StringScheme());
        KafkaSpout kafkaSpout = new KafkaSpout(kafkaConfig);
        TopologyBuilder builder = new TopologyBuilder();
        builder.setSpout("twitter-spout", kafkaSpout, 8);
        builder.setBolt("WordSplitterBolt", new JsonWordSplitterBolt(5)).shuffleGrouping("twitter-spout");
        builder.setBolt("IgnoreWordsBolt", new IgnoreWordsBolt()).shuffleGrouping("WordSplitterBolt");
        builder.setBolt("WordCounterBolt", new WordCounterBolt(5, 5 * 60, 50)).shuffleGrouping("IgnoreWordsBolt");
        Config config = new Config();
        config.setDebug(false);
        config.setMaxTaskParallelism(5);
        config.put(Config.NIMBUS_HOST, nimbusHost);
        config.put(Config.NIMBUS_THRIFT_PORT, 6627);
        config.put(Config.STORM_ZOOKEEPER_PORT, 2181);
        config.put(Config.STORM_ZOOKEEPER_SERVERS, Arrays.asList(kafkaIp));
        try {
                config.setNumWorkers(20);
                config.setMaxSpoutPending(5000);
                StormSubmitter.submitTopology(topologyName, config, builder.createTopology()); 
            } catch (Exception e) {
                    throw new IllegalStateException("Couldn't initialize the topology", e);
            }
    }
}

我在storm ui中遇到以下异常:

Unable to get offset lags for kafka. Reason: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /brokers/topics/twitter1/partitions at org.apache.zookeeper.KeeperException.create(KeeperException.java:99) at org.apache.zookeeper.KeeperException.create(KeeperException.java:51) at org.apache.zookeeper.ZooKeeper.getChildren(ZooKeeper.java:1590) at org.apache.curator.shaded.framework.imps.GetChildrenBuilderImpl$3.call(GetChildrenBuilderImpl.java:242) at org.apache.curator.shaded.framework.imps.GetChildrenBuilderImpl$3.call(GetChildrenBuilderImpl.java:231) at org.apache.curator.shaded.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64) at org.apache.curator.shaded.RetryLoop.callWithRetry(RetryLoop.java:100) at org.apache.curator.shaded.framework.imps.GetChildrenBuilderImpl.pathInForeground(GetChildrenBuilderImpl.java:228) at org.apache.curator.shaded.framework.imps.GetChildrenBuilderImpl.forPath(GetChildrenBuilderImpl.java:219) at org.apache.curator.shaded.framework.imps.GetChildrenBuilderImpl.forPath(GetChildrenBuilderImpl.java:41) at org.apache.storm.kafka.monitor.KafkaOffsetLagUtil.getLeadersAndTopicPartitions(KafkaOffsetLagUtil.java:319) at org.apache.storm.kafka.monitor.KafkaOffsetLagUtil.getOffsetLags(KafkaOffsetLagUtil.java:256) at org.apache.storm.kafka.monitor.KafkaOffsetLagUtil.main(KafkaOffsetLagUtil.java:124)

错误 Unable to get offset lags for kafka 在异常的另一部分根据我更改的zkroot路径(中的第3个参数)更改时保持不变 SpoutConfig ). 我不知道如何确切地填补这些论点,让Kafka从我的主题推特拉。
我使用这里的教程编写了提交拓扑的代码:http://stdatalabs.blogspot.ca/2016/10/real-time-stream-processing-using.html 我对maven依赖项做了许多更改。我的pom.xml拥有storm core、kafka等的所有依赖项,maven repo中提供了最新版本。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题