Kafka单机版安装(CentOS 7环境下)

一、环境操作系统和软件版本介绍

1.环境操作系统为CentOS Linux release 7.2.1511 (Core)

可用cat /etc/redhat-release查询

2.软件版本

Kafka版本为:0.10.0.0

二、详细安装步骤

1.下载kafka_2.10-0.10.0.0.tgz到/data/soft目录

2.将kafka_2.10-0.10.0.0.tgz解压到/data/app/Kafka目录

1 [root@centos7 kafka_2.10-0.10.0.0]# tar –xzf kafka_2.10-0.10.0.0.tgz –C /data/app/Kafka

3.进入解压目录(在此为/data/app/Kafka/kafka_2.10-0.10.0.0/bin),启动zookeeper服务。可以在命令的结尾加个&符号,这样服务就可以在后台运行

1 [root@centos7 kafka_2.10-0.10.0.0]# ./zookeeper-server-start.sh ../config/zookeeper.properties &

4.启动kafka服务

[root@centos7 kafka_2.10-0.10.0.0]# ./kafka-server-start.sh ../config/server.properties &

[root@centos7 bin]# ps -ef | grep kafka查看,观察到zookeeper和kafka服务已启动

三、验证

1.创建一个叫"test1234"的topic,它只有一个分区,一个副本:

[root@centos7 bin]# ./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test1234

可以用list查看创建的topic,当前创建了4个topic

[root@centos7 bin]# ./kafka-topics.sh --list --zookeeper localhost:2181

2.发送消息。运行producer并在控制台中输一些消息,这些消息将被发送到服务端

[root@centos7 bin]# ./kafka-console-producer.sh --broker-list localhost:9092 --topic test1234

3.在另一个终端开启consumer,可以读取到刚才发出的消息并输出。

[root@centos7 bin]# ./kafka-console-consumer.sh --zookeeper localhost:2181 --topic test1234 --from-beginning

原文地址:https://www.cnblogs.com/littlemonsterksn/p/6284012.html