KaFka 安装与基本使用

学了有一段时间的大数据了,学习新的组件,大部分安装可以分为三步:上传解压,配置文件,启动。

分享一下我的kafka安装包:

  链接:https://pan.baidu.com/s/1fbydwZwcYyi2saYozit0nA
  提取码:w4oc

1、上传解压

2、进入到 /usr/local/soft/kafka_2.10-0.8.2.2/config 目录下,修改server.properties文件

3、因为Kafka是去中心化的,所以我们需要在每一台节点上都要有

修改上面配置文件中的两个信息:

(1)brokers.id

 (2)zookeeper

4、scp到每个节点,并且修改broker.id

5、先每个节点启动zookeeper 

6、每个节点上启动kafka

  nohup /usr/local/soft/kafka_2.10-0.8.2.2/bin/kafka-server-start.sh /usr/local/soft/kafka_2.10-0.8.2.2/config/server.properties >>/usr/local/soft/kafka_2.10-0.8.2.2/logs/start.log 2>&1 &

7、查看进程

8、创建topic

--replication-factor ---每一个分区的副本数量
--partition --分区数

kafka-topics.sh --create --zookeeper testmaster:2181,testnode1:2181,testnode2:2181,testnode3:2181 --replication-factor 4 --partitions 4 --topic flume

kafka-topics.sh --create --zookeeper Linux:2181,Linux1:2181,Linux2:2181 --replication-factor 3 --partitions 3 --topic topic


9、查看topic描述信息
kafka-topics.sh --describe --zookeeper testmaster:2181,testnode1:2181,testnode2:2181,testnode3:2181 --topic topic

kafka-topics.sh --describe --zookeeper Linux:2181,Linux1:2181,Linux2:2181 --topic topic

10、获取所有topic
kafka-topics.sh --list --zookeeper testmaster:2181,testnode1:2181,testnode2:2181,testnode3:2181
kafka-topics.sh --list --zookeeper Linux:2181,Linux1:2181,Linux2:2181

11、创建控制台生产者
kafka-console-producer.sh --broker-list testmaster:9092,testnode1:9092,testnode2:9092,testnode3:9092 --topic topic

kafka-console-producer.sh --broker-list Linux:9092,Linux1:9092,Linux2:9092 --topic topic

12、创建控制台消费者 --from-beginning 从头消费
kafka-console-consumer.sh --zookeeper testmaster:2181,testnode1:2181,testnode2:2181,testnode3:2181 --from-beginning --topic topic
kafka-console-consumer.sh --zookeeper Linux:2181,Linux1:2181,Linux2:2181 --from-beginning --topic topic

kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --topic topic

kafka-console-consumer.sh --zookeeper localhost:2181 --from-beginning --topic topic

原文地址:https://www.cnblogs.com/wyh-study/p/12486029.html