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二进制 ...
随机推荐
- BZOJ 3048: [Usaco2013 Jan]Cow Lineup 双指针
看到这道题的第一个想法是二分+主席树(好暴力啊) 实际上不用这么麻烦,用一个双指针+桶扫一遍就行了 ~ code: #include <bits/stdc++.h> #define N 1 ...
- H5制作显示轮播图的方法Swiper
1.需要引入Swiper插件 <!-- swiper插件 --> <link rel="stylesheet" href="https://unpkg. ...
- 洛谷P1107 [BJWC2008]雷涛的小猫 题解
题面 以下是luogu给的标签 但字符串是什么鬼.... 玄学... 哦吼~ #include<cstdio> #include<iostream> using namespa ...
- 在交互环境下使用 Pyspark 提交任务给 Spark 解决 : java.sql.SQLException: No suitable driver
在 jupyter 上启用 local 交互环境和 spark 进行交互使用 imapla 来帮助 spark 取数据却失败了 from pyspark.sql import SparkSession ...
- [golang][gui]Hands On GUI Application Development in Go【在Go中动手进行GUI应用程序开发】读书笔记03-拒交“智商税”,解密“GUI”运行之道
和老外的原文好像没多大联系了,哈哈哈,反正是读书笔记,下面的内容也是我读此书中的历程,也写进来吧.不过说实话,这框架的作者还挺对我脾气的,哈哈哈. 拒交“智商税”,解密“GUI”运行之道 我很忙 项目 ...
- linux netstat 命令简介
常用选项: -r, --route 显示路由表 -i, --interfaces 显示接口信息表-s, --statistics 显示网络协议汇总信息 -n, --numeric 不解析域名-p, - ...
- git 初始用法
Git global setup git config --global user.name "xiaoming" git config --global user.email & ...
- 关于windows10用c++部署libtorch过程中遇到的一些问题
libtorch1.0 vs2017 CMake3.14 windows10 无cuda 用c++调用pytorch模型官网上面有详细教程,也有很多博客,可以参考以下链接:https://blog.c ...
- Kubernetes中如何让Deployment更新镜像
问题描述 我的deployment有单个pod,我的自定义docker镜像如下: 123 containers: - name: mycontainer image: myimage:latest 在 ...
- [技术博客]React-Native中的组件加载、卸载与setState问题
React-Native中的组件加载.卸载与setState问题. Warning: Can only update a mounted or mounting component. This usu ...