kafka
(1)kafka是一个分布式的消息缓存系统
(2)kafka集群中的服务器都叫做broker
(3)kafka有两类客户端,一个叫做producer(消息生产者),一类叫做consumer(消息消费者),客户端和broker服务器之间采用TCP协议连接
(4)kafka中的消息可以通过topic进行区分,而且每一个消息topic都会被分区,以分担消息服务器的负载
(5)每一个分区都可以有多个副本,以防止数据的丢失
(6)某一个分区中的数据如果需要更新,都必须通知该分区所有副本中的leader来更新
(7)消费者可以分组,比如有两个消费者组A和B,共同消费一个topic:order_info,A和B所消费的消息不会重复,如order_info中有100个消息,每个消息都有一个id,编号从1-99,那么如果A组消费从0-49,B组消费就从50-99,当然不一定都是连续的
(8)消费者在具体消费某个topic中的消息时,可以制定起始偏移量

集群安装
官网教程
http://kafka.apache.org/22/documentation.html#introduction
1.解压
2.修改server.properties
broker.id=1
zookeeper.connect=hadoop01:2182,hadoop02:2182,hadoop03:2182
3.将zookeeper集群启动
4.在每一台节点上启动broker
bin/kafka-server-start.sh config/server.properties
#5.自带zookeeper,用于单节点,一般集群不用
#bin/zookeeper-server-start.sh config/zookeeper.proterties

开始安装
1.下载解压

[linyouyi@hadoop01 software]$ wget https://mirrors.aliyun.com/apache/kafka/2.2.0/kafka_2.11-2.2.0.tgz
[linyouyi@hadoop01 software]$ tar -zxvf kafka_2.-2.2..tgz -C /hadoop/module/

2.修改配置文件

[linyouyi@hadoop01 software]$ cd /hadoop/module/
[linyouyi@hadoop01 module]$ ll
total
drwxrwxr-x linyouyi linyouyi Aug : apache-storm-2.0.
drwxr-xr-x linyouyi linyouyi Aug : hadoop-2.7.
drwxrwxr-x linyouyi linyouyi Aug : hbase-2.0.
drwxr-xr-x linyouyi linyouyi Jul jdk1..0_144
drwxr-xr-x linyouyi linyouyi Mar : kafka_2.-2.2.
drwxr-xr-x linyouyi linyouyi Aug : zookeeper-3.4.
[linyouyi@hadoop01 kafka_2.-2.2.]$ vim config/server.properties
broker.id=
log.dirs=/hadoop/kafka_2.-2.2./log/kafka-logs
zookeeper.connect=hadoop01:,hadoop02:,hadoop03:

3.拷贝到其他节点

[linyouyi@hadoop01 kafka_2.-2.2.]$ cd ../
[linyouyi@hadoop01 module]$ scp -r kafka_2.-2.2./ linyouyi@hadoop02:/hadoop/module/
[linyouyi@hadoop01 module]$ scp -r kafka_2.-2.2./ linyouyi@hadoop03:/hadoop/module/

4.修改另外两台的broker.id

[linyouyi@hadoop02 kafka_2.-2.2.]$ vim config/server.properties
broker.id=
[linyouyi@hadoop03 kafka_2.-2.2.]$ vim config/server.properties
broker.id=

5.启动kafka

[linyouyi@hadoop01 kafka_2.-2.2.]$ bin/kafka-server-start.sh -deamon config/server.properties
[linyouyi@hadoop01 kafka_2.-2.2.]$ jps
Jps
QuorumPeerMain
Kafka
[linyouyi@hadoop02 kafka_2.-2.2.]$ bin/kafka-server-start.sh -deamon config/server.properties
[linyouyi@hadoop02 kafka_2.-2.2.]$ jps
Jps
Kafka
QuorumPeerMain
[linyouyi@hadoop03 kafka_2.-2.2.]$ bin/kafka-server-start.sh -deamon config/server.properties
[linyouyi@hadoop03 kafka_2.-2.2.]$ jps
QuorumPeerMain
Jps
Kafka

使用
1.创建话题
//hadoop01:9092,hadoop02:9092,hadoop03:9092都行

[linyouyi@hadoop03 kafka_2.-2.2.]$ bin/kafka-topics.sh --create --bootstrap-server hadoop01: --replication-factor  --partitions  --topic linyouyi
[-- ::,] INFO [ReplicaFetcherManager on broker ] Removed fetcher for partitions Set(linyouyi-) (kafka.server.ReplicaFetcherManager)
[-- ::,] INFO [Log partition=linyouyi-, dir=/tmp/kafka-logs] Loading producer state till offset with message format version (kafka.log.Log)
[-- ::,] INFO [Log partition=linyouyi-, dir=/tmp/kafka-logs] Completed load of log with segments, log start offset and log end offset in ms (kafka.log.Log)
[-- ::,] INFO Created log for partition linyouyi- in /tmp/kafka-logs with properties {compression.type -> producer, message.format.version -> 2.2-IV1, file.delete.delay.ms -> , max.message.bytes -> , min.compaction.lag.ms -> , message.timestamp.type -> CreateTime, message.downconversion.enable -> true, min.insync.replicas -> , segment.jitter.ms -> , preallocate -> false, min.cleanable.dirty.ratio -> 0.5, index.interval.bytes -> , unclean.leader.election.enable -> false, retention.bytes -> -, delete.retention.ms -> , cleanup.policy -> [delete], flush.ms -> , segment.ms -> , segment.bytes -> , retention.ms -> , message.timestamp.difference.max.ms -> , segment.index.bytes -> , flush.messages -> }. (kafka.log.LogManager)
[-- ::,] INFO [Partition linyouyi- broker=] No checkpointed highwatermark is found for partition linyouyi- (kafka.cluster.Partition)
[-- ::,] INFO Replica loaded for partition linyouyi- with initial high watermark (kafka.cluster.Replica)
[-- ::,] INFO Replica loaded for partition linyouyi- with initial high watermark (kafka.cluster.Replica)
[-- ::,] INFO Replica loaded for partition linyouyi- with initial high watermark (kafka.cluster.Replica)
[-- ::,] INFO [Partition linyouyi- broker=] linyouyi- starts at Leader Epoch from offset . Previous Leader Epoch was: - (kafka.cluster.Partition) [linyouyi@hadoop03 kafka_2.-2.2.]$ bin/kafka-topics.sh --list --bootstrap-server localhost:
linyouyi
[linyouyi@hadoop03 kafka_2.-2.2.]$ bin/kafka-topics.sh --list --bootstrap-server hadoop01:
linyouyi
[linyouyi@hadoop03 kafka_2.-2.2.]$ bin/kafka-topics.sh --list --zookeeper hadoop01:
linyouyi
[linyouyi@hadoop03 kafka_2.-2.2.]$ bin/kafka-topics.sh --create --bootstrap-server hadoop01: --replication-factor --partitions --topic youyi
[linyouyi@hadoop03 kafka_2.-2.2.]$ bin/kafka-topics.sh --list --zookeeper hadoop01:
linyouyi
youyi

2.生产者往话题里面写消息

[linyouyi@hadoop03 kafka_2.-2.2.]$ bin/kafka-console-producer.sh --broker-list localhost: --topic linyouyi>This is a message
>This is another message

3.消费者立马消费消息

[linyouyi@hadoop02 kafka_2.-2.2.]$ bin/kafka-console-consumer.sh --bootstrap-server localhost: --topic linyouyi --from-beginning
This is a message
This is another message

4.接着在生产者继续写话题,消费者立马就消费了

5.查看topic linyouyi总体情况

[linyouyi@hadoop01 kafka_2.-2.2.]$ bin/kafka-topics.sh --describe --bootstrap-server localhost: --topic linyouyi
Topic:linyouyi PartitionCount: ReplicationFactor: Configs:segment.bytes=
Topic: linyouyi Partition: Leader: Replicas: ,, Isr: ,,
[linyouyi@hadoop01 kafka_2.-2.2.]$ bin/kafka-topics.sh --describe --bootstrap-server localhost: --topic youyi
Topic:youyi PartitionCount: ReplicationFactor: Configs:segment.bytes=
Topic: youyi Partition: Leader: Replicas: ,, Isr: ,,

kafka集群安装和使用的更多相关文章

  1. kafka集群安装部署

    kafka集群安装 使用的版本 系统:centos6.5 centos6.7 jdk:1.7.0_79 zookeeper:3.4.9 kafka:2.10-0.10.1.0 一.环境准备[只列,不具 ...

  2. zookeeper+kafka集群安装之二

    zookeeper+kafka集群安装之二 此为上一篇文章的续篇, kafka安装需要依赖zookeeper, 本文与上一篇文章都是真正分布式安装配置, 可以直接用于生产环境. zookeeper安装 ...

  3. zookeeper+kafka集群安装之一

    zookeeper+kafka集群安装之一 准备3台虚拟机, 系统是RHEL64服务版. 1) 每台机器配置如下: $ cat /etc/hosts ... # zookeeper hostnames ...

  4. zookeeper+kafka集群安装之中的一个

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/cheungmine/article/details/26678877 zookeeper+kafka ...

  5. KafKa集群安装详细步骤

    最近在使用Spring Cloud进行分布式微服务搭建,顺便对集成KafKa的方案做了一些总结,今天详细介绍一下KafKa集群安装过程: 1. 在根目录创建kafka文件夹(service1.serv ...

  6. Kafka 集群安装

    Kafka 集群安装 环境: Linux 7.X kafka_2.x 在linux操作系统中,kafka安装在 /u04/app目录中 1. 下载 # wget https://mirrors.cnn ...

  7. KafKa集群安装、配置

    一.事前准备 1.kafka官网:http://kafka.apache.org/downloads. 2.选择使用版本下载. 3.kafka集群环境准备:(linux) 192.168.145.12 ...

  8. Centos7.4 kafka集群安装与kafka-eagle1.3.9的安装

    Centos7.4 kafka集群安装与kafka-eagle1.3.9的安装 集群规划: hostname Zookeeper Kafka kafka-eagle kafka01 √ √ √ kaf ...

  9. (Linux环境Kafka集群安装配置及常用命令

    Linux环境Kafka集群安装配置及常用命令 Kafka 消息队列内部实现原理 Kafka架构 一.下载Kafka安装包 二.Kafka安装包的解压 三.设置环境变量 四.配置kafka文件 4.1 ...

  10. Kafka集群安装Version1.0.1(自带Zookeeper)

    1.说明 Kafka集群安装,基于版本1.0.1, 使用kafka_2.12-1.0.1.tgz安装包, 其中2.12是编译工具Scala的版本. 而且不需要另外安装Zookeeper服务, 使用Ka ...

随机推荐

  1. {"timestamp":"2019-11-12T02:39:28.949+0000","status":415,"error":"Unsupported Media Type","message":"Content type 'text/plain;charset=UTF-8' not supported","path":&quo

    在Jmeter运行http请求时报错: {"timestamp":"2019-11-12T02:39:28.949+0000","status&quo ...

  2. vue element-ui NavMenu错位问题

    原因:子菜单全部打开后太长超过100% 解决方法:设置只能点击打开当前的菜单

  3. CodeFirst命令

    CodeFirst get-help entityFramework          NuGet命令 Add-Migration                     Adds a new mig ...

  4. Sql 语法整理

    Query 1 SELECT 和 SELECT * 语句 SELECT LastName,FirstName FROM Persons 2 SELECT DISTINCT 语句 SELECT DIST ...

  5. 【luoguP4768】【NOI2018】归程

    description 本题的故事发生在魔力之都,在这里我们将为你介绍一些必要的设定. 魔力之都可以抽象成一个 nn 个节点.mm 条边的无向连通图(节点的编号从 11 至 nn).我们依次用 l,a ...

  6. web自动化框架抽取示例【Java+selenium】

    web自动化测试框架抽取示例 例子:测试登录模块,对登录的账号和密码进行不同的case校验. 1.1.1 无优化代码login_1 package com.lee.auto.testFrome; im ...

  7. python 爬取拉勾网

    import requestsimport randomimport timeimport osimport csvimport pandas as pdreq_url = 'https://www. ...

  8. 【LeetCode 24】两两交换链表中的节点

    题目链接 [题解] 简单的链表操作 [代码] /** * Definition for singly-linked list. * struct ListNode { * int val; * Lis ...

  9. mongdb 备份还原导入导出

    -------------------MongoDB数据导入与导出------------------- 1.导出工具:mongoexport     1.概念:         mongoDB中的m ...

  10. 二叉树总结及部分Lintcode题目分析 1

    1. 遍历问题 Preorder / Inorder / Postorder preorder: root left right inorder: left root right postorder: ...