kafka 系列一(windows 安装)
1.kafka 官网
http://kafka.apache.org/ 点击下载如下文件
2. 首先确保系统已经安装了 java 环境 可以用dos命令 java -version 查看
3.将下载的kafka 解压到对应的文件夹
F:\kafka\kafka_src 此文件夹是我解压的目录
4.修改kafka 配置文件的日志地址默认是linux的地址,修改成windows
1.修改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=F:\kafka\kafka_src\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=0
# Disable the adminserver by default to avoid port conflicts.
# Set the port to something non-conflicting if choosing to enable this
admin.enableServer=false
# admin.serverPort=8080
2.修改kafka 的 server.propertis
# A comma separated list of directories under which to store log files
#修改这里的文件地址
log.dirs=F:\kafka\kafka_src\logs\kafka-logs
5.开始启动zookeeper 后面都使用windows 的powershell
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.properties
注意红框处,否则会导致闪退,因为官方的文档是linux的教程。windows 脚本用.bat,位置在 bin\windows 下
6 启动kafka
.\bin\windows\kafka-server-start.bat .\config\server.properties
7.测试是否启动成功
创建一个主题
.\bin\windows\kafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
查看主题
.\bin\windows\kafka-topics.bat --list --bootstrap-server localhost:9092
8 环境变量设置,类似java 设置系统环境变量
9.查看环境变量是否配置成功
在任意文件下执行kafka 的命令
C:\Users\Administrator>kafka-topics.bat --list --bootstrap-server localhost:9092
返回
test