1. kafka2.11下载并解压
2. 修改配置文件
· config/server.properties
broker.id=4(集群里的id不能重复,我是取每台机器IP最后一位)
listeners=PLAINTEXT://192.168.248.134:9092(格式不变,绑定本机IP)
log.dirs=/home/hadoop/kafka/logs4kafka(日志路径)
zookeeper.connect=h2:2181,h3:2181,h4:2181,h8:2181,h9:2181,h10:2181
最后一项时延可以增大一些,曾经因为超过时延而报错,修改成10倍就OK了
· producer.properties
bootstrap.servers=h2:9092,h3:9092,h4:9092,h8:9092,h9:9092,h10:9092
· consumer.properties
zookeeper.connect=h2:2181,h3:2181,h4:2181,h8:2181,h9:2181,h10:2181
group不配的话就是默认,看需求
3.拷贝到其他节点,注意修改listeners绑定的IP和broker.id
4 基本命令
#start
bin/kafka-server-start.sh config/server.properties
#create a topic
bin/kafka-topics.sh --create --zookeeper h2:2181,h3:2181,h4:2181,h8:2181,h9:2181,h10:2181 --replication-factor 5 --partition 5 --topic T20161021
#list all topics
bin/kafka-topics.sh --zookeeper h2:2181,h3:2181,h4:2181,h8:2181,h9:2181,h10:2181 --list
#describe the detail of this topic
bin/kafka-topics.sh --describe --zookeeper h2:2181,h3:2181,h4:2181,h8:2181,h9:2181,h10:2181 --topic test101
#write some Messages to the topic
bin/kafka-console-producer.sh --broker-list h2:9092 --topic T20161021
#recerive the message producer writed
bin/kafka-console-consumer.sh --zookeeper h2:2181,h3:2181,h4:2181,h8:2181,h9:2181,h10:2181 --topic T20161021 --from-beginning
2. 修改配置文件
· config/server.properties
broker.id=4(集群里的id不能重复,我是取每台机器IP最后一位)
listeners=PLAINTEXT://192.168.248.134:9092(格式不变,绑定本机IP)
log.dirs=/home/hadoop/kafka/logs4kafka(日志路径)
zookeeper.connect=h2:2181,h3:2181,h4:2181,h8:2181,h9:2181,h10:2181
最后一项时延可以增大一些,曾经因为超过时延而报错,修改成10倍就OK了
· producer.properties
bootstrap.servers=h2:9092,h3:9092,h4:9092,h8:9092,h9:9092,h10:9092
· consumer.properties
zookeeper.connect=h2:2181,h3:2181,h4:2181,h8:2181,h9:2181,h10:2181
group不配的话就是默认,看需求
3.拷贝到其他节点,注意修改listeners绑定的IP和broker.id
4 基本命令
#start
bin/kafka-server-start.sh config/server.properties
#create a topic
bin/kafka-topics.sh --create --zookeeper h2:2181,h3:2181,h4:2181,h8:2181,h9:2181,h10:2181 --replication-factor 5 --partition 5 --topic T20161021
#list all topics
bin/kafka-topics.sh --zookeeper h2:2181,h3:2181,h4:2181,h8:2181,h9:2181,h10:2181 --list
#describe the detail of this topic
bin/kafka-topics.sh --describe --zookeeper h2:2181,h3:2181,h4:2181,h8:2181,h9:2181,h10:2181 --topic test101
#write some Messages to the topic
bin/kafka-console-producer.sh --broker-list h2:9092 --topic T20161021
#recerive the message producer writed
bin/kafka-console-consumer.sh --zookeeper h2:2181,h3:2181,h4:2181,h8:2181,h9:2181,h10:2181 --topic T20161021 --from-beginning
本文详细介绍Kafka 2.11的下载、配置及集群部署步骤,包括配置文件server.properties的修改要点,如broker.id设置、listeners绑定、日志路径指定及Zookeeper连接等。此外还介绍了基本命令操作,如启动服务、创建主题、查看所有主题、描述主题详情、写入消息及接收消息等。
1429

被折叠的 条评论
为什么被折叠?



