kafka安装完整步骤_kafka集群搭建详细步骤

kafka安装完整步骤_kafka集群搭建详细步骤本文记录在linux环境下,安装kafka,并做简单测试,如果zookeeper没有安装,可参考zookeeper安装:1.下载安装包地址:http://kafka.apache.org/downloads,注意不要下载成source了。2.上传至服务器rz命令上传至服务器解压[root@localhostlocal]#tar-zxvfkafka_2.11-2.1.1.t…

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

本文记录在linux环境下,安装kafka,并做简单测试,如果zookeeper没有安装,可参考zookeeper安装

1.下载安装包

地址:http://kafka.apache.org/downloads, 注意不要下载成source了。
在这里插入图片描述

2.上传至服务器

rz命令上传至服务器
在这里插入图片描述
解压

[root@localhost local]# tar -zxvf kafka_2.11-2.1.1.tgz 

在这里插入图片描述

3.修改配置文件

这里这列举几个重要的配置,其他配置如果只是单机的自己做测试不需要修改:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

4.启动

[root@localhost bin]# ./kafka-server-start.sh ../config/server.properties &

这个&是后台启动,但是需要exit去退出。
(还有一种是:sh kafka-server-start.sh …/config/server.properties 1>/dev/null 2>&1 &

其中1>/dev/null 2>&1 是将命令产生的输入和错误都输入到空设备,也就是不输出的意思。

/dev/null代表空设备。)
在这里插入图片描述

启动后会刷一波日志然后看到如下信息:

[2019-02-28 10:49:13,727] INFO [ExpirationReaper-1-Rebalance]: Starting (kafka.server.DelayedOperationPurgatory$ExpiredOperationReaper)
[2019-02-28 10:49:14,551] INFO [GroupCoordinator 1]: Starting up. (kafka.coordinator.group.GroupCoordinator)
[2019-02-28 10:49:14,600] INFO [GroupCoordinator 1]: Startup complete. (kafka.coordinator.group.GroupCoordinator)
[2019-02-28 10:49:14,866] INFO [GroupMetadataManager brokerId=1] Removed 0 expired offsets in 228 milliseconds. (kafka.coordinator.group.GroupMetadataManager)
[2019-02-28 10:49:15,019] INFO [ProducerId Manager 1]: Acquired new producerId block (brokerId:1,blockStartProducerId:0,blockEndProducerId:999) by writing to Zk with path version 1 (kafka.coordinator.transaction.ProducerIdManager)
[2019-02-28 10:49:15,143] INFO [TransactionCoordinator id=1] Starting up. (kafka.coordinator.transaction.TransactionCoordinator)
[2019-02-28 10:49:15,279] INFO [TransactionCoordinator id=1] Startup complete. (kafka.coordinator.transaction.TransactionCoordinator)
[2019-02-28 10:49:15,317] INFO [Transaction Marker Channel Manager 1]: Starting (kafka.coordinator.transaction.TransactionMarkerChannelManager)
[2019-02-28 10:49:18,420] INFO [/config/changes-event-process-thread]: Starting (kafka.common.ZkNodeChangeNotificationListener$ChangeEventProcessThread)
[2019-02-28 10:49:18,631] INFO [SocketServer brokerId=1] Started processors for 1 acceptors (kafka.network.SocketServer)
[2019-02-28 10:49:18,690] INFO Kafka version : 2.1.1 (org.apache.kafka.common.utils.AppInfoParser)
[2019-02-28 10:49:18,709] INFO Kafka commitId : 21234bee31165527 (org.apache.kafka.common.utils.AppInfoParser)
[2019-02-28 10:49:18,713] INFO [KafkaServer id=1] started (kafka.server.KafkaServer)
[2019-02-28 10:59:14,552] INFO [GroupMetadataManager brokerId=1] Removed 0 expired off

也可以用命令验证一下:

[root@localhost kafka_2.11-2.1.1]# netstat -tunlp|egrep "(2181|9092)"
tcp6       0      0 :::9092                 :::*                    LISTEN      14019/java          
tcp6       0      0 :::2181                 :::*                    LISTEN      11938/java          
[root@localhost kafka_2.11-2.1.1]# 

5.创建一个topic

创建一个名为“wangtest”的Topic,只有一个分区和一个备份:

[root@localhost bin]# ./kafka-topics.sh --create --zookeeper xx.xx.xx.xx:2181 --replication-factor 1 --partitions 1 --topic wangtest
Created topic "wangtest".
[root@localhost bin]# 

查询一下topic

[root@localhost bin]# ./kafka-topics.sh --list --zookeeper xx.xx.xx.xx:2181
wangtest
[root@localhost bin]# 

6.发送消息

我们发一下消息测试一下:

[root@localhost bin]# ./kafka-console-producer.sh --broker-list xx.x.xx.xx:9092 --topic wangtest
>this is a test message from wangwang
>from itqunqi^H^H^H^H^H^[[3~
>Ties^H^H^H^H
>this test from itu^H
>this test from ityunqing
>

7.消费消息

在另一个终端,可以消费刚才写入的消息

[root@localhost bin]# ./kafka-console-consumer.sh --bootstrap-server xx.xx.xx.xx:9092 --topic wangtest --from-beginning

this is a test message from wangwang
from itqunqi
Ties
this test from itu
this test from ityunqing

资料:http://orchome.com/6

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/184858.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Linux中hexdump命令「建议收藏」

    Linux中hexdump命令「建议收藏」Linux中hexdump命令简介hexdump主要用来查看“二进制”文件的十六进制编码。*注意:它能够查看任何文件,不限于与二进制文件。*语法hexdump[选项][文件]…选项-nlength:格式化输出文件的前length个字节-C:输出规范的十六进制和ASCII码-b:单字节八进制显示-c:单字节字符显示-d:双字节十进制显示-o:双字节八进制显示-…

    2022年9月21日
    0
  • vue django mysql_Python MySQL

    vue django mysql_Python MySQL工作之余断断续续根据网上找到的教程进行环境搭建,搭建了多个。但是一直没有一个整体概念,到底该先做什么,后做什么,操作一步后,结果应该是怎样另外,网上的教程都是直接用命令行操作,用pycharm又应该怎么弄呢环境搭建好以后,应该怎么分目录结构,应该先从哪里的代码开始写,写了以后,又需要做哪些配置这些问题一直困扰着我,所以我决定边学边记录整理。也希望能帮助同为初学者的你少走一些…

    2022年8月28日
    3
  • sql语句练习50题(Mysql版)

    sql语句练习50题(Mysql版)习题来源于网络,sql语句是自己写的。欢迎指正。表名和字段–1.学生表Student(s_id,s_name,s_birth,s_sex)–学生编号,学生姓名,出生年月,学生性别–2.课程表Course(c_id,c_name,t_id)––课程编号,课程名称,教师编号–3.教师表Teacher(t_id,t_name)–教师编号,教师姓名–4

    2022年10月6日
    0
  • c语言解析xml文件「建议收藏」

    c语言解析xml文件「建议收藏」#include”stdafx.h”#include#include”Mytext.h”#include#include#include#include#include#include#include#include#include#includeusingnamespacestd;#pragmacomment(lib,”Oleac

    2022年7月14日
    65
  • 104键键盘布局高清示意图「建议收藏」

    104键键盘布局高清示意图「建议收藏」转载于:https://www.cnblogs.com/sangzs/p/10643850.html

    2022年10月24日
    0
  • DNS负载均衡 例子

    DNS负载均衡 例子在host文件中加入192.168.8.240 centos1and2192.168.8.204 centos1and2完成。

    2022年7月14日
    12

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号