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

[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
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
Created topic huolala-kafka-topic.

解析:

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

查询toipc列表

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

查看指定topic信息

 包括一些分区信息:

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

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

删除topic

 

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

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

kafka 生产和消费:

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

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

直接指定它。主题huolala

启动消费者

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

[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
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
huolala:0:16
 

增加topic分区数

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

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

    链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&am ...

  2. [题解]UVA11027 Palindromic Permutation

    链接:http://vjudge.net/problem/viewProblem.action?id=19602 描述:给出一个字符串,求重新排列后第n个回文串,若没有则输出"XXX&quo ...

  3. React函数类组件及其Hooks学习

    目录 函数类组件 函数式组件和类式组件的区别: 为什么要使用函数式组件? Hooks概念及常用的Hooks 1. useState: State的Hook 语法 useState()说明: setXx ...

  4. Keepalived配置重载(reload)实现方法

    一.前言 Keepalived运行过程中,可能存在更改配置的需求,例如修改virtual_ipaddress,virtual_router_id,priority等参数.在keepalived不重启, ...

  5. c# 窗体相关操作(最大化/最小化/关闭/标题栏)

    /// <summary> /// 窗体跟随鼠标移动的标记 /// </summary> private bool normalmoving = false; /// < ...

  6. 前端js webuploader上传(导入)excel文件

    项目开发中用到导入(上传)Excel文件 我使用的是百度的webuploader: 1:下载:http://fex.baidu.com/webuploader/(官方下载/示例) 2:使用Web Up ...

  7. Tableau学习Step4一数据解释、异常值监测、参数使用、分析结果如何对外发布

    Tableau学习Step4一数据解释.异常值监测.参数使用.分析结果如何对外发布 本文首发于博客冰山一树Sankey,去博客浏览效果更好. 一. 前言 本教程通过一个案例从浅到深来学习Tableau ...

  8. 有效提升Python代码性能的三个层面

    使用python进入一个熟练的状态之后就会思考提升代码的性能,尤其是python的执行效率还有很大提升空间(委婉的说法).面对提升效率这个话题,python自身提供了很多高性能模块,很多大牛开发出了高 ...

  9. GateWay配置使用

    是什么 Cloud全家桶中有个很重要的组建就是网关,在1.x版本中都是采用的Zuul网关 但在2.X版本中,zuul的升级一直跳票,SpringCloud最后自己研发了一个网关替代Zuul Sprin ...

  10. Linux下面怎么安装PHP扩展?

    一般开发环境都是在windows上, 安装扩展也很容易, 直接把下载的.dll文件扔到ext下面, 改一下php.ini文件. 完事了. linux上有两种安装方法 1.编译安装 //下载文件 #wg ...