基础环境 CentOS-7-x86_64-DVD-1908
1.安装配置jdk
下载安装包并解压配置环境变量
jdk-8u231-linux-x64.tar.gz
配置环境变量修改文件vi /etc/profile
尾部添加
export JAVA_HOME=/gcl/jdk1.8.0_231
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
配置生效 source /etc/profile
测试 java -version 成功后进入下一步配置
2.搭建zookeeper
下载安装包并解压
apache-zookeeper-3.5.5-bin.tar.gz
配置 复制文件
[[email protected] conf]# cp zoo_sample.cfg zoo.cfg
编辑文件
[[email protected] conf]# vi zoo.cfg
dataDir=/gcl/apache-zookeeper-3.5.5-bin/data
dataLogDir=/gcl/apache-zookeeper-3.5.5-bin/log
确保上述配置添加了
常用命令
sh zkServer.sh start
sh zkServer.sh status
sh zkServer.sh stop
启动成功后进行下一步
启动失败到logs目录下查看启动失败原因,然后解决
[[email protected] logs]# tail -f zookeeper-root-server-localhost.localdomain.out
3.搭建kafka
下载安装包并解压
kafka_2.11-2.3.1.tgz
修改配置
[[email protected]alhost config]# vi server.properties
port=9092
host.name=192.168.6.114
log.dirs=/gcl/kafka_2.11-2.3.1/kafka-logs
zookeeper.connect=localhost:2181
bin/kafka-server-start.sh config/server.properties
停止
./bin/kafka-server-stop.sh
创建一个主题
./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic TEST_TOPIC
备注:先安装配置启动zookeeper
备注: 错误
advertised.listeners=PLAINTEXT://192.168.6.92:9092
4.命令使用kafka
启动
bin/kafka-server-start.sh config/server.properties
停止
./bin/kafka-server-stop.sh
创建一个主题
./bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic TEST_TOPIC
查看主题
bin/kafka-topics.sh --list --zookeeper localhost:2181
运行
./bin/kafka-server-start.sh ./config/server.properties
原文地址:https://www.cnblogs.com/guochaolang/p/12031048.html