linux下安装kafka
1.下载安装包
##scala安装包##
wget https://downloads.lightbend.com/scala/2.12.11/scala-2.12.11.tgz
##kafka安装包 (kafka3.0.0已经包含了zookeeper) ##
wget https://archive.apache.org/dist/kafka/3.0.0/kafka_2.12-3.0.0.tgz
2.安装java环境(已安装跳过该步骤)
-
安装openjdk
yum install java-1.8.0-openjdk-1.8.0.201.b09-0.amzn2 -y
-
编辑环境变量配置文件
vim /etc/profile
-
添加内容
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.352.b08-2.el7_9.x86_64 JRE_HOME=$JAVA_HOME/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin export JAVA_HOME JRE_HOME CLASS_PATH PATH
-
生效配置文件文件
source /etc/profile
-
测试openjdk是否安装成功
java -version ##输出以下内容代表openjdk安装成功## openjdk version "1.8.0_352" OpenJDK Runtime Environment (build 1.8.0_352-b08) OpenJDK 64-Bit Server VM (build 25.352-b08, mixed mode)
3.安装scala环境(已安装跳过该步骤)
-
解压
tar -zxvf scala-2.12.11.tgz
-
编辑环境变量配置文件
vim /etc/profile
-
添加内容
注意/apps/scala为文件解压的路径
export SCALA_HOME=/apps/scala export PATH=${PATH}:${SCALA_HOME}/bin
-
生效配置文件文件
source /etc/profile
-
测试scala是否生效
scala -version ##显示以下内容则代表scala环境安装成功## Scala code runner version 2.12.11 -- Copyright 2002-2020, LAMP/EPFL and Lightbend, Inc
4.安装并且启动kafka
-
解压
tar -zxvf kafka_2.12-3.0.0.tgz mv kafka_2.12-3.0.0 kafka cd kafka
-
修改配置文件
vim /config/server.properties ##修改文件内容## listeners=PLAINTEXT://192.168.48.48:9092 zookeeper.connect=192.168.48.48:2181
-
启动zookeeper
./bin/zookeeper-server-start.sh -daemon ./config/zookeeper.properties
-
启动zk成功再启动kafka
./bin/kafka-server-start.sh -daemon ./config/server.properties