赞
踩
- yum install java-1.8.0-openjdk.x86_64
- yum install java-1.8.0-openjdk-devel.x86_64
软件下载地址:https://kafka.apache.org/downloads
我下载的是当前的最新版 3.4.0
- tar -xzf kafka_2.13-3.4.0.tgz
- cd kafka_2.13-3.4.0
bin/zookeeper-server-start.sh config/zookeeper.properties
bin/kafka-server-start.sh config/server.properties
- bin/zookeeper-shell.sh localhost:2181
-
- #输出
- OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
- Connecting to localhost:2181
- Welcome to ZooKeeper!
- JLine support is disabled
-
- WATCHER::
-
- WatchedEvent state:SyncConnected type:None path:null
-
-
- #查看节点ids
- ls /
-
- ls /brokers/ids
- #输出
- [0]
-
bin/kafka-topics.sh --create --topic test_topic --bootstrap-server localhost:9092
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test_topic
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
bin/kafka-topics.sh --list --zookeeper localhost:2181
在config / producer.properties 文件中指定默认生产者属性
bin/kafka-console-producer.sh --topic test_topic --bootstrap-server localhost:9092
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test_topic
在config / consumber.properties 文件中指定了缺省使用者属性
bin/kafka-console-consumer.sh --topic test_topic --from-beginning --bootstrap-server localhost:9092
bin/kafka-console-consumer.sh --zookeeper localhost:2181 —-topic test_topic --from-beginning
旧版(<v2.2):
kafka-topics.sh --zookeeper node1:2181,node2:2181,node3:2181/kafka --create --topic ..
旧版用--zookeeper参数,主机名(或IP)和端口用ZooKeeper的2181,也就是server.properties文件中zookeeper.connect属性的配置值. ps:使用--zookeeper参数还需要指定kafka的Broker路径,注意不是在根目录下,是在/kafka路径下。
新版(>v2.2):
kafka-topics.sh --bootstrap-server node1:9092 --create --topic ..
新版用--bootstrap-server参数,主机名(或IP)和端口用某个节点的即可,即主机名(或主机IP):9092。9092是Kafka的监听端口
https://www.w3cschool.cn/apache_kafka/apache_kafka_introduction.html
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。