安装jdk
下载jdk1.8并解压
然后移动到目录/usr/local/jdk1.8.0
在/etc/profile 下面添加下面内容:
export JAVA_HOME=/usr/local/jdk1.8.0
export JAVA_BIN=$JAVA_HOME/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
执行下面命令(生效):
source /etc/profile

下载kafka
https://mirrors.tuna.tsinghua.edu.cn/apache/kafka/2.7.0/kafka_2.12-2.7.0.tgz
解压:tar zxf kafka_2.12-2.7.0.tgz

移动文件
mv kafka_2.12-2.7.0 /home/hadoop/kafka

更改配置文件:
zookeeper.properties和server.properties

我这边已经配置好了!直接传上去就行了!
先启动Zookeeper!再启动kafka
以前配置过,有历史记录!

启动Zookeeper
/home/hadoop/kafka/bin/zookeeper-server-start.sh -daemon /home/hadoop/kafka/config/zookeeper.properties

关闭Zookeeper
/home/hadoop/kafka/bin/zookeeper-server-stop.sh -daemon /home/hadoop/kafka/config/zookeeper.properties

启动kafka
/home/hadoop/kafka/bin/kafka-server-start.sh -daemon /home/hadoop/kafka/config/server.properties

停止kafka
/home/hadoop/kafka/bin/kafka-server-stop.sh /home/hadoop/kafka/config/server.properties

创建并查看topic
/home/hadoop/kafka/bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
/home/hadoop/kafka/bin/kafka-topics.sh --list --zookeeper localhost:2181

发送消息
/home/hadoop/kafka/bin/kafka-console-producer.sh --broker-list localhost:59092 --topic canal_topic

接收消息
/home/hadoop/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:59092 --topic canal_topic --from-beginning

查看topic&删除topic
/home/hadoop/kafka/bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic test

/home/hadoop/kafka/bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic test

topic图形化工具下载地址:
https://www.kafkatool.com/download.html