kafka使用中遇到的問題

一、測試發送消息時,在broker本機正常,另外一臺非broker機器發送時錯: ERROR Error when sending message to topic my-topic with key: null, value: 9 bytes with error: Batch Expired (org.apache.kafka.clients.
producer.internals.ErrorLoggingCallback)java

修改kafka的配置文件中的listeners改成host:port:
listeners=PLAINTEXT://192.168.204.112:9092apache

查到的資料上說,設置advertised.listeners=PLAINTEXT://192.168.204.112:9092。該值是發佈給zookeeper而後提供給客戶端使用的,它可能與broker的綁定地址不一樣。若是沒有設置該值,將使用host.name.若是host.name也未設置,將使用java.net.InetAddress.getCanonicalHostName()的返回值。ide

二、內存不足測試

USAGE: ./kafka-server-start.sh [-daemon] server.properties [--override property=value]*
gelare@Carrot:~/misc/kafka_2.11-0.9.0.0/bin$ ./kafka-server-start.sh ../config/server.properties 
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c0000000, 1073741824, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 1073741824 bytes for committing reserved memory.
 .net

修改kafka-server-startup.sh:server

export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"
改成:
export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"
相關文章
相關標籤/搜索