kafka安装linux版
安装实战
kafka安装包下载(注意:这里选择的安装包是2.11系列的1.1.0版本的)
wget https://archive.apache.org/dist/kafka/1.1.0/kafka_2.11-1.1.0.tgz
安装启动服务
首先,我们需要下载并且安装zk和kafka,并且将这两个服务启动:
解压缩文件
tar zxvf kafka_2.11-1.1.0.tgz
cd kafka_2.11-1.1.0/
启动zk
bin/zookeeper-server-start.sh -daemon config/zookeeper.properties
检查zk是否启动成功
netstat -tunpl|grep 2181
tcp6 0 0 :::2181 :::* LISTEN 2877/java
启动kafka
常规模式启动kafka
bin/kafka-server-start.sh -daemon config/server.properties
进程守护模式启动kafka
nohup bin/kafka-server-start.sh config/server.properties >/dev/null 2>&1 &
检查kafka是否启动成功
netstat -tunpl|grep 9092
tcp6 0 0 :::9092 :::* LISTEN 3164/java
命令方式验证
1. 运行 producer
打开一个窗口,输入如下的指令,启动生产者:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
2. 运行 consumer
新启动一个新的窗口,输入如下的指令,启动消费者:
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning (可能不成功,换下面红色的启动方式)
3. 测试消息传递
在producer中写信息, 从consumer中可以看到结果, 如下:
生产者端:
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
>i like you
[2018-12-07 01:55:56,427] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 1 : {test=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
[2018-12-07 01:55:56,532] WARN [Producer clientId=console-producer] Error while fetching metadata with correlation id 3 : {test=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
>hello
>world
>hello kafka
>
消费者端:
bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper].
i like you
hello
world
hello kafka
但是这是一种比较老使用zk启动消费端的方式,后序版本会废弃,官方推荐新的使用方式如下:
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning
i like you
hello
world
hello kafka
hello
上面的消费方式为从头开始消费的,因此之前生产者发送过的历史消息,后启动的消费者仍然可以接收到。
这里我们再次测试一下只接收新的消息。
bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test
生产者端输入:
i like you
hello
world
hello kafka
hello
-------
louxj424 #新输入的内容
消费者端就只查看到一条消息:
louxj424
zookeeper和kafka的关闭
./bin/zookeeper-server-stop.sh
bin/kafka-server-stop.sh
参考:https://www.jianshu.com/p/94349568533c
https://blog.csdn.net/qq_19524879/article/details/82848556
kafka安装linux版的更多相关文章
- Kafka安装-Linux版
1. 准备 1.1 Kafka Kafka版本采用0.10.2.1,下载0.10.2.1文件 http://kafka.apache.org/downloads 1.2 JDK JDK ...
- 安装linux版zabbix客户端
安装linux版zabbix客户端 一.下载客户端 查看centos系统内核版本 cat /proc/version 如上图,就选择Linux 2.6系统对应的agent版本程序 打开官网:https ...
- sqlserver2017安装Linux版教程
安装 SQL Server 下载 Microsoft SQL Server 2017 Red Hat 存储库配置文件: sudo curl -o /etc/yum.repos.d/mssql-serv ...
- 安装linux版qq,安装二进制包编译器,安装mysql-5.6.11,删除已安装或安装失败的mysql-5.6.11,简单mysql练习题
上午[root@localhost ~]# ./test3.sh dev1^C[root@localhost ~]# groupadd dev1[root@localhost ~]# vim /etc ...
- Linux版OpenVPN安装、配置教程(转)
本文将以目前最新的openvpn-2.3.4.tar.gz(更新于2014-5-2,下载地址)为例来介绍如何在Linux系统中安装.配置及使用OpenVPN. 在这里,我们选用了一台预装CentOS ...
- 巧用linux版powershell,管理linux下的docker
大家好,我把用powershell的docker马甲命令的好处,放在了页面下方,从第五章开始. powershell 传教士 原创文章 始于 2017-09-07 允许转载,但必须保留名字和出处,否则 ...
- XAMPP 的安装配置(Linux 版)
--姜庭华 msn: jaimejth@live.cn --博客:http://blog.csdn.net/jaimejth 软件下载在以下网站 http://www.apachefriends.o ...
- CENTOS6 下MATLAB2014b的安装和破解(Matlab_R2014b linux版 安装笔记)
参考:http://www.jianshu.com/p/f0cefc737dda ①在下载matlab linux版.iso, ②在windows下用ULTRAISO软件提取 ③用crack中的ins ...
- linux版powershell安装教程(.net core版)
powershell 传教士 原创文章 始于2016-12-20,2017-03-15改.文章版本目前博客园为最新版. 允许转载,但必须保留名字和出处,否则追究法律责任 问:powershell二进制 ...
随机推荐
- IDEA连接数据库之后,无法自动找到表
在用IDEA连接数据库之后,在查询的时候无法自动关联出表,就如下图的提示所示: 这样看着很不舒服,按照如下设置就可以联想出表了: 点击第一个勾,关联所有: 然后就可以关联到表了
- div模拟textarea且高度自适应
需求 我们知道文本超出 textarea 高度后,textarea 就会出现滚动条,需求就是让 textarea 高度跟随文本高度变化,屏蔽滚动条,原来做过用js去监听文本行数,然后改变文本框的高度, ...
- GoCN每日新闻(2019-11-02)
GoCN每日新闻(2019-11-02) GoCN每日新闻(2019-11-02) 1. Go 1.13.4 and Go 1.12.13 are released https://groups.go ...
- SpringMVC相关试题
1.下列相关Spring自动装配的说法中,错误的是( ). (选择一项) A:在Spring配置文件中,可以通过<bean>元素的autowire属性指定自动装配方式B: autowire ...
- Codeforces1254B2 Send Boxes to Alice (Hard Version)(贪心)
题意 n个数字的序列a,将i位置向j位置转移x个(a[i]-x,a[j]+x)的花费为\(x\times |i-j|\),最终状态可行的条件为所有a[i]均被K整除(K>1),求最小花费 做法 ...
- 实践分布式配置中心Apollo
简介 Apollo(阿波罗)是携程框架部门研发的分布式配置中心,能够集中化管理应用不同环境.不同集群的配置,配置修改后能够实时推送到应用端,并且具备规范的权限.流程治理等特性,适用于微服务配置管理场景 ...
- GlusterFS常用设置命令
可信存储池(Trusted Storage Pool)创建存储池例如要创建一个包含3个服务器的存储池,则需要从第一个服务器server1中把另外两个服务器加入存储池中:# gluster peer p ...
- SpringCache
官方文档:https://docs.spring.io/spring/docs/4.3.13.RELEASE/spring-framework-reference/htmlsingle/#cache ...
- 用shedlock实现分布式定时任务锁
添加包 <dependency> <groupId>net.javacrumbs.shedlock</groupId> <artifactId ...
- 【用例篇】Xmind转为csv 导入禅道
用过禅道的都知道,用例维护实在是太不方便了,有人推荐了一种方法,用Xmind先编写用例(思路比较清晰),写好之后借助工具(xmind2testcase)将用例转为CSV格式,之后再导入禅道 参考资料: ...