我是卡夫卡的新人。我对kafka配置有疑问。
我想使用下面的单独服务器,
server1:kafka producer server2:kafka broker,kafka consumer,zookeeper
但是,我无法向经纪人发送消息。我收到此错误消息。
在console-producer(server1)上,控制台stdout错误消息`
[2016-05-24 16:41:11,823] ERROR Error when sending message to topic twitter with key: null, value: 3 bytes with error: Failed to update metadata after 60000 ms.(org.apache.kafka.clients.producer.internals.ErrorLoggingCallback)
`
在kafka生成器(server2)上,控制台stdout错误消息`
[2016-05-25 10:20:01,588] DEBUG Connection with /192.168.50.142 disconnected (org.apache.kafka.common.network.Selector)
java.io.EOFException
at org.apache.kafka.common.network.NetworkReceive.readFromReadableChannel(NetworkReceive.java:83)
at org.apache.kafka.common.network.NetworkReceive.readFrom(NetworkReceive.java:71)
at org.apache.kafka.common.network.KafkaChannel.receive(KafkaChannel.java:160)
at org.apache.kafka.common.network.KafkaChannel.read(KafkaChannel.java:141)
at org.apache.kafka.common.network.Selector.poll(Selector.java:286)
at kafka.network.Processor.run(SocketServer.scala:413)
at java.lang.Thread.run(Thread.java:745)
`
运行命令如下所示
server1在kafka上,`
./bin/zookeeper-server-start.sh config/zookeeper.properties
./bin/kafka-server-start.sh config/server.properties
./bin/kafka-console-consumer.sh --zookeeper 192.168.50.142:2181 --from-beginning --topic twitter
./bin/kafka-topics.sh --create --zookeeper 192.168.50.142:2181 --replication-factor 1 --partitions 1 --topic twitter
`
和kafka目录上的server2,`
./bin/kafka-console-producer.sh --broker-list 192.168.50.142:9092 --topic twitter
`
我的配置是,
server1(IP:192.168.50.155):
kafka / config / producer.properties`
metadata.broker.list=192.168.50.142:9092
producer.type=sync
compression.codec=none
serializer.class=kafka.serializer.DefaultEncoder
`
服务器2(IP:192.168.50.142):
kafka / config / zookeeper.properties`
dataDir=/tmp/zookeeper
clientPort=2181
maxClientCnxns=0
`
kafka / config / server.properties`
broker.id=0
listeners=PLAINTEXT://0.0.0.0:9092
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/tmp/kafka-logs
num.partitions=1
num.recovery.threads.per.data.dir=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
log.cleaner.enable=false
zookeeper.connect=localhost:2181
zookeeper.connection.timeout.ms=6000
broker.id=0
port=9092
log.dir=/tmp/kafka-logs-1
delete.topic.enable=true
`
kafka.config / consumer.properties`
zookeeper.connect=127.0.0.1:2181
zookeeper.connection.timeout.ms=6000
group.id=test-consumer-group
`
кафка_2.11-0.я.0.0ява1.8.0_60нодевч.ч.ч
我需要更改任何配置吗?请给我一些帮助。
看来您的生产者配置不正确。
卡夫卡/配置/ producer.properties
bootstrap.servers=192.168.50.142:9092
key.serializer=org.apache.kafka.common.serialization.StringSerializer
value.serializer=org.apache.kafka.common.serialization.StringSerializer
您需要使用适当的配置值修改server.properties文件并更新/ etc / hosts文件以将您的计算机解析为IP。
在server.properties中进行以下更改:
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://192.168.50.142:9092
需要此行,因为这是代理将向消费者和生产者宣传的主机名和端口。由于您在另一台机器上有生产者,因此需要此生产线。在终端中编写任何命令时,请使用
<command> --zookeeper localhost:2181 <rest of it>
希望这有效。