爬蟲與Python:(一)網路爬蟲概念篇——7.Session和Cookie
阿新 • • 發佈:2021-09-17
安裝
1.下載kafka_2.13-3.0.0.tar 不同版本,命令稍有不同
2.放到/usr/local/share/kafka
3.解壓tar -xvfkafka_2.13-3.0.0.tar
4.修改名字mv kafka_2.13-3.0.0 kafka3
單機測試,不修改zookeeper.properties 和 server.properties
1.啟動zookeeper
bin/zookeeper-server-start.sh config/zookeeper.properties
使用 bin/zookeeper-server-start.sh -daemon config/zookeeper.properties 以守護程序啟動
2. 啟動kafka
bin/kafka-server-start.sh config/server.properties
此方式需要保持終端
3.建立topic,需要重新啟動一個終端
bin/kafka-topics.sh --create --topic topicName --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1
官網沒有指定partitions,命令執行後會提示你指定。
建立topic過程的問題,replication-factor
個數不能超過 broker 的個數
4.檢視所有topic
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
5.檢視具體topic
bin/kafka-topics.sh --describe --topic name --bootstrap-server localhost:9092 Topic:name PartitionCount:1 ReplicationFactor:1 Configs: Topic: name Partition: 0 Leader: 0 Replicas: 0 Isr: 0
6.生產訊息(write event)
bin/kafka-console-producer.sh --topic name --bootstrap-server localhost:9092 This is my first event (回車即表示一條結束) This is my second event
control+c 退出
7.消費訊息(read event)
bin/kafka-console-consumer.sh --topic name --from-beginning --bootstrap-server localhost:9092
This is my first event
This is my second event
8.刪除topic
bin/kafka-topics.sh --delete --bootstrap-server localhost:9092 --topic topicName