自己玩KAFKA 版本 kafka_2.13-3.2.1

news/2024/4/25 15:50:49/文章来源:https://www.cnblogs.com/alexgl2008/p/16626885.html

     好久没有研究Kafka了,重新摸起来

自己在虚机中  、环境JDK8 + kafka_2.13-3.2.1

不太建议使用Windows,除非迫不得已,毕竟Kafka的使用场景都是高并发场景,Windows服务器不合适。

(1)下载最新版本

     https://kafka.apache.org/downloads

         各位同学,请注意,因为是开源的软件中间件,所以一定要注意版本号,最新的版本据说抛弃了Zookeeper了,作为使用者,我就不仔细检查和测试这个说法了。

     直接使用就好了,只要和老版本的功能一致,就可以相信了。

 

(2)参考网址

         感谢BAIDU,感谢万能的网友,我参考了

 https://blog.csdn.net/iku_whf/article/details/125432794

 https://blog.csdn.net/weixin_42854904/article/details/118424361 

官方推荐如果kafka版本大于等于2.2使用–bootstrap-server替代–zookeeper

 

(3)开始吧

下载最新版

 

 

 zookeeper.properties 内容

 

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
# 
#    http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# the directory where the snapshot is stored.
dataDir=/tmp/zookeeper
# the port at which the clients will connect
clientPort=2181
# disable the per-ip limit on the number of connections since this is a non-production config
maxClientCnxns=60
# Disable the adminserver by default to avoid port conflicts.
# Set the port to something non-conflicting if choosing to enable this
admin.enableServer=true
admin.serverPort=8082###add by 20220830
# 默认是true
# standaloneEnabled=true  
tickTime=2000
initLimit=10

 

 server.properties 内容

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.#
# This configuration file is intended for use in ZK-based mode, where Apache ZooKeeper is required.
# See kafka.server.KafkaConfig for additional details and defaults
############################## Server Basics ############################## The id of the broker. This must be set to a unique integer for each broker.
broker.id=0############################# Socket Server Settings ############################## The address the socket server listens on. If not configured, the host name will be equal to the value of
# java.net.InetAddress.getCanonicalHostName(), with PLAINTEXT listener name, and port 9092.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://192.168.226.141:9092# Listener name, hostname and port the broker will advertise to clients.
# If not set, it uses the value for "listeners".
#advertised.listeners=PLAINTEXT://your.host.name:9092# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details
#listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL# The number of threads that the server uses for receiving requests from the network and sending responses to the network
num.network.threads=3# The number of threads that the server uses for processing requests, which may include disk I/O
num.io.threads=8# The send buffer (SO_SNDBUF) used by the socket server
socket.send.buffer.bytes=102400# The receive buffer (SO_RCVBUF) used by the socket server
socket.receive.buffer.bytes=102400# The maximum size of a request that the socket server will accept (protection against OOM)
socket.request.max.bytes=104857600############################# Log Basics ############################## A comma separated list of directories under which to store log files
log.dirs=/tmp/kafka-logs# The default number of log partitions per topic. More partitions allow greater
# parallelism for consumption, but this will also result in more files across
# the brokers.
num.partitions=1# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
# This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1############################# Internal Topic Settings  #############################
# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state"
# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3.
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1############################# Log Flush Policy ############################## Messages are immediately written to the filesystem but by default we only fsync() to sync
# the OS cache lazily. The following configurations control the flush of data to disk.
# There are a few important trade-offs here:
#    1. Durability: Unflushed data may be lost if you are not using replication.
#    2. Latency: Very large flush intervals may lead to latency spikes when the flush does occur as there will be a lot of data to flush.
#    3. Throughput: The flush is generally the most expensive operation, and a small flush interval may lead to excessive seeks.
# The settings below allow one to configure the flush policy to flush data after a period of time or
# every N messages (or both). This can be done globally and overridden on a per-topic basis.# The number of messages to accept before forcing a flush of data to disk
#log.flush.interval.messages=10000# The maximum amount of time a message can sit in a log before we force a flush
#log.flush.interval.ms=1000############################# Log Retention Policy ############################## The following configurations control the disposal of log segments. The policy can
# be set to delete segments after a period of time, or after a given size has accumulated.
# A segment will be deleted whenever *either* of these criteria are met. Deletion always happens
# from the end of the log.# The minimum age of a log file to be eligible for deletion due to age
log.retention.hours=168# A size-based retention policy for logs. Segments are pruned from the log unless the remaining
# segments drop below log.retention.bytes. Functions independently of log.retention.hours.
#log.retention.bytes=1073741824# The maximum size of a log segment file. When this size is reached a new log segment will be created.
log.segment.bytes=1073741824# The interval at which log segments are checked to see if they can be deleted according
# to the retention policies
log.retention.check.interval.ms=300000############################# Zookeeper ############################## Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect=192.168.226.141:2181# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=18000############################# Group Coordinator Settings ############################## The following configuration specifies the time, in milliseconds, that the GroupCoordinator will delay the initial consumer rebalance.
# The rebalance will be further delayed by the value of group.initial.rebalance.delay.ms as new members join the group, up to a maximum of max.poll.interval.ms.
# The default value for this is 3 seconds.
# We override this to 0 here as it makes for a better out-of-the-box experience for development and testing.
# However, in production environments the default value of 3 seconds is more suitable as this will help to avoid unnecessary, and potentially expensive, rebalances during application startup.
group.initial.rebalance.delay.ms=0

 

  server.properties  修改的地方

 

 

zookeeper.properties 修改的地方

 

 

(1) 启动

启动顺序,先zookeeper ,再kafka

sh bin/zookeeper-server-start.sh config/zookeeper.properties

sh bin/kafka-server-start.sh config/server.properties

请一定注意路径,否则启动报错

(2)创建Topic

sh kafka-topics.sh --create --bootstrap-server 192.168.226.140:9092 --replication-factor 1 --partitions 1 --topic test7

(3)检查创建是否成功

sh kafka-topics.sh --list  --bootstrap-server 192.168.226.141:9092

如果反馈是 test7 ,说明一切OK了。

 

小结:

(1)启动顺序、路径很重要,没有zookeeper直接启动Kafka会报错。

(2)网上说新版本的kafka已经包含了Zookeeper ,个人操作下来看,Kafka把它包入了,但是还是分开启动的,并没有说是完全放弃Zookeeper不用

(3)以前的版本创建、查看Topic 用的 zookeeper ,实际我的这个版本中,是不吃的,报错,换成 bootstrap-server 就OK 了

(4)网上的什么查看Zookeeper的工具,未必适合所有版本;看情况再去浪费时间;

(5)Zookeeper的配置文件中, 默认 standaloneEnabled=true ,可以不用这个参数,但是如果改成false,一定会报错;

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_3000.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

图像处理工具推荐

如果您正好想要一款方便快捷的图像照片处理工具,那就来试试这款名为Movavi Picverse Photo Editor的编辑软件。Movavi Picverse Photo Editor Mac优化大家的图像处理步骤,可以花费更多的时间拍摄和更少的修饰时间,Movavi Picverse Photo Editor是每一位初学者和专业摄影师的…

3 个你不知道的 Python 库

3 个你不知道的 Python 库 Python 是那些从世界各地获得巨大贡献的社区之一,并且有一个我们不知道的无可挑剔的集合。让我们深入挖掘并了解三个新的 python 库。 人脸识别 数据科学和人工智能位于当今世界的领先技术之上。您是否知道已经有一个 Python 库可以为您识别人脸并且…

P1231 教辅的组成

求三重匹配最大匹配数。 \(N\leq 10^5\),\(M_1\), \(M_2 \leq 20000\)。首先要承认,这一题属于P3254的延申,可以先复习一下P3254的题解。 然而这一题又和P3254不太一样 (不就是从两条边匹配变成三条边吗) 那就错了!看上面这张图,如果用最大流来跑,最后答案会是2条,但 …

方正璞华入选“火炬智能制造服务商”和“智能制造产品服务”!

方正璞华协助客户实现数字化运营管理和工业互联网产业升级。日前,经初审、专家评审、公示等程序,凭借多年在工业领域的实践经验与优质产品,方正璞华成功入选“火炬智能制造服务商”和“智能制造产品服务”,标志着厦门火炬高新区对方正璞华信息企业数字化转型赋能实力的充分…

[CTF]2022 CNSS夏令营 WebReverse 复现wp

写在前面 很有趣的一次(大)学前教育, 作为一个22级泥电新生, 对CTF网安类的东西完全是一窍不通, 进新生群然后就被拉进来Van了. 结果没想到还挺好玩(可能是我这几天太无聊了), 边学边打居然还能霸几天榜一, 满足了. 其实我就只是总榜高, 细分分区我其实不是很行的, 毕竟都是现学…

JUC学习23:理解JMM

JUC学习23:理解JMM面试题:请你谈谈你对Volatile的理解:Volatile是Java虚拟机提供轻量级的同步机制;1,保证可见性(JMM);2,不保证原子性;3,禁止指令重排; 什么是JMM:JMM:Java内存模型,不存在的东西,概念,是一种约定;关于JMM的一些同步约定:线程解锁前:必须把…

channel与range、select

channel与range、selectpackage mainimport "fmt"func main() {c := make(chan int)go func() {for i := 0; i < 5; i++ {c <- i}//close可以关闭一个channelclose(c)}()//可以使用range来迭代不断操作channelfor data := range c {fmt.Println(data)}fmt.Prin…

channel

channel有缓冲与无缓冲同步问题package mainimport ("fmt""time" )func main() {c := make(chan int, 3) //带有缓冲的channelfmt.Println("len(c) = ", len(c), ", cap(c)", cap(c))go func() {defer fmt.Println("子go程结束&q…

selenium 常用操作汇总

使用selenium1、查看Chrome版本去下载浏览器驱动 驱动下载链接2、selenium官方网站 官方文档 selenium通信原理对于每一条Selenium脚本,一个http请求会被创建并且发送给浏览器的驱动 浏览器驱动中包含了一个HTTP Server,用来接收这些http请求 HTTP Server接收到请求后根据请…

不想当Window的Dialog不是一个好Modal,弹窗翻身记

Windows的灵魂是什么?当然是Window,当方便快捷的多窗口进入人们视野的时候,大家无不为之惊呼太好用了!!弹窗是我们熟视无睹的一种交互方式,经常用到,但从没好好想过这种交互行为背后的意义... 弹窗是Windows的灵魂 Windows的灵魂是什么?当然是Window,当方便快捷的多窗…

工具 -- git 汉化

说明 来源转载 https://blog.csdn.net/mansir123/article/details/121692125Git GUI汉化包来源 https://github.com/stayor/git-gui-zh转载 https://www.cnblogs.com/chenghu/articles/12678500.html1、git bash 汉化 这个Git bash本身就支持中文,只需要在打开Git bash后命令窗…

好多不懂的和bug

1、知道了MD5, 2、知道了validate是干什么的,(validate中的rules中编写验证规则,规范输入),可以在管理员在网站修改数据的时候对输入进行限制。1 <script type="text/javascript">2 $(function(){3 $("#addForm").validate({4 rul…

DevTools 无法加载来源映射:无法加载 webpack net::ERR_UNKNOWN_URL_SCHEME

问题:DevTools 无法加载来源映射:无法加载 webpack:///node_modules/element-plus/es/components/notification/src/notification.mjs.map 的内容:Fetch through target failed: Unsupported URL scheme; Fallback: HTTP 错误:状态代码 404,net::ERR_UNKNOWN_URL_SCHEME 当…

JAVA进阶--static、工具类、单例、继承--2022年8月28日

第一节 static静态关键字1、成员变量的分类和访问分别是什么样的?静态成员变量(有static修饰,属于类,加载一次,可以被共享访问)访问格式:类名.变量名(推荐)对象名.变量名(不推荐)实例成员变量(无static修饰,属于对象)访问格式:对象名.变量名2、两种成员变量各自…

QA特辑 | 看了这场直播,我找到了设备指纹“从不说谎”的原因

除了身份证外,设备指纹可能是唯一一个可以证明你是谁的方法。 究其原因,就在于设备指纹的唯一性和稳定性。 8月 25 日下午 15 点,顶象技术总监杜威就设备指纹的唯一性和稳定性的核心算法展开分享。直播过程中,我们也收到了一系列关于设备指纹唯一性稳定性核心算法的疑问,现…

YBTOJ [树状数组] 二进制

哇咔咔,此乃真好题!这种东西当然要抢个榜首辣qaq。 Solution 首先不带 \(+x\) 的做法,相信大家都会,维护一下全局二进制每一位 \(1\) 的个数,把 \(y\) 二进制拆分一下,就知道答案了。 这个 \(+x\) 真滴很恶心啊! 考虑这样一个事实,非常滴实用: 对于一个 \(x\) \(and\)…

科普达人丨一图看懂安全组

建议收藏安全组是一种虚拟防火墙,通过安全组规则控制 ECS 实例出/入方向的流量,保障云服务器的安全。本文将通过介绍安全组的工作原理、功能、默认安全组和规则,以及快速上手使用安全组的操作等方面的介绍,您对于安全组有一个全面的了解,帮助您更好、更安全地开展业务上云…

京东云PostgreSQL在GIS场景的应用分享

在地图或地理信息有关的场景里,地址关键词的检索尤其重要。比如打开百度地图,想要查询某个位置的信息“北京市海淀区清华东路17号中国农业大学”,往往我们输入的是关键词“中国农业大学”而不是精确到街道的详细地址信息。在地图或地理信息有关的场景里,地址关键词的检索尤…

超全的正则表达式速查手册

一、校验数字的表达式 数字:^[0-9]*$ n位的数字:^\d{n}$ 至少n位的数字:^\d{n,}$ m-n位的数字:^\d{m,n}$ 零和非零开头的数字:^(0|[1-9][0-9]*)$ 非零开头的最多带两位小数的数字:^([1-9][0-9]*)+(.[0-9]{1,2})?$ 带1-2位小数的正数或负数:^(\-)?\d+(\.\d{1,2})?$ 正…

HCIA学习笔记二十六:手工负载分担模式二层链路聚合

一、链路聚合的应用场景• 链路聚合一般部署在核心结点,以便提升整个网络的数据吞吐量。 二、链路聚合• 链路聚合能够提高链路带宽,增强网络可用性,支持负载分担。 三、链路聚合模式• 手工负载分担模式下所有活动接口都参与数据的转发,分担负载流量。 • LACP模式支持链路…