CentOS7搭建Kafka单机环境及基础操作
CentOS7搭建Kafka单机环境及基础操作
前提
安装Kafka前需要先安装zookeeper集群
Kafka安装
解压
tar -zxvf kafka_2.8.0-0.8.0.tar.gz
修改配置
cd /usr/local/hadoop/kafka_2.8.0-0.8.0/config
vim server.properties
listeners=PLAINTEXT://:9092
advertised.listeners=PLAINTEXT://192.168.63.81:9092
log.dirs=/opt/kafka/kafka_2.12-2.3.0/logs
zookeeper.connect=localhost:2181,localhost:2182,localhost:2183
启动kafka
bin/kafka-server-start.sh config/server.properties
后台运行
./kafka-server-start.sh -daemon ../config/server.properties
Jps 查看进程
---new version--
./kafka-topics.sh --create --zookeeper 192.168.63.81:2181,192.168.63.81:2182,192.168.63.81:2183 --replication-factor 1 --partitions 1 --topic test
./kafka-topics.sh --list --zookeeper 127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183
./kafka-console-producer.sh --broker-list 127.0.0.1:9092 --topic test
./kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --topic test --from-beginning