windows 下部署kafka 日记 转

windows 下部署kafka 日记 转
一、下载
去apache 的官网(http://kafka.apache.org/downloads.html)下载最新的二进制版的压
缩包。目前的最新版本是kafka_2.11-0.8.2.1.tgz。
二、解压
直接解压到D 盘根目录下。
三、修改配置文件
注意版本不同,可能配置文件不同。请参照实际情况修改。
1.修改log4j.properties 文件中的“kafka.logs.dir=logs ”为“kafka.logs.dir=/tmp/logs”。
2.修改test-log4j.properties 文件中的4 处“ File=logs/server.log ” 为
“File=/tmp/logs/server.log”。
3.复制config/server.properties 为
第一个节点server-9093.properties,修改如下内容:
broker.id=9093
port=9093
host.name=localhost
log.dirs=/tmp/kafka-logs-9093
4.复制config/server.properties 为
第一个节点server-9094.properties,修改如下内容:
broker.id=9094
port=9094
host.name=localhost
log.dirs=/tmp/kafka-logs-9094
四、修改启动文件
删除所有不能在windows 下运行的*.sh 文件。复制kafka_2.11-0.8.2.1/bin/windows/*.bat
到kafka_2.11-0.8.2.1/bin 目录下。
1.修改zookeeper-server-start.bat 文件中的“%~dp0../../”为“%~dp0/../”。
2.修改kafka-server-start.bat 文件中的“%~dp0../../”为“%~dp0/../”。
3.修改kafka-run-class.bat 文件中的“pushd %~dp0..\..”为“pushd %~dp0”。
修改kafka-run-class.bat 文件中的“%BASE_DIR%/config”为“%BASE_DIR%/../config”。
将kafka-run-class.bat 文件中的如下内容:
rem Classpath addition for kafka-core dependencies
for %%i in (%BASE_DIR%\core\build\dependant-libs-%SCALA_VERSION%\*.jar) do (
call :concat %%i
)
rem Classpath addition for kafka-perf dependencies
for %%i in (%BASE_DIR%\perf\build\dependant-libs-%SCALA_VERSION%\*.jar) do (
call :concat %%i
)
rem Classpath addition for kafka-clients
for %%i in (%BASE_DIR%\clients\build\libs\kafka-clients-*.jar) do (
call :concat %%i
)
rem Classpath addition for kafka-examples
for %%i in (%BASE_DIR%\examples\build\libs\kafka-examples-*.jar) do (
call :concat %%i
)
rem Classpath addition for contrib/hadoop-consumer
for %%i in (%BASE_DIR%\contrib\hadoop-consumer\build\libs\kafka-hadoop-consumer-*.jar)
do (
call :concat %%i
)
rem Classpath addition for contrib/hadoop-producer
for %%i in (%BASE_DIR%\contrib\hadoop-producer\build\libs\kafka-hadoop-producer-*.jar) do
(
call :concat %%i
)
rem Classpath addition for release
for %%i in (%BASE_DIR%\libs\*.jar) do (
call :concat %%i
)
rem Classpath addition for core
for %%i in (%BASE_DIR%\core\build\libs\kafka_%SCALA_BINARY_VERSION%*.jar) do (
call :concat %%i
)
修改为:
rem Classpath addition for release
for %%i in (%BASE_DIR%\..\libs\*.jar) do (
call :concat %%i
)
五、启动zookeeper
打开命令提示符窗口,在kafka_2.11-0.8.2.1/bin 目录下执行如下命令:
zookeeper-server-start ../config/zookeeper.properties
六、启动kafka
打开命令提示符窗口,在kafka_2.11-0.8.2.1/bin 目录下执行如下命令,启动第一个节点:
kafka-server-start.bat ..\config\server-9093.properties
打开命令提示符窗口,在kafka_2.11-0.8.2.1/bin 目录下执行如下命令,启动第二个节点:
kafka-server-start.bat ..\config\server-9094.properties
七、创建topic 批处理脚本  执行报错,不影响 。
打开命令提示符窗口,在kafka_2.11-0.8.2.1/bin 目录下执行如下命令:
kafka-topics.bat kafka.admin.TopicCommand %*
八、创建topic
打开命令提示符窗口,在kafka_2.11-0.8.2.1/bin 目录下执行如下命令(replication-factor
设置为kafka 节点数):
kafka-topics.bat --create --zookeeper localhost:2181 --replication-factor 2 --partitions 3 --topic
my-replicated-topic
九、查看topic 描述信息
打开命令提示符窗口,在kafka_2.11-0.8.2.1/bin 目录下执行如下命令:
kafka-topics.bat --describe --zookeeper localhost:2181 --topic my-replicated-topic
十、生产topic 消息
打开命令提示符窗口,在kafka_2.11-0.8.2.1/bin 目录下执行如下命令:
kafka-console-producer.bat --broker-list localhost:9093 --topic my-replicated-topic
启动成功后,即可在此窗口输入测试内容,回车后即可发送成功。
十一、消费topic 消息
打开命令提示符窗口, 在kafka_2.11-0.8.2.1/bin 目录下执行如下命令:
kafka-console-consumer.bat --zookeeper localhost:2181 --from-beginning --topic
my-replicated-topic
启动成功后,即可实时在此窗口看到生产的消息。
十二、未解决的异常信息
命令提示符还会输入一些异常信息,还未解决。但是目前看,不影响使用。
1. 启动kafka 时:
[2015-05-14 17:36:50,027] INFO Initiating client connection, connectString=localhost:2181
sessionTimeout=6000 [email protected] (org.apache.zo
okeeper.ZooKeeper)
[2015-05-14 17:36:50,058] INFO Opening socket connection to server 127.0.0.1/127.0.0.1:2181.
Will not attempt to authenticate using SASL (java.lang.SecurityException: 无
法定位登录配置) (org.apache.zookeeper.ClientCnxn)
[2015-05-14 17:36:50,063] INFO Socket connection established to 127.0.0.1/127.0.0.1:2181,
initiating session (org.apache.zookeeper.ClientCnxn)
[2015-05-14 17:36:50,110] INFO Session establishment complete on server
127.0.0.1/127.0.0.1:2181, sessionid = 0x14d51c7fc560000, negotiated timeout = 6000
(org.apache.zoo
keeper.ClientCnxn)
[2015-05-14 17:36:50,112] INFO zookeeper state changed (SyncConnected)
(org.I0Itec.zkclient.ZkClient)
[2015-05-14 17:36:50,273] INFO Loading logs. (kafka.log.LogManager)
[2015-05-14 17:36:50,323] INFO Recovering unflushed segment 0 in log my-replicated-topic-0.
(kafka.log.Log)
[2015-05-14 17:36:50,335] WARN Error when freeing index buffer (kafka.log.OffsetIndex)
java.lang.NullPointerException
at kafka.log.OffsetIndex.kafka$log$OffsetIndex$$forceUnmap(OffsetIndex.scala:301)
at kafka.log.OffsetIndex$$anonfun$resize$1.apply(OffsetIndex.scala:283)
at kafka.log.OffsetIndex$$anonfun$resize$1.apply(OffsetIndex.scala:276)
at kafka.utils.Utils$.inLock(Utils.scala:535)
at kafka.log.OffsetIndex.resize(OffsetIndex.scala:276)
at kafka.log.Log.loadSegments(Log.scala:179)
at kafka.log.Log.<init>(Log.scala:67)
at
kafka.log.LogManager$$anonfun$loadLogs$2$$anonfun$3$$anonfun$apply$7$$anonfun$apply$
1.apply$mcV$sp(LogManager.scala:142)
at kafka.utils.Utils$$anon$1.run(Utils.scala:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
[2015-05-14 17:36:50,344] INFO Completed load of log my-replicated-topic-0 with log end offset
1 (kafka.log.Log)
[2015-05-14 17:36:50,351] INFO Recovering unflushed segment 0 in log my-replicated-topic-1.
(kafka.log.Log)
[2015-05-14 17:36:50,355] WARN Error when freeing index buffer (kafka.log.OffsetIndex)
java.lang.NullPointerException
at kafka.log.OffsetIndex.kafka$log$OffsetIndex$$forceUnmap(OffsetIndex.scala:301)
at kafka.log.OffsetIndex$$anonfun$resize$1.apply(OffsetIndex.scala:283)
at kafka.log.OffsetIndex$$anonfun$resize$1.apply(OffsetIndex.scala:276)
at kafka.utils.Utils$.inLock(Utils.scala:535)
at kafka.log.OffsetIndex.resize(OffsetIndex.scala:276)
at kafka.log.Log.loadSegments(Log.scala:179)
at kafka.log.Log.<init>(Log.scala:67)
at
kafka.log.LogManager$$anonfun$loadLogs$2$$anonfun$3$$anonfun$apply$7$$anonfun$apply$
1.apply$mcV$sp(LogManager.scala:142)
at kafka.utils.Utils$$anon$1.run(Utils.scala:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
[2015-05-14 17:36:50,358] INFO Completed load of log my-replicated-topic-1 with log end offset
13 (kafka.log.Log)
[2015-05-14 17:36:50,363] INFO Recovering unflushed segment 0 in log my-replicated-topic-2.
(kafka.log.Log)
[2015-05-14 17:36:50,367] WARN Error when freeing index buffer (kafka.log.OffsetIndex)
java.lang.NullPointerException
at kafka.log.OffsetIndex.kafka$log$OffsetIndex$$forceUnmap(OffsetIndex.scala:301)
at kafka.log.OffsetIndex$$anonfun$resize$1.apply(OffsetIndex.scala:283)
at kafka.log.OffsetIndex$$anonfun$resize$1.apply(OffsetIndex.scala:276)
at kafka.utils.Utils$.inLock(Utils.scala:535)
at kafka.log.OffsetIndex.resize(OffsetIndex.scala:276)
at kafka.log.Log.loadSegments(Log.scala:179)
at kafka.log.Log.<init>(Log.scala:67)
at
kafka.log.LogManager$$anonfun$loadLogs$2$$anonfun$3$$anonfun$apply$7$$anonfun$apply$
1.apply$mcV$sp(LogManager.scala:142)
at kafka.utils.Utils$$anon$1.run(Utils.scala:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:662)
[2015-05-14 17:36:50,371] INFO Completed load of log my-replicated-topic-2 with log end offset
14 (kafka.log.Log)
2. 查看topic 描述信息时:
D:\kafka_2.11-0.8.2.1\bin>kafka-topics.bat --describe --zookeeper localhost:2181 --topic
my-replicated-topic
[2015-05-14 17:40:25,209] ERROR Unable to open socket to
0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181 (org.apache.zookeeper.ClientCnxnSocketNIO)
[2015-05-14 17:40:25,210] WARN Session 0x0 for server null, unexpected error, closing socket
connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
java.net.SocketException: Address family not supported by protocol family: connect
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:532)
at
org.apache.zookeeper.ClientCnxnSocketNIO.registerAndConnect(ClientCnxnSocketNIO.java:277)
at
org.apache.zookeeper.ClientCnxnSocketNIO.connect(ClientCnxnSocketNIO.java:287)
at org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:967)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1003)
Topic:my-replicated-topic PartitionCount:3 ReplicationFactor:2 Configs:
Topic: my-replicated-topic Partition: 0 Leader: 9093 Replicas:
9094,9093 Isr: 9093,9094
Topic: my-replicated-topic Partition: 1 Leader: 9093 Replicas:
9093,9094 Isr: 9093,9094
Topic: my-replicated-topic Partition: 2 Leader: 9093 Replicas:
9094,9093 Isr: 9093,9094
3. 生产topic 消息时
D:\kafka_2.11-0.8.2.1\bin>kafka-console-producer.bat --broker-list localhost:9093 --topic
my-replicated-topic
[2015-05-14 17:42:27,943] WARN Property topic is not valid (kafka.utils.VerifiableProperties)
4. 消费topic 消息时
D:\kafka_2.11-0.8.2.1\bin>kafka-console-consumer.bat --zookeeper localhost:2181
--from-beginning --topic my-replicated-topic
[2015-05-14 17:47:11,588] ERROR Unable to open socket to
0:0:0:0:0:0:0:1/0:0:0:0:0:0:0:1:2181 (org.apache.zookeeper.ClientCnxnSocketNIO)
[2015-05-14 17:47:11,589] WARN Session 0x0 for server null, unexpected error, closing socket
connection and attempting reconnect (org.apache.zookeeper.ClientCnxn)
java.net.SocketException: Address family not supported by protocol family: connect
at sun.nio.ch.Net.connect(Native Method)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:532)
at
org.apache.zookeeper.ClientCnxnSocketNIO.registerAndConnect(ClientCnxnSocketNIO.java:277)
at
org.apache.zookeeper.ClientCnxnSocketNIO.connect(ClientCnxnSocketNIO.java:287)
at org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:967)
at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1003)

安装过程遇到的问题:

1. kafka启动后提示

Unrecognized VM option ‘+UseCompressedOops‘
Could not create the Java virtual machine.

开始以为是内存大小的问题, 后来发现不是,是JDK的问题, 我用的32位centos,jdk1.6_24,  换成JDK1.7依然报错。

查看 bin/kafka-run-class.sh

找到

if [ -z "$KAFKA_JVM_PERFORMANCE_OPTS" ]; then
  KAFKA_JVM_PERFORMANCE_OPTS="-server  -XX:+UseCompressedOops -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:+CMSScavengeBeforeRemark -XX:+DisableExplicitGC -Djava.awt.headless=true"
fi

去掉-XX:+UseCompressedOops

JMX_PORT=9999 bin/kafka-server-start.sh config/server.properties &
启动成功

时间: 2024-10-20 11:08:23

windows 下部署kafka 日记 转的相关文章

QT程序在windows下部署发布

转载:http://www.cnblogs.com/Fan_Fan/archive/2010/05/29/1746860.html QT程序在windows下部署发布 以下包括了部分网上收集的,以及qt帮助里的内容(Deploying an Application on Qt/Windows) 首先,打开windows控制台,然后,找到vs安装目录下的bin里,执行 vcvars32.bat 这个脚本.执行完之后,vs需要的所有环境变量就已经设置好了. 我的环境是QT 4.3.3 + mingw

windows下部署免费ssl证书(letsencrypt)

随着网络的发展,网络安全也越来越重要,对于网站来说,从Http升级到https也是我们要做的首要事情.要实现https,首先我们需要申请一张SSL证书,这篇文章我主要介绍下边这几个方面: 1. SSL简单介绍 2. 免费Letencrypt证书部署 3. 安装注意事项 一.SSL简单介绍 ssl作为一个网络加密协议,主要是存在于系统中应用层和传输层之间的一个安全套接字层(Secure Socket Layer),也就是位于TCP/IP协议和各个应用层协议之间,为应用数据传输提供加密的协议.当然它

关于Linux和Windows下部署mysql.data.dll的注册问题

mysql ado.net connector下载地址: http://dev.mysql.com/downloads/connector/net/ 选择版本: Generally Available Releases(1)是发布版(bug什么的较少的版本吧),而Development Releases(2)是开发版 我们采用1版本 Windows (x86, 32-bit), MSI Installer 该版本是window下的安装版,如果你安装了这个版本的话,在本机调试的时候可以不用再次注册

Windows下部署Appium教程(Android App自动化测试框架搭建)

摘要: 1,appium是开源的移动端自动化测试框架: 2,appium可以测试原生的.混合的.以及移动端的web项目: 3,appium可以测试ios.android.firefox os: 4,appium是跨平台的,可以用在osx,windows以及linux系统上: ----------------------------------------------appium的一些基本概念---------------------------------------------- appium

使用Vagrant在Windows下部署开发环境

Vagrant介绍 Vagrant可以提供可配置.可再生.便携的工作环境,它主要是一个中间层技术,它的下层是VirtualBox,VMware等虚拟机软件,它的上层是配置管理系统工具,比如Shell Scripts,Chef,Puppet等可以自动化安装和配置软件的工具. 对你有什么用 对于开发人员来说,Vagrant可以帮你统一团队成员的开发环境.如果你或者你的伙伴创建了一个Vagrantfile,那么你只需要执行vagrant up就行了,所有的软件都会安装并且配置好.团队成员可以通过相同的

Linux下部署Kafka分布式集群,安装与测试

注意:部署Kafka之前先部署环境JAVA.Zookeeper 准备三台CentOS_6.5_x64服务器,分别是:IP: 192.168.0.249 dbTest249 Kafka IP: 192.168.0.250 Other250 Kafka IP: 192.168.0.251 webTest251 Kafka 一.安装Kafka # tar zxvf kafka_2.9.1-0.8.2.2.tgz -C /usr/local/ # cd /usr/local/kafka_2.9.1-0.

Windows下安装Kafka

一.安装JDK 二.安装zooeleeper 下载安装包:http://zookeeper.apache.org/releases.html#download 下载后解压到一个目录: 1.进入Zookeeper设置目录,笔者D:\Java\Tool\zookeeper-3.4.6\conf2. 将“zoo_sample.cfg”重命名为“zoo.cfg”3. 在任意文本编辑器(如notepad)中打开zoo.cfg4. 找到并编辑dataDir=D:\\Java\\Tool\\zookeeper

Windows下部署Apache RocketMQ

一:环境准备: Windows.JDK1.8+.Maven.Git 二:RocketMQ准备:  1.http://rocketmq.apache.org/release_notes/release-notes-4.2.0/ 2.选择'Binary'进行下载 下完完毕之后解压 三:配置 进行环境变量配置: 四:启动 4.1:在cmd中启动 'start mqnamesrv.cmd',或在mq文件夹的bin目录里执行'mqnamesrv.cmd',弹出DOS命令框之后不要关闭. 4.2:在cmd中

【原】无脑操作:Windows下搭建Kafka运行环境

Kafka是一种高吞吐量的分布式发布订阅消息系统 1.优点:① 通过磁盘数据结构提供消息的持久化,这种结构对于即使数以TB的消息存储也能够保持长时间的稳定性能.② 高吞吐量:即使是非常普通的硬件Kafka也可以支持每秒数百万的消息.③ 支持通过Kafka服务器和消费机集群来分区消息.④ 支持Hadoop并行数据加载. 2.基本概念: ① Broker:Kafka集群包含的一个或多个服务器② Topic:每条发布到Kafka集群的消息都有一个类别主题.(物理上不同Topic的消息分开存储,逻辑上一