您的位置:首页 > 其它

kafka安装

2016-01-25 17:27 447 查看
一:安装

首先查看防火墙是否关闭:

/etc/init.d/iptables status

没有关闭,用下列命令关闭:

/etc/init.d/iptables stop

(1) 下载kafka

kafka下载地址:https://www.apache.org/dyn/closer.cgi?path=/kafka/0.9.0.0/kafka_2.11-0.9.0.0.tgz,下载包放到 /export/servers/目录下

(2)安装kafka

--> tar -xzvf  kafka_2.11-0.9.0.0.tgz

--> cd kafka_2.11-0.9.0.0

vim config/server.properties

编辑内容如下:

一定要注销掉 listeners=PLAINTEXT://:9092

broker.id=0

port=9092

host.name=192.168.1.162

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=/tmp/kafka-logs

num.partitions=1

num.recovery.threads.per.data.dir=1

log.retention.hours=168

log.segment.bytes=1073741824

log.retention.check.interval.ms=300000

log.cleaner.enable=false

zookeeper.connect=192.168.154.64:2181

zookeeper.connection.timeout.ms=60000

-->启动kafka-server

bin/kafka-server-start.sh config/server.properties

-->create a topic

bin/kafka-topics.sh --create --zookeeper 192.168.154.64:2181
--replication-factor 1 --partitions 1 --topic test


--> topic list

bin/kafka-topics.sh
--list --zookeeper 192.168.154.64:2181




-->send messages

bin/kafka-console-producer.sh --broker-list localhost:9092
--topic test


-->Start a consumer

bin/kafka-console-consumer.sh --zookeeper 192.168.154.64:2181 --topic test --from-beginning

具体的配置请查看官网地址:http://kafka.apache.org/documentation.html#quickstart
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: