史上最简单的Kafka安装教程

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

查看主题

./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

删除主题

./kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic myevents

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shangjg3

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值