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"
相关文章
相关标签/搜索