本文共 1568 字,大约阅读时间需要 5 分钟。
配置zookeeper
$cd kafka_2.11-0.10.0.0
$vi config/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
[root@hhh bin]#./zookeeper-server-start.sh/opt/kafka_2.12-0.11.0.0/config/zookeeper.properties
如果没有报错,可以转后台启动
[root@hhh bin]#nohup /opt/kafka_2.12-0.11.0.0/bin/zookeeper-server-start.sh/opt/kafka_2.12-0.11.0.0/config/zookeeper.properties &
配置kafka
$ vi config/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
[root@hhh bin]#/opt/kafka_2.12-0.11.0.0/bin/kafka-server-start.sh/opt/kafka_2.12-0.11.0.0/config/server.properties
如果没有报错,可以转后台启动
[root@hhh bin]#nohup /opt/kafka_2.12-0.11.0.0/bin/kafka-server-start.sh/opt/kafka_2.12-0.11.0.0/config/server.properties &
测试kafka
1、创建topic
$bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
2、查看创建的topic
$ bin/kafka-topics.sh -list -zookeeper localhost:2181
test
3、生产消息测试
$bin/kafka-console-producer.sh --broker-list 10.2.152.202:9092 --topic test
this is test #输入后回车
4、消费消息测试
$bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic test --from-beginning
this is test
转载地址:http://lmpub.baihongyu.com/