linux按照kafka

必须先按照java jdk包!!!!!!!!!!!!

先安装zookeeper

下载:http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.14/zookeeper-3.4.14.tar.gz

解压,整个目录复制到/usr/local中

环境变量配置

编辑环境变量配置文件:vim /etc/profile

在文件末尾位置添加如下内容

export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.11

export PATH=$PATH:$ZOOKEEPER_HOME/bin

通过vim的 ":wq" 命令进行保存退出

使配置生效:source /etc/profile

修改zookeeper的配置文件

进入conf文件夹下将zoo_simple.cfg改名为zoo.cfg:mv zoo_sample.cfg zoo.cfg

服务管理命令:zkServer.sh start|stop|restart|status

客户端连接:zkCli.sh -server ${ip}:${port}

客户端关闭:quit 或者按 Ctrl + C

启动即可

 注意:必须先启动zookeeper,不然会报错
 
 
下载kafka:
http://archive.apache.org/dist/kafka/2.5.0/kafka_2.13-2.5.0.tgz
解压;复制到/usr/local
 
bin/kafka-server-start.sh config/server.properties
可能出现错误,修改kafka里面的启动文件的内存需求大小:
 

 
 
当我们zookeeper和kafak都启动完成之后,我们就可以、
创建kafka topic :

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

  1. [root@better.qzqlsj.club kafka_2.13-2.5.0]$bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic huolala-kafka-topic
  2. 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
  3. Created topic huolala-kafka-topic.

解析:

  1. partitions指定topic分区数
  2. replication-factor指定topic每个分区的副本数
  3. --zookeeper:表示在这个集群里面创建

查询toipc列表

  1. bin/kafka-topics.sh --zookeeper localhost:2181 --list
    bin/kafka-topics.sh --zookeeper 129.204.3.133:2181 --list
  1. [root@better.qzqlsj.club kafka_2.13-2.5.0]$bin/kafka-topics.sh --zookeeper localhost:2181 --list
  2. 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
  3. __consumer_offsets
  4. demo
  5. huolala
  6. huolala-kafka-topic
  7. my-kafka-topic
  8. test

查看指定topic信息

 包括一些分区信息:

bin/kafka-topics.sh --zookeeper 129.204.3.133:2181 --describe --topic huolala

  1. [root@better.qzqlsj.club kafka_2.13-2.5.0]$bin/kafka-topics.sh --zookeeper 129.204.3.133:2181 --describe --topic huolala
  2. 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
  3. Topic: huolala PartitionCount: 1 ReplicationFactor: 1 Configs:
  4. Topic: huolala Partition: 0 Leader: 0 Replicas: 0 Isr: 0

删除topic

 

bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic my-kafka-topic

  1. [root@better.qzqlsj.club kafka_2.13-2.5.0]$bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic my-kafka-topic
  2. 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
  3. Topic my-kafka-topic is marked for deletion.
  4. Note: This will have no impact if delete.topic.enable is not set to true.
  5. [root@better.qzqlsj.club kafka_2.13-2.5.0]$bin/kafka-topics.sh --zookeeper 129.204.3.133:2181 --list
  6. 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
  7. __consumer_offsets
  8. demo
  9. huolala
  10. huolala-kafka-topic
  11. test
  12. [root@better.qzqlsj.club kafka_2.13-2.5.0]$

kafka 生产和消费:

 
启动生产者
  1. bin/kafka-console-producer.sh --broker-list localhost:9092 --topic huolala

代理列表 - 我们要发送邮件的代理列表。 在这种情况下,我们只有一个代理。 Config / server.properties文件包含代理端口ID,因为我们知道我们的代理正在侦听端口9092

直接指定它。主题huolala

启动消费者

  1. bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic huolala --from-beginning

查看topic某分区偏移量最大(小)值

bin/kafka-run-class.sh kafka.tools.GetOffsetShell --topic huolala  --time -1 --broker-list localhost:9092 --partitions 0

  1. [root@better.qzqlsj.club kafka_2.13-2.5.0]$bin/kafka-run-class.sh kafka.tools.GetOffsetShell --topic huolala --time -1 --broker-list localhost:9092 --partitions 0
  2. 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
  3. huolala:0:16
 

增加topic分区数

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic huolala --partitions 10

  1. [root@better.qzqlsj.club kafka_2.13-2.5.0]$bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic huolala --partitions 10
  2. 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
  3. WARNING: If partitions are increased for a topic that has a key, the partition logic or ordering of the messages will be affected
  4. Adding partitions succeeded!
  5. [root@better.qzqlsj.club kafka_2.13-2.5.0]$bin/kafka-topics.sh --zookeeper 129.204.3.133:2181 --describe --topic huolala
  6. 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
  7. Topic: huolala PartitionCount: 10 ReplicationFactor: 1 Configs:
  8. Topic: huolala Partition: 0 Leader: 0 Replicas: 0 Isr: 0
  9. Topic: huolala Partition: 1 Leader: 0 Replicas: 0 Isr: 0
  10. Topic: huolala Partition: 2 Leader: 0 Replicas: 0 Isr: 0
  11. Topic: huolala Partition: 3 Leader: 0 Replicas: 0 Isr: 0
  12. Topic: huolala Partition: 4 Leader: 0 Replicas: 0 Isr: 0
  13. Topic: huolala Partition: 5 Leader: 0 Replicas: 0 Isr: 0
  14. Topic: huolala Partition: 6 Leader: 0 Replicas: 0 Isr: 0
  15. Topic: huolala Partition: 7 Leader: 0 Replicas: 0 Isr: 0
  16. Topic: huolala Partition: 8 Leader: 0 Replicas: 0 Isr: 0
  17. Topic: huolala Partition: 9 Leader: 0 Replicas: 0 Isr: 0
 
 
 

kafka-linux-install的更多相关文章

  1. linux install wineQQ

    Linux上没有QQ太麻烦了,查了一下讲wineQQ安装上去了,亲测可以使用滴---就是版本低,安装步骤如下: 一.安装Wine 1.添加PPA sudo add-apt-repository ppa ...

  2. linux install Theano+Tensorflow+Keras

    安装过程中,网络状态一定要好,如果安装过程中出现time out的提示信息,今天就可以洗洗睡啦,等明天网络状态好的时候再安装. 安装过程出现不知名的错误的时候,执行第一步,update一下 1.#up ...

  3. linux install sublime_text3

    ubuntu & debian: (baidu or google) 1). download ***.deb to install inux系统下怎么安装.deb文件? deb 是 ubun ...

  4. Linux install sogou input method

    # Copyright (c) 2016, 付刘伟 (Liuwei Fu)# All rights reserved.# 转载请注明出处 Linux下安装搜狗输入法需要安装以下插件,当以下所有插件安装 ...

  5. Kafka~Linux环境下的部署

    概念 Kafka是一种高吞吐量的分布式发布订阅消息系统,它可以处理消费者规模的网站中的所有动作流数据. 这种动作(网页浏览,搜索和其他用户的行动)是在现代网络上的许多社会功能的一个关键因素. 这些数据 ...

  6. linux install tomcat

    折腾了好久,按照官网的安装流程安装了不止3次,发现还是不能成功,最终发现是linux机器本身的问题,因为我用的公司的virtual machine,可能是机器本身在一次迁移的过程当中出现了问题,导致了 ...

  7. 2018 kali linux install tools

    1.VM setup https://www.vmware.com/products/workstation-pro/workstation-pro-evaluation.html VMware-Wo ...

  8. RHEL / CentOS Linux Install Core Development Tools Automake, Gcc (C/C++), Perl, Python & Debuggers

    how do I install all developer tools such as GNU GCC C/C++ compilers, make and others, after install ...

  9. linux install mysql

    sudo apt-get install mysql-server #此处会输入root的密码,设置的密码要记住 sudo apt-get install mysql-client sudo apt- ...

  10. Kafka Linux 安装

                            要先设置host, etc/hosts,添加     127.0.0.1 机器名         创建目录             修改日志保存位置   ...

随机推荐

  1. bugku-Web md5 collision writeup

    访问题目链接,得到提示input a,而题目是md5 collision,md5碰撞.所以找一个md5是oe开头的值,get方式传参过去,PAYLOAD http://114.67.246.176:1 ...

  2. mysql 的奇妙历险

    mysql 的奇妙历险 这几天在练习sql的时候,碰到下面几个题, 如下 他的表字段是这些 create table Student( SId varchar(10), # 学生id Sname va ...

  3. 2021年国内BI厂商推荐_大数据分析工具

    随着互联网大数据时代的不断发展,BI让企业的工作效率变得更高效.BI的功能也随着需求的增长不断地丰富,例如,数据可视化大屏.可视化表格.商业化数据分析.数据地图等.国外的厂商在很多场景下无法满足国内的 ...

  4. 【C# 调试】.net中的 .pdb文件是什么,有什么用

    mscn:在 Visual Studio 调试器(C#)中指定符号 (.pdb) 和源文件 PDB全称Program Database,程序数据库 ( .pdb) 文件(也称为符号文件)将项目源代码中 ...

  5. C# 题目

    题目 http://blog.zhaojie.me/2011/03/my-interview-questions-for-dotnet-programmers.html 1.考察对常量和自读字段 初始 ...

  6. c++ stringstream 实现字符串与int之间的转换

    #include <iostream> #include <sstream> using namespace std; int main() { //string转int st ...

  7. 如何在 Spring Boot 优雅关闭加入一些自定义机制

    个人创作公约:本人声明创作的所有文章皆为自己原创,如果有参考任何文章的地方,会标注出来,如果有疏漏,欢迎大家批判.如果大家发现网上有抄袭本文章的,欢迎举报,并且积极向这个 github 仓库 提交 i ...

  8. ScrollView垂直滚动和HrizontalScrollView水平滚动

    当我们在写一个页面,内容过多时我们需要滚动页面来查看,但是注意ScrollView下只能有一个元素,所以要把主页面改下,这样就只有一个LinearLayout元素: 1 <ScrollView ...

  9. Hive udf 或者 spark maven打包问题

    正常打包maven pom配置如下 <properties> <project.build.sourceEncoding>UTF8</project.build.sour ...

  10. P4-可编程语言代码学习

    (1).behavioral-model 简称bmv2 P4程序首先经过p4c-bm模块编译成JSON格式的配置文件,然后将配置文件载入到bmv2中,转化成能实现交换机功能的数据结构. behavio ...