linux常见文件
cat>>start.sh
ctrl+d推出保存
kafka启动脚本
#!/bin/bash
echo "start kafka>>>"
#cd /home/software/kafka_2.11-0.11.0.3
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
sleep 1
bin/kafka-server-start.sh -daemon config/server.properties
kafka停止脚本
#!/bin/bash
echo "kafka stop >>>?"
bin/kafka-server-stop.sh
sleep 1
bin/zookeeper-server-stop.sh
常见命令
生产者客户端
bin/kafka-console-producer.sh --broker-list 192.168.43.122:9092 --topic test
bin/kafka-console-producer.sh --broker-list iod.kafka:6667 --topic test
bin/kafka-console-producer.sh --broker-list 192.168.43.161:9092 --topic test
消费者客户端
bin/kafka-console-consumer.sh --bootstrap-server 192.168.43.122:9092 --topic vehicle_passlog--from-beginning
bin/kafka-console-consumer.sh --bootstrap-server 192.168.43.161:9092 --topic test
bin/kafka-console-consumer.sh --bootstrap-server iod.kafka:6667 --topic vehicle_passlog
bin/kafka-console-consumer.sh --zookeeper iod.kafka:2181 --topic iod_gcjlout
启动zookeeper
nohup bin/zookeeper-server-start.sh config/zookeeper.properties >/dev/null &
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
启动kafka
nohup bin/kafka-server-start.sh config/server.properties &
bin/kafka-server-start.sh -daemon config/server.properties
查看topic列表
bin/kafka-topics.sh --list --zookeeper 192.168.43.122:2181
bin/kafka-topics.sh --list --zookeeper 61.16.43.64:2181
查看topic详情
bin/kafka-topics.sh --zookeeper 192.168.43.122:2181 --describe --topic test
查看消费情况
bin/kafka-run-class.sh kafka.tools.ConsumerOffsetChecker --zookeeper localhost:2181 --group zhsq --topic vehicle_passlog
bin/kafka-consumer-offset-checker.sh --zookeeper 61.16.43.64:2181 --topic iod_gcjlout --group zhsq
创建topic ,1个副本6个分区,副本数小于broker数,一个分区只能同时被一个消费者线程消费,一般分区数量等于线程数量,
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 6 --topic test
删除topic
bin/kafka-topics.sh --delete --zookeeper localhost:2181 --topic test
后台启动kafka
bin/kafka-server-start.sh -daemon config/server.properties
hosts目录
C:\Windows\System32\drivers\etc
auto.offset.reset
如果存在已经提交的offest时,不管设置为earliest 或者latest 都会从已经提交的offest处开始消费
如果不存在已经提交的offest时,earliest 表示从头开始消费,latest 表示从最新的数据消费,也就是新产生的数据.