kafka0.10.0.0版本安装

来源:互联网 发布:淘宝上最好卖的是什么 编辑:程序博客网 时间:2024/05/19 17:24

1、下载https://www.apache.org/dyn/closer.cgi?path=/kafka/0.10.0.0/kafka_2.11-0.10.0.0.tgz

2、解压

      tar -zxvf kafka_2.11-0.10.0.0.tgz

3、cd /usr/local/wl/kafka/kafka_2.11-0.10.0.0

4、启动zookeeper

     bin/zookeeper-server-start.sh config/zookeeper.properties

5、开启kafka服务

    bin/kafka-server-start.sh config/server.properties 

   出现:

OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000b5a00000, 1073741824, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 1073741824 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /tmp/jvm-4499/hs_error.log

解决办法:将 kafka-server-start.sh的export KAFKA_HEAP_OPTS="-Xmx1G -Xms1G"修改为export KAFKA_HEAP_OPTS="-Xmx256M -Xms128M"

6、发布主题

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

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


7、创建生产者

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

8、创建消费者

      bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic kafkatopic --from-beginning

9、测试

      在生产者端输入消息回车,然后查看消费者端是否已经接收到消息

0 0
原创粉丝点击