kafka_2.11-1.0.0单机安装

步骤

搭建kafka单机环境时,使用版本是kafka_2.11-1.0.0.tgz,步骤是按官网的介绍如下:

1.   下载1.0.0release 并解压。

1)       tar -xzf kafka_2.11-1.0.0.tgz

2)   cd kafka_2.11-1.0.0

2.       启动服务

Kafka因为依赖与ZooKeeper,所以需要首先启动ZooKeeper。如果没有安装ZooKeeper,则可以使用内置的单节点ZooKeeper实例

bin/zookeeper-server-start.shconfig/zookeeper.properties

启动服务:

bin/kafka-server-start.shconfig/server.properties

3.       建立topic

创建一个名为“test”的单分区、单replica的主题:

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

查看topic:

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

4.       发送消息

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

This is a message

This is anothermessage

5.       接收消息

bin/kafka-console-consumer.sh --bootstrap-serverlocalhost:9092 --topic test --from-beginning

This is a message

This is anothermessage

问题

按上述步骤执行到5,接收消息时,会出现以下的错误信息:

[2017-11-27 13:02:40,618] WARN [Controllerid=0, targetBrokerId=0] Connection to node 0 could not be established. Brokermay not be available. (org.apache.kafka.clients.NetworkClient)

解决:

Vim config/server.properties

发现zookeeper.connect= localhost:2181的设置是localhost,则修改server.properties,添加:

listeners=PLAINTEXT://localhost:9092

重新启动zookeeper、kafka、consumer、producer即可解决问题。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值