windows环境安装运行kafka

news2024/9/23 12:50:18

一、配置java环境变量
1、下载安装包

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

2、添加系统变量:JAVA_HOME=D:\Program Files (x86)\Java\jdk1.8.0_144

二、安装zooKeeper
1、 下载安装包
http://zookeeper.apache.org/releases.html#download

2、 解压并进入zooKeeper目录:E:\kafka\zookeeper-3.5.10\conf

3、 将“zoo_sample.cfg”重命名为“zoo.cfg”

4、 打开“zoo.cfg”找到并编辑dataDir= E:\kafka\zookeeper-3.5.10\data

5、 添加系统变量:ZOOKEEPER_HOME= E:\kafka\zookeeper-3.5.10

6、 编辑path系统变量,添加路径:%ZOOKEEPER_HOME%\bin

7、 在zoo.cfg文件中使用默认端口2181,使用一个未被占用的端口,如8085,修改admin.serverPort=8085

zoo.cfg完成的配置如下

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=E:\\kafka\\zookeeper-3.5.10\\data
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
admin.serverPort=8085

8、 打开新的cmd,输入“zkServer“,运行zookeeper

9、 命令行提示如下:说明本地zookeeper启动成功

在这里插入图片描述

注意:不要关了这个窗口

三、安装Kafka
1、 下载安装包
http://kafka.apache.org/downloads
注意要下载二进制版本

2、 解压并进入Kafka目录,E:\kafka\kafka_2.11

3、 进入config目录找到文件server.properties并打开

4、 找到并编辑log.dirs= E:\kafka\kafka_2.11\kafka-logs

5、 端口使用默认的 zookeeper.connect=localhost:2181
Kafka会按照默认,在9092端口上运行,并连接zookeeper的默认端口:2181

设置允许自动创建topic
auto.create.topics.enable=true

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.

# 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. It will get the value returned from 
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
#listeners=PLAINTEXT://:9092

# Hostname and port the broker will advertise to producers and consumers. If not set, 
# it uses the value for "listeners" if configured.  Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
#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=E:\\kafka\\kafka_2.11\\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 for 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=30000

############################# 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=localhost:2181

# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000


############################# 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
auto.create.topics.enable=true

6、 进入Kafka安装目录D:\Kafka\kafka_2.12,按下Shift+右键,选择“打开命令窗口”选项,打开命令行,输入:

.\bin\windows\kafka-server-start.bat .\config\server.properties

在这里插入图片描述

注意:注意:不要关了这个窗口,启用kafka前请确保zooKeeper实例已经准备好并开始运行

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【Java笔试强训 34】

🎉🎉🎉点进来你就是我的人了博主主页:🙈🙈🙈戳一戳,欢迎大佬指点! 欢迎志同道合的朋友一起加油喔🤺🤺🤺 目录 一、选择题 二、编程题 🔥收件人列…

eks实践案例

Eks: ami-0c23197c88296c1b5 eks集群: 拉面 - 知乎 https://blog.csdn.net/saynaihe/category_12204222.html 什么是 Amazon EKS? - Amazon EKS kubectl 使用指南 https://zhuanlan.zhihu.com/p/364994610 k8s HPA自动伸缩 手把手教你 K8…

centOS7忘记登录密码该如何重新修改登录密码

文章目录 前言一、重新修改登录密码1.1、第一步1.2、第二步1.3、第三步1.4、第四步1.5、第五步1.6、第六步1.7、第七步1.8、第八步 前言 忘记密码并不可怕,只要学会方法,密码随时都可以找回。 一、重新修改登录密码 1.1、第一步 当打开centOS7之后忘记…

flutter系列之:做一个修改组件属性的动画

文章目录 简介flutter中的动画widgetAnimatedContainers使用举例总结 简介 什么是动画呢?动画实际上就是不同的图片连续起来形成的。flutter为我们提供了一个AnimationController来对动画进行详尽的控制,不过直接是用AnimationController是比较复杂的&a…

Colab使用教程(自己胡乱弄了半天,发现不行,还是得学一下)

文章目录 在google云盘中创建笔记本,并红设置笔记本的运行环境常见设置挂载云硬盘更改工作目录移动训练数据防止断链设置方法一、控制台设置方法二、安装Colab Alive 训练结果保存到硬盘中相关链接 在google云盘中创建笔记本,并红 云盘链接,…

K公司项目文件管理系统的分析与设计_kaic

摘 要 2020年的新冠疫情促进了线上办公市场的发展,加快了企业进入全面数字化时代的脚步。办公自动化是当今的大趋势,越来越多的企业采用电子文档的形式存储内外部资料。K公司是一家致力于为政府和企业提供数据安全服务的小型B2B企业,公司承…

Nessus 10.5 Auto Install for macOS Ventura(自动化安装 Nessus 试用版)

发布 Nessus 试用版自动化安装程序,支持 macOS Ventura、RHEL 9 和 Ubuntu 22.04 请访问原文链接:https://sysin.org/blog/nessus-auto-install-for-macos/,查看最新版。原创作品,转载请保留出处。 作者主页:sysin.o…

STM32输入捕获之快速构建频率计

简介:配置好STM32 CUBE IDE后只需要额外7行代码就可以构建一个频率计,目前只计算测频,占空比测量需要加入下降沿捕获标记(暂时没做)。 一、原理 频率:单位时间内完成周期性变化的次数,f 1/T。…

如何裁剪图片大小尺寸?

如何裁剪图片大小尺寸?平时我们在工作或者学习的时候,会经常需要将图片上传到不同的网站或者平台上,然而上传的时候经常会受到尺寸的限制,有时候尺寸太大就需要变小,为了确保上传成功,我们需要将图片进行裁…

Vue Router 最新版惊现使用 BUG

就在刚刚,当我在 写 Vue3 的项目的时候,使用到了 Vue Router 4 的最新版本(4.1.6),然而在使用过程中,发现了一个使用问题,起初我还以为,是我这边的代码逻辑有问题,然而在…

九联UNT402A_当贝纯净桌面-卡刷固件包-内有教程

九联UNT402A_当贝纯净桌面-卡刷固件包-内有教程 特点: 1、适用于对应型号的电视盒子刷机; 2、开放原厂固件屏蔽的市场安装和u盘安装apk; 3、修改dns,三网通用; 4、大量精简内置的没用的软件,运行速度提…

【Java笔试强训 33】

🎉🎉🎉点进来你就是我的人了博主主页:🙈🙈🙈戳一戳,欢迎大佬指点! 欢迎志同道合的朋友一起加油喔🤺🤺🤺 目录 一、选择题 二、编程题 🔥剪花布条…

虹科新闻 | HKATTO推出FastFrame™ 第四代智能以太网适配器系列

ATTO Technology, Inc. 是 35 多年来为数据密集型计算环境提供网络、存储连接和基础设施解决方案的全球领导者,今天宣布推出其新的FastFrame™ 第四代以太网产品系列智能网卡。 第四代FastFrame SmartNICs 产品线具有四种独特的型号,产品线涵盖 10/25/40…

OmniVerse + ChatGPT = 智能3D建模

全球各行各业对 3D 世界和虚拟环境的需求呈指数级增长。 3D 工作流是工业数字化的核心,开发实时模拟以测试和验证自动驾驶汽车和机器人,运行数字孪生以优化工业制造,并为科学发现铺平新道路。 今天,3D 设计和世界构建仍然是高度手…

IS200TPROH1BCB用于工业应用和电力分配等。高压型隔离开关用于变电站

​ IS200TPROH1BCB用于工业应用和电力分配等。高压型隔离开关用于变电站 什么是隔离器,它与断路器有何不同 什么是隔离器,为什么要使用隔离器 隔离器是一种开关装置,它可以手动或自动操作,隔离一部分电能。隔离器可用于在无负载情…

Python 实验四 常用数据结构(2)

6.某企业为职工发放奖金:如果入职超过5年,且销售业绩超过15000元的员工,奖金比例为0.2;销售业绩超过10000元的员工,奖金比例为0.15;销售业绩超过5000元的员工,奖金比例为0.1;其他奖金…

【25】核心易中期刊推荐——智能控制机器人

🚀🚀🚀NEW!!!核心易中期刊推荐栏目来啦 ~ 📚🍀 核心期刊在国内的应用范围非常广,核心期刊发表论文是国内很多作者晋升的硬性要求,并且在国内属于顶尖论文发表,具有很高的学术价值。在中文核心目录体系中,权威代表有CSSCI、CSCD和北大核心。其中,中文期刊的数…

【PWN · ret2libc】ret2libc2

ret2libc1的略微进阶——存在systemplt但是不存在“/bin/sh”怎么办? 目录 前言 python3 ELF 查看文件信息 strings 查看寻找"/bin/sh" IDA反汇编分析 思路及实现 老规矩,偏移量 offset EXP编写 总结 前言 经过ret2libc1的洗礼&a…

MyBatis介绍和MyBatis的增删改查xml配置--日志输出-查看 SQL

目录 MyBatis(简化数据库操作的持久层 框架) 官方文档 Maven 仓库 传统的 Java 程序操作 DB 分析 工作示意图 传统方式问题分析(如上) 引出 MyBatis MyBatis 工作原理示意图 MyBatis 快速入门 快速入门需求说明 创建 mybatis 数据库 - monster 表 MyBatis 快速入门 …

【需求响应】基于进化算法的住宅光伏电池系统需求响应研究(Matlab代码实现)

💥💥💞💞欢迎来到本博客❤️❤️💥💥 🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。 ⛳️座右铭&a…