kafka 的命令
1.原理
- 基本原理图
2.组成
- 话题(Topic):Kafka的消息逻辑存放结构。
- 每个topic可以由多个partition构成, 每个partition可以有多个副本,只会有一个partition leader用来做消息读写
- 生产者(Producer):发送topic到broker上,同一消息会均匀的写到partions上
- 服务器(Broker):保存消息、维护副本数据、保存消息消费的offset、保证Consumer Group消费消息、选举 partition leader。
- 消费者(Consumer):消费topic中的消息
- 每个Consumer属于一个Consumer Group,每个消息只会被Consumer Group消费一次
- 每个Consumer 都是单独Consumer Group,则相当于 Pub/Sub。
- 所用Consumer 都是在同一Consumer Group,则相当于 P2P。
- Consumer API
- The high-level consumer API:一个消息只能被Group内的一个consumer消费,且consumer消费时不关注offset,最后一个offset由zookeeper保存。Consumer Group 直接保存offset
- The SimpleConsumer API:很灵活,可以重复消费消息
- 每个Consumer属于一个Consumer Group,每个消息只会被Consumer Group消费一次
- 运行
- Push模式:实时性高,但是不能很好的根据每个consumer服务器状态太推送消息。
- Pull模式: 这里输入引用文本: 实时性低,Consumer 服务器可以根据自身的情况来消费
3.安装
- 下载:kafka_2.11-1.1.0.tgz
- 解压:tar -xzf kafka_2.11-1.1.0.tgz
- 启动zk:
- 启动kafka:bin/kafka-server-start.sh config/server.properties
4.命令
- 相关命令的shell
-rwxr-xr-x 1 dlmanager dlmanager 1421 Mar 24 06:51 connect-distributed.sh-rwxr-xr-x 1 dlmanager dlmanager 1418 Mar 24 06:51 connect-standalone.sh-rwxr-xr-x 1 dlmanager dlmanager 861 Mar 24 06:51 kafka-acls.sh-rwxr-xr-x 1 dlmanager dlmanager 873 Mar 24 06:51 kafka-broker-api-versions.sh-rwxr-xr-x 1 dlmanager dlmanager 864 Mar 24 06:51 kafka-configs.sh-rwxr-xr-2 1 dlmanager dlmanager 945 Mar 24 06:51 kafka-console-consumer.sh-rwxr-xr-x 1 dlmanager dlmanager 944 Mar 24 06:51 kafka-console-producer.sh3-rwxr-xr-x 1 dlmanager dlmanager 871 Mar 24 06:51 kafka-consumer-groups.sh-rwxr-xr-x 1 dlmanager dlmanager 948 Mar 24 06:51 kafka-consumer-perf-test.sh-rwxr-xr-x 1 dlmanager dlmanager 871 Mar 24 06:51 kafka-delegation-tokens.sh-rwxr-xr-x 1 dlmanager dlmanager 869 Mar 24 06:51 kafka-delete-records.sh-rwxr-xr-x 1 dlmanager dlmanager 863 Mar 24 06:51 kafka-log-dirs.sh-rwxr-xr-x 1 dlmanager dlmanager 862 Mar 24 06:51 kafka-mirror-maker.sh-rwxr-xr-x 1 dlmanager dlmanager 886 Mar 24 06:51 kafka-preferred-replica-election.sh-rwxr-xr-x 1 dlmanager dlmanager 959 Mar 24 06:51 kafka-producer-perf-test.sh-rwxr-xr-x 1 dlmanager dlmanager 874 Mar 24 06:51 kafka-reassign-partitions.sh-rwxr-xr-x 1 dlmanager dlmanager 868 Mar 24 06:51 kafka-replay-log-producer.sh-rwxr-xr-x 1 dlmanager dlmanager 874 Mar 24 06:51 kafka-replica-verification.sh-rwxr-xr-x 1 dlmanager dlmanager 7864 Mar 24 06:51 kafka-run-class.sh-rwxr-xr-x 1 dlmanager dlmanager 1376 Mar 24 06:51 kafka-server-start.sh-rwxr-xr-x 1 dlmanager dlmanager 997 Mar 24 06:51 kafka-server-stop.sh-rwxr-xr-x 1 dlmanager dlmanager 870 Mar 24 06:51 kafka-simple-consumer-shell.sh-rwxr-xr-x 1 dlmanager dlmanager 945 Mar 24 06:51 kafka-streams-application-reset.sh-rwxr-xr-x 1 dlmanager dlmanager 863 Mar 24 06:51 kafka-topics.sh-rwxr-xr-x 1 dlmanager dlmanager 958 Mar 24 06:51 kafka-verifiable-consumer.sh-rwxr-xr-x 1 dlmanager dlmanager 958 Mar 24 06:51 kafka-verifiable-producer.sh