1、下载
官网地址:http://kafka.apache.org/downloads
直接连接:https://www.apache.org/dyn/closer.cgi?path=/kafka/2.8.0/kafka_2.13-2.8.0.tgz
下载/解压:
# 安装 wget
$ yum -y install wget
# 下载 kafka 安装包
$ wget https://www.apache.org/dyn/closer.cgi?path=/kafka/2.8.0/kafka_2.13-2.8.0.tgz
# 解压
$ tar -zxvf kafka_2.13-2.8.0.tgz
2 须知
kafka 服务依赖 zookeeper ,在kafka 安装包中包含 zookeeper,需要先配置启动好zookeeper 然后 启动 kafka 服务
3、zookeeper 服务配置
在 kafka 安装包根目录下
$ yum -y install vim
vim ./config/zookeeper.properties
详细配置如下:
dataDir=/usr/local/kafka/data # 存放数据目录
# the port at which the clients will connect
clientPort=2181
# disable the per-ip limit on the number of connections since this is a non-production config
maxClientCnxns=100
# Disable the adminserver by default to avoid port conflicts.
# Set the port to something non-conflicting if choosing to enable this
admin.enableServer=false
# admin.serverPort=8080
4、启动zookeeper 服务
# 注释:'&' 代表 该服务后台启动
$ ./bin/zookeeper-server.start.sh ./config/zookeeper.properties &
查看 zookeeper 服务
$ jsp
zookeeper 启动成功
5、配置 kafka 服务
$ vim /conf/server.properies
# zookeeper 连接配置
zookeeper.connect=localhost:2181
# kafka 日志目录
log.dirs=/usr/local/kafka/kafka_2.13-2.8.0/logs
# kafka 服务器/端口连接配置
listeners=PLAINTEXT://192.168.182.133:9092
6、启动kafka 服务器
指令:
$ ./bin/kafka-server.start ./conf/server.properies &
查看kafka 服务
7、 使用 kafka 连接工具
下载: https://www.kafkatool.com/download.html
连接成功:
8、遇到问题
1、外部无法连接kafka服务器,使用 ping 可以ping通ip 地址。
使用 telnet ip port 测试服务器端口是否可通。连接失败 可能是 防火墙问题。
2、关闭防火墙
2.1、查看 防火墙状态 Centos7
systemctl status firewalld
2.2、关闭防火墙
systemctl stop firewalld