安装jdk
下载jdk https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
配置环境变量(建议加在done之后,unset i之前)
JAVA_HOME=/usr/local/hotpot/jdk8
JRE_HOME=$JAVA_HOME/jre
PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/jt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
使文件生效 source /etc/profile
安装zookeeper
建议zookeeper版本和kafka依赖版本一致(kafka26/libs下看查zookeeper依赖加包版本)
-rw-r--r-- 1 root root 991098 May 16 01:16 zookeeper-3.5.8.jar
https://zookeeper.apache.org/releases.html
配置环境变量
export ZOOKEEPER_HOME=/usr/local/hotpot/zookeeper
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$ZOOKEEPER_HOME/bin
使文件生效 source /etc/profile
zookeeper/conf 下
cp zoo_sample.cfg zoo.cfg
./zkServer.sh start 启动
./zkServer.sh stop 启动
./zkServer.sh status 查看状态
安装kafka
下载 http://kafka.apache.org/downloads.html
配置环境变量
export KAFKA_HOME=/usr/local/hotpot/kafka26
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$ZOOKEEPER_HOME/bin:$KAFKA_HOME/bin
使文件生效 source /etc/profile
整体环境变量如下:
image.png
进到bin目录启动kafka
./kafka-server-start.sh ../config/server.properties
发送消息
kafka-console-producer.sh --broker-list localhost:9092 --topic my-replicated-topic
接收消息
./kafka-console-consumer.sh --bootstrap-server localhost:9092 --from-beginning --topic my-replicated-topic
使用jps查看kafka进程
[root@VM_0_7_centos hotpot]# jps
27091 ConsoleProducer
18647 Jps
27640 ConsoleConsumer
20847 QuorumPeerMain
18015 Kafka
网友评论