Apache Kafka:bootstrap-server不是公认的选项

时间:2019-05-08 17:52:43

标签: networking apache-kafka centos

我正在尝试将Apache Kafka设置为在同一网络上运行CentOS的两个虚拟机之间进行通信。我最初在一台机器上设置了Kafka生产者和消费者,并且一切运行顺利。然后,我在另一台计算机上设置了Kafka,并在尝试使其连接的过程中,出现错误“ bootstrap-server未被识别的选项”(我运行的是Kafka的最新版本2.2)。

这是我用来尝试建立生产者连接的方式:

bin/kafka-console-producer.sh --bootstrap-server 10.0.0.11:9092 --topic test

在消费者方面:

bin/kafka-console-producer.sh --bootstrap-server 10.0.0.11:9092 --topic test

10.0.0.11计算机正在运行服务器本身。

3 个答案:

答案 0 :(得分:1)

根据Apache Kafka文档(可在https://kafka.apache.org/documentation/#quickstart_send中找到),应使用#include <iostream> #include <string> #include <boost/algorithm/string.hpp> using namespace std; int main() { string mRNA, acids; int hold[3]; cout<<"Enter mRNA strand. (Ex. AUG CCA UUG)\n"; getline(cin, mRNA); boost::erase_all(mRNA, " "); cout<<mRNA<<endl<<"length: "<<mRNA.length()<<endl; int codonNum = (mRNA.length() - (mRNA.length() % 3)) / 3; cout<<codonNum<<" codons\n"; string codon[4][4][4] = { { {"Phe ", "Phe ", "Leu ", "Leu "}, {"Ser ", "Ser ", "Ser ", "Ser "}, {"Tyr ", "Tyr ", "STOP ", "STOP "}, {"Cys ", "Cys ", "STOP ", "Trp "} }, { {"Leu ", "Leu ", "Leu ", "Leu "}, {"Pro ", "Pro ", "Pro ", "Pro "}, {"His ", "His ", "Gin ", "Gin "}, {"Arg ", "Arg ", "Arg ", "Arg "} }, { {"Ile ", "Ile ", "Ile ", "Met "}, {"Thr ", "Thr ", "Thr ", "Thr "}, {"Asn ", "Asn ", "Lys ", "Lys "}, {"Ser ", "Ser ", "Arg ", "Arg "} }, { {"Val ", "Val ", "Val ", "Val "}, {"Ala ", "Ala ", "Ala ", "Ala "}, {"Asp ", "Asp ", "Glu ", "Glu "}, {"Gly ", "Gly ", "Gly ", "Gly "} } }; for (int x = 1; x <= (mRNA.length() - (mRNA.length() % 3)); x =+ 3){ for (int y = 0; y <= 2; y++){ switch (mRNA[x+y]){ case 'U': hold[y] = 0; break; case 'C': hold[y] = 1; break; case 'A': hold[y] = 2; break; case 'G': hold[y] = 3; break; case 'u': hold[y] = 0; break; case 'c': hold[y] = 1; break; case 'a': hold[y] = 2; break; case 'g': hold[y] = 3; break; } acids += codon[hold[0]][hold[1]][hold[2]]; } } cout<<"Sequence: "<<acids; /* for (int x = 0; x <= 3; x++) { for (int y = 0; y <= 3; y++) { for (int z = 0; z <= 3; z++) { cout<<codon[x][y][z]; } cout<<endl; } cout<<endl; } */ return 0; } 属性传递代理地址。

命令将是: --broker-list

答案 1 :(得分:1)

以下命令应该起作用。

./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

答案 2 :(得分:1)

./ kafka-console-consumer.sh --zookeeper localhost:2181 --topic fred

仅使此命令有效。但是,在即将发布的主要版本中,必须使用bootstrap-server选项。

当我使用上述命令时,它会发出警告:“不建议将ConsoleConsumer与旧使用者一起使用,并且在将来的主要版本中将删除它。考虑通过传递[bootstrap-server]而不是[zookeeper]使用新使用者。”