1.安装zookeeper
解压apache-zookeeper-3.8.0-bin.tar.gz到指定目录,复制conf目录下zoo_sample.cfg到zoo.cfg,并修改配置。
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/data/etl/zookeeper-3.8.0-bin/data
clientPort=2181
maxClientCnxns=60
进入bin目录,启动zookeeper
./zkServer.sh start
2.安装Kafka
解压kafka_2.12-3.0.0.tgz到指定目录。
进入到config目录,修改server.properties配置
# 允许外部端口连接
listeners=PLAINTEXT://0.0.0.0:9092
# 外部代理地址
advertised.listeners=PLAINTEXT://10.16.60.62:9092
log.dirs=/data/etl/kafka_2.12-3.0.0/log
zookeeper.connect=10.16.60.62:2181
advertised.listeners才是真正的对外代理地址,listeners的作用不是对外提供服务代理,而是监听!
启动kafka
./kafka-server-start.sh -daemon ../config/server.properties
3.使用测试
创建主题topic
./kafka-topics.sh --create --topic myevents --partitions 10 --replication-factor 1 --bootstrap-server localhost:9092
查看主题文章来源:https://www.toymoban.com/news/detail-730430.html
./kafka-topics.sh --describe --topic myevents --bootstrap-server localhost:9092
Topic: myevents TopicId: 68wbesvHSmmYSTRu-odyeQ PartitionCount: 20 ReplicationFactor: 1 Configs: segment.bytes=1073741824
Topic: myevents Partition: 0 Leader: 0 Replicas: 0 Isr: 0
Topic: myevents Partition: 1 Leader: 0 Replicas: 0 Isr: 0
Topic: myevents Partition: 2 Leader: 0 Replicas: 0 Isr: 0
Topic: myevents Partition: 3 Leader: 0 Replicas: 0 Isr: 0
Topic: myevents Partition: 4 Leader: 0 Replicas: 0 Isr: 0
Topic: myevents Partition: 5 Leader: 0 Replicas: 0 Isr: 0
Topic: myevents Partition: 6 Leader: 0 Replicas: 0 Isr: 0
Topic: myevents Partition: 7 Leader: 0 Replicas: 0 Isr: 0
Topic: myevents Partition: 8 Leader: 0 Replicas: 0 Isr: 0
Topic: myevents Partition: 9 Leader: 0 Replicas: 0 Isr: 0
Topic: myevents Partition: 10 Leader: 0 Replicas: 0 Isr: 0
删除主题文章来源地址https://www.toymoban.com/news/detail-730430.html
./kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic myevents
到了这里,关于史上最简单的Kafka安装教程的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!