前言
这个博文只是记录一下在学习过程中遇到的一些小知识或小坑,并不是系统的教程,会不断的更新内容,大佬就请直接绕过!!/手动笑哭 </br>
Kafka基础指令
- 启动服务
./bin/zookeeper-server-start.sh ./config/zookeeper.properties(开启Kafka自带的zookeeper)
新开一个控制台:
./bin/kafka-server-start.sh ./config/server.properties
- 新建Topic,topic列表:
./bin/kafka-topics.sh --create --zookeeper localhost:12181 --replication-factor 1 --partitions 1 --topic YourTopicName
- 查看topic列表
./bin/kafka-topics.sh --list --zookeeper localhost:12181
- 发送消息(启动producer)
./bin/kafka-console-producer.sh --broker-list localhost:19092 --topic YourTopicName
- 接收消息(启动consumer)
./bin/kafka-console-consumer.sh --zookeeper localhost:12181 --topic YourTopicName --from-beginning
- 删除Kafka topic:
./bin/kafka-topics.sh --delete --zookeeper localhost:12181 --topic YourTopicName
- 停用Kafka、zookeeper
./bin/kafka-server-stop.sh
./bin/zookeeper-server-stop.sh
- 提交作业示例
./bin/spark-submit --driver-class-path ./jars/*:./kafka/* --class "org.apache.spark.examples.streaming.KafkaWordCount" ./mycode/kafka/target/scala-2.11/simple-project_2.11-1.0.jar 192.168.33.101:12181 1 topicOne 1
- 配置多个代理
cp ./config/server.properties ./config/server-1.properties
cp ./config/server.properties ./config/server-2.properties