kafka 系列一(windows 安装)
1.kafka 官網
http://kafka.apache.org/ 點擊下載如下文件
2. 首先確保系統已經安裝了 java 環境 可以用dos命令 java -version 查看
3.將下載的kafka 解壓到對應的文件夾
F:kafkakafka_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:kafkakafka_srczookeeper # 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:kafkakafka_srclogskafka-logs
5.開始啟動zookeeper 后面都使用windows 的powershell
.inwindowszookeeper-server-start.bat .configzookeeper.properties
注意紅框處,否則會導致閃退,因為官方的文檔是linux的教程。windows 腳本用.bat,位置在 binwindows 下
6 啟動kafka
.inwindowskafka-server-start.bat .configserver.properties
7.測試是否啟動成功
創建一個主題
.inwindowskafka-topics.bat --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
查看主題
.inwindowskafka-topics.bat --list --bootstrap-server localhost:9092
8 環境變量設置,類似java 設置系統環境變量
9.查看環境變量是否配置成功
在任意文件下執行kafka 的命令
C:UsersAdministrator>kafka-topics.bat --list --bootstrap-server localhost:9092
返回
test
總結
以上是生活随笔為你收集整理的kafka 系列一(windows 安装)的全部內容,希望文章能夠幫你解決所遇到的問題。