kafka單機安裝和啓動

1.下載並解壓到/usr/local/src目錄下
bootstrap

2.運行kafka須要使用Zookeeper,先啓動Zookeeper,若是沒有Zookeeper,可使用kafka自帶打包和配置好的Zookeeper3d

前臺運行:
bin/zookeeper-server-start.sh config/zookeeper.properties

後臺運行:
nohup bin/zookeeper-server-start.sh config/zookeeper.properties > zookeeper-run.log 2>&1 &

3.啓動kafkacode

前臺運行:
bin/kafka-server-start.sh config/server.properties

後臺運行:
nohup bin/kafka-server-start.sh config/server.properties > kafka-run.log 2>&1 &

4.建立topicserver

建立kafka topic:
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test

顯示kafka topic:
bin/kafka-topics.sh -list -zookeeper  localhost:2181

5.建立生產者和消費者blog

建立kafka生產者:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test

建立kafka消費者:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning

設置kafka消費組名:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning --consumer-property group.id=test-group


相關文章
相關標籤/搜索