kafka下载地址
http://kafka.apache.org/downloads.html
在这里下载kafka_2.11-0.10.0.0.tgz,kafka和zookeeper都用同一个包里的
安装和配置jdk(略过)
JAVA_HOME=/opt/jdk1.8.0_131 CLASSPATH=.:$JAVA_HOME/lib.tools.jar PATH=$JAVA_HOME/bin:$PATH exportJAVA_HOMECLASSPATHPATH $java-version javaversion"1.8.0_131" Java(TM)SERuntimeEnvironment(build1.8.0_131-b11) JavaHotSpot(TM)ServerVM(build25.131-b11,mixedmode)
或者在bin/kafka-run-class.sh指定kafka jdk 环境变量
vibin/kafka-run-class.sh JAVA_HOME=/opt/jdk1.8.0_131
安装glibc
#yum-yinstallglibc.i686
解压后kafka_2.11-0.10.0.0.tgz,
先配置zookeeper
$cdkafka_2.11-0.10.0.0 $viconfig/zookeeper.properties dataDir=/data/programs/kafka_2.11-0.10.0.0/data dataLogDir=/data/programs/kafka_2.11-0.10.0.0/logs clientPort=2181 maxClientCnxns=100 tickTime=2000 initLimit=10 配置后直接启动zookeeper $bin/zookeeper-server-start.shconfig/zookeeper.properties 如果没有报错,可以转后台启动 $nohupbin/zookeeper-server-start.shconfig/zookeeper.properties&
再配置kafka
$viconfig/server.properties broker.id=0 port=9092 host.name=192.168.12.105 num.network.threads=3 num.io.threads=8 socket.send.buffer.bytes=102400 socket.receive.buffer.bytes=102400 socket.request.max.bytes=104857600 log.dirs=/data/logs/kafka num.partitions=2 num.recovery.threads.per.data.dir=1 log.retention.check.interval.ms=300000 zookeeper.connect=localhost:2181 zookeeper.connection.timeout.ms=6000 启动kafka $bin/kafka-server-start.shconfig/server.properties 如果没有报错,可以转后台启动 $nohupbin/kafka-server-start.shconfig/server.properties&
测试kafka
1、创建topic $bin/kafka-topics.sh--create--zookeeperlocalhost:2181--replication-factor1--partitions1--topictest 2、查看创建的topic $bin/kafka-topics.sh-list-zookeeperlocalhost:2181 test 3、生产消息测试 $bin/kafka-console-producer.sh--broker-list192.168.12.105:9092--topictest thisistest#输入后回车 4、消费消息测试 $bin/kafka-console-consumer.sh--zookeeperlocalhost:2181--topictest--from-beginning thisistest
完成以上代表kafka单包机安装成功。
原文链接:https://www.f2er.com/centos/377282.html