Skip to main content

下载与安装

Mac 便捷安装

brew install kafka

linux

> wget http://mirror.bit.edu.cn/apache/kafka/2.0.0/kafka_2.11-2.0.0.tgz
> tar -xzf kafka_2.11-2.0.0.tgz
> cd kafka_2.11-2.0.0

config目录下修改

vi server.properties

开启kafka

./bin/kafka-server-start.sh -daemon config/server.properties
./bin/kafka-server-start.sh config/server.properties

后台运行

nohup bin/kafka-server-start.sh config/server.properties &

执行 jps 命令查看是否运行
没安装 jps 执行 apt install openjdk-8-jdk-headless 安装

bin下关闭kafka

./kafka-server-stop.sh ../config/server.properties
./bin/kafka-server-stop.sh ../config/server.properties

错误解决

  1. bash: ./kafka-server-start.sh: Permission denied
chmod u+x ./bin/*.sh
  1. OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c0000000, 1073741824, 0) failed; error='Cannot allocate memory' (errno=12)
vi kafka-server-start.sh

找到这一行

export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"

改为

export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"