1:确认zookeeper集群安装正确,防火墙关闭
2:下载kafka安装文件
cd /usr/local/mydown wget http://mirror.bit.edu.cn/apache/kafka/2.2.1/kafka_2.12-2.2.1.tgz
3:解压后指定目录
tar -zxvf kafka_2.12-2.2.1.tgz -C /usr/local ln -s kafka_2.12-2.2.1 kafka
4:修改配制文件/usr/local/kafka/config/server.properties
# 设置broker的id,每台机器的broker不同 broker.id=1 # 因为此处使用阿里云,所以需要配置上外网地址 host.name=内网地址 advertised.host.name=外网地址 message.max.byte=5242880 default.replication.factor=2 replica.fetch.max.bytes=5242880 # 设置zookeeper集群连接端口 zookeeper.connect=X.X.X.X:2181,X.X.X.X:2181,X.X.X.X:2181/kafka
5:启动kafka
nohup bin/kafka-server-start.sh config/server.properties >logs/1.log 2>&1 &
6:测试,注意zk的路径要和配制的路径一致
#创建 topic bin/kafka-topics.sh --create --zookeeper X.X.X.X:2181,X.X.X.X:2181,X.X.X.X:2181/kafka --replication-factor 3 --partitions 3 --topic zyb-test #显示 topic 信息 bin/kafka-topics.sh --describe --zookeeper X.X.X.X:2181,X.X.X.X:2181,X.X.X.X:2181/kafka --topic zyb-test #列出topic bin/kafka-topics.sh --list --zookeeper X.X.X.X:2181,X.X.X.X:2181,X.X.X.X:2181/kafka #删除 topic bin/kafka-topics.sh --delete --zookeeper X.X.X.X:2181,X.X.X.X:2181,X.X.X.X:2181/kafka --topic zyb-test