kafka 3.0.0 Windows下启动不了的问题及kafka使用教程

kafka 3.0.0

windows环境下:
.\bin\windows\kafka-server-start.bat .\config\server.properties
启动报错如下:

 ERROR Error while writing to checkpoint file D:\kafka\kafka_2.12-3.0.0\logs\log-start-offset-checkpoint (kafka.server.LogDirFailureChannel)
java.nio.file.AccessDeniedException: D:\kafka\kafka_2.12-3.0.0\logs

经过尝试发现kafka3.0.0版本因自身问题在windows环境下启动存在问题,可将版本升至3.1.0
在这里插入图片描述

启动配置:

因kafka3.0之后内置zk所以不需要额外下载

第一步:配置文件修改

server.properties

# broker.id 要保持唯一,只启动一台的话则不需修改
# The id of the broker. This must be set to a unique integer for each broker.
broker.id=0
# 修改日志存放位置
# A comma separated list of directories under which to store log files
log.dirs=D://kafka//kafka_2.13-3.1.0//kafka-logs
# 修改zk连接地址,默认本机启动则不需要修改
# 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

zookeeper.properties

# 修改日志存放位置
# 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=D://kafka//kafka_2.13-3.1.0//zookeeper-logs

第二步:启动

要先启动zk
启动语句

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

然后启动kafka
启动语句

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

使用教程

进入/bin/windows 目录下通过下面的命令创建topic

kafka-topics.bat --bootstrap-server localhost:9092 --create --replication-factor 3 --partitions 1 --topic test

partitions:分区
replication-factor:设置分区副本

查看当前有哪些topic

kafka-topics.bat --bootstrap-server localhost:9092 --list

查看某个topic的详细信息

kafka-topics.bat --bootstrap-server localhost:9092 --describe --topic test

修改topic的配置

kafka-topics.bat --bootstrap-server localhost:9092 --alter --topic test --partitions 3

删除topic会报错,此时停掉所有的cmd,然后将日志文件删除,重新启动可以解决

启动生产者命令/bin/window 目录下

kafka-console-producer.bat --broker-list localhost:9092 --topic test

启动消费者命令/bin/window 目录下

kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic test --from-beginning

然后就可以快乐的发送啦
在这里插入图片描述
在这里插入图片描述

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值