kafka-2.11-2.0.0
[root@lijia1 config]# vi ./server.properties
broker.id=0
advertised.listeners=PLAINTEXT://192.168.106.141:9092
log.dirs=/opt/bigdata/kafka211/kafka-logs
zookeeper.connect=192.168.106.107:2181
delete.topic.enable=true
// 配置环境变量
export KAFKA_HOME=/opt/bigdata/kafka211
export PATH=$PATH:$KAFKA_HOME/bin
// 启动Kafka
[root@lijia1 kafka211]# kafka-server-start.sh ./config/server.properties
[root@lijia1 kafka211]# kafka-server-start.sh -daemon ./config/server.properties
// 创建topic
[root@lijia1 kafka211]# kafka-topics.sh --create --zookeeper 192.168.106.141:2181 --topic kb07demo --partitions 3 --replication-factor 1
Created topic "kb07demo".
// 查看当前kafka中的topic
[root@lijia1 kafka211]# kafka-topics.sh --zookeeper 192.168.106.141:2181 --list
// 查看topic详情
[root@lijia1 kafka211]# kafka-topics.sh --zookeeper 192.168.106.141:2181 --describe --topic kb07demo
Isr 选择相应速度快,消息数量最多的副本用于备用leader 宕机后选举相应最快,消息数量最多的当选
// 删除topic
[root@lijia1 kafka211]# kafka-topics.sh --zookeeper 127.0.0.1:2181 --delete --topic kb05
// 创建生产者,产生数据
[root@lijia1 kafka211]# kafka-console-producer.sh --topic kb07demo --broker-list 192.168.106.141:9092
// 创建消费者,重头开始取数据
[root@lijia1 ~]# kafka-console-consumer.sh --bootstrap-server 192.168.106.141:9092 --topic kb07demo --from-beginning
// 查看topic消息队列数量
[root@lijia1 config]# kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list 192.168.106.141:9092 --topic kb07demo -time -1 --offsets 1