kafka 安装内存会报不够
https://stackoverflow.com/questions/9350437/incompatible-initial-and-maximum-heap-sizes-specified
Picked up _JAVA_OPTIONS: -Xmx1024M
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000b5a00000, 1073741824, 0) failed; error=‘Cannot allocate memory‘ (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 1073741824 bytes for committing reserved memory.
需要调整jvm
export _JAVA_OPTIONS=-Xmx1024Mexport _JAVA_OPTIONS=-Xms512M
bin/kafka-server-start.sh config/server.properties
Picked up _JAVA_OPTIONS: -Xms512M
创建topic
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic a2
Created topic "a2".
查看topic
bin/kafka-topics.sh --list --zookeeper localhost:2181
发送消息到指定的topic
bin
/kafka-console-producer
.sh --broker-list localhost:9092 --topic
test
WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 1 : {test=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
如果发现是没有leader的提示错误,需要修改配置文件
原文地址:https://www.cnblogs.com/studyNT/p/9272314.html