依赖jdk、zookeeper
1.解压文件
tar -zxvf kafka_2.12-2.7.0
2.修改配置文件,日志输出地址
vim config/server.properties
log.dirs=/opt/kafka_2.12-2.7.0/logs
3.常用命令
启动
bin/kafka-server-start.sh -daemon config/server.properties
停止
bin/kafka-server-stop.sh -daemon config/server.properties
创建topic
bin/kafka-topics.sh —create —zookeeper 127.0.0.1:2181 —replication-factor 3 —partitions 3 —topic test
查看topic
bin/kafka-topics.sh —list —zookeeper 127.0.0.1:2181
发送消息
bin/kafka-console-producer.sh —broker-list 192.168.202.128:9094 —topic test
接收信息
bin/kafka-console-consumer.sh —bootstrap-server 192.168.202.128:9092 —topic test —from-beginning
查看特定主题的详细信息
bin/kafka-topics.sh —zookeeper localhost:2181 —describe —topic test
删除主题
bin/kafka-topics.sh —zookeeper localhost:2181 —delete —topic test
设置开机启动
编辑以下文件
chmod +x /etc/rc.local
vi /etc/rc.local
写入启动命令
source /etc/profile;
/opt/kafka_2.12-2.7.0/bin/kafka-server-start.sh -daemon /opt/kafka_2.12-2.7.0/config/server.properties