centos7 安装kafka

1.下载kafka
https://kafka.apache.org/downloads
centos7 安装kafka_第1张图片centos7 安装kafka_第2张图片2.解压

tar -zxvf kafka_2.11-2.2.1.tgz -C /opt

centos7 安装kafka_第3张图片3.修改配置文件

cd kafka_2.11-2.2.1
vi ./config/server.properties

centos7 安装kafka_第4张图片centos7 安装kafka_第5张图片将broker.id=0改为
broker.id=1
将log.dirs=/tmp/kafka-logs改为 log.dirs=/
centos7 安装kafka_第6张图片centos7 安装kafka_第7张图片4.启动zookeeper

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

centos7 安装kafka_第8张图片
5.启动kafka

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

报错提示
/opt/kafka_2.11-2.2.1/bin/kafka-run-class.sh: 第 306 行:exec: java: 未找到
kafka需要java环境,查看jdk是否安装

java -version

centos7 安装kafka_第9张图片
安装Open JDK
搜索JDK yum 源

yum search java | grep jdk

centos7 安装kafka_第10张图片centos7 安装kafka_第11张图片使用yum安装open JDK

yum install -y java-1.8.0-openjdk

centos7 安装kafka_第12张图片centos7 安装kafka_第13张图片再次启动kafka

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

报错信息,提示2181端口无法连接
O Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2019-06-20 10:00:28,276] INFO Socket error occurred: localhost/127.0.0.1:2181: 拒绝连接 (org.apache.zookeeper.ClientCnxn)
[2019-06-20 10:00:29,380] INFO Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
[2019-06-20 10:00:29,383] INFO Socket error occurred: localhost/0:0:0:0:0:0:0:1:2181: 拒绝连接 (org.apache.zookeeper.ClientCnxn)
[2019-06-20 10:00:30,484] INFO Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error) (org.apache.zookeeper.ClientCnxn)
查看zookeeper是否启动成功

netstat -ntpl

centos7 安装kafka_第14张图片启动zookeeper

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

centos7 安装kafka_第15张图片启动kafka

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

centos7 安装kafka_第16张图片centos7 安装kafka_第17张图片安装成功

你可能感兴趣的:(消息中间件)