Kafka集群搭建

1、环境:

centos7

kafka_2.10-0.10.2.1

zookeeper-3.5.2

jdk1.8

2、前提:

安装JDK

安装zookeeper

3、在master上将kafka安装包上传到Linu的/opt/softWare/kafka目录下并解压

4、将/opt/softWare/kafka分发到其他服务器

scp -r kafka slaves1:/opt/softWare/

scp -r kafka slaves2:/opt/softWare/

5、分别配置master、slaves1、slaves2中kafka中config下的server.properties

 broker.id=0
 port=6667
 host.name=master

 zookeeper.connect=master:2181,slaves1:2181,slaves2:2181
 broker.id=1
 port=6667
 host.name=slaves1

 zookeeper.connect=master:2181,slaves1:2181,slaves2:2181
 broker.id=2
 port=6667
 host.name=slaves2

 zookeeper.connect=master:2181,slaves1:2181,slaves2:2181

6、启动zookeeper

8、启动kafka

[root@master bin]# nohup ./kafka-server-start.sh ../config/server.properties &

[root@slaves1 bin]# nohup ./kafka-server-start.sh ../config/server.properties &

[root@slaves2 bin]# nohup ./kafka-server-start.sh ../config/server.properties &

9、创建主题

[root@master bin]# ./kafka-topics.sh --create --zookeeper master:2181,slaves1:2181,slaves2:2181 --replication-factor 3 --partitions 1 --topic mytest
Created topic "mytest".
[root@master bin]# ./kafka-topics.sh --list --zookeeper master:2181,slaves1:2181,slaves2:2181
mytest

10、测试:master生产数据、slaves1、slaves2消费数据

[root@master bin]# ./kafka-console-producer.sh --broker-list master:6667 --topic mytest
test01
test02
test02
test03
[root@slaves1 bin]# ./kafka-console-consumer.sh --zookeeper master:2181,slaves1:2181,slaves2:2181 --topic mytest --from-beginning
Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper].
test01
test02
test02
test03
[root@slaves2 bin]# ./kafka-console-consumer.sh --zookeeper master:2181,slaves1:2181,slaves2:2181 --topic mytest --from-beginning
Using the ConsoleConsumer with old consumer is deprecated and will be removed in a future major release. Consider using the new consumer by passing [bootstrap-server] instead of [zookeeper].
test01
test02
test02
test03

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

郝少

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

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

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

打赏作者

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

抵扣说明:

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

余额充值