kafka 单节点安装

Last updated on November 20, 2024 am

🧙 Questions

Kafka 单节点安装 2.12-2.6.2

☄️ Ideas

前提

下载kafka并解压

cd /tmp
nohup wget https://archive.apache.org/dist/kafka/2.6.2/kafka_2.12-2.6.2.tgz --no-check-certificate >> download_kafka.log 2>&1 &
tail -f download_kafka.log
sudo mkdir -p /data/kafka
sudo tar -vzxf /tmp/kafka_2.12-2.6.2.tgz -C /data/kafka
sudo ln -s /data/kafka/kafka_2.12-2.6.2 /opt/kafka
sudo tee -a /etc/profile <<-'EOF'
export KAFKA_HOME=/opt/kafka
export PATH=$PATH:$KAFKA_HOME/bin
EOF
source /etc/profile

配置zookeeper端口号(可选)

sudo vim /opt/kafka/config/zookeeper.properties
# 默认端口号 2181
clientPort=30121
启动zookeeper(可选)

停止zk
sudo ./zookeeper-server-stop.sh -daemon /opt/kafka/config/zookeeper.properties

cd /opt/kafka/bin
sudo ./zookeeper-server-start.sh -daemon /opt/kafka/config/zookeeper.properties
tail -f /opt/kafka/logs/zookeeper.out
sudo netstat -ntpl | grep 30121

配置kafka端口号

NOTE!
listeners 一定要是ip地址且要是内网
advertised.listeners 一定要是ip且要为外网

sudo vim /opt/kafka/config/server.properties
# 配置zookeeper地址
zookeeper.connect=isxcode:30121
# 配置kafka端口号 默认9092 内网(新增)
listeners=PLAINTEXT://172.16.215.83:30120
# 外网(新增)
advertised.listeners=PLAINTEXT://39.100.85.0:30120
# 可以删除topic(新增)
delete.topic.enable=true
# 添加kafka日志路径
log.dirs=/data/kafka/kafka-logs
启动kafka

关闭kafka
sudo ./kafka-server-stop.sh -daemon /opt/kafka/config/server.properties

cd /opt/kafka/bin
sudo ./kafka-server-start.sh -daemon /opt/kafka/config/server.properties
tail -f /opt/kafka/logs/server.log
sudo netstat -ntpl | grep 30120
测试命令$$
# 创建topic
kafka-topics.sh --create --zookeeper isxcode:30121 --topic ispong-topic --replication-factor 1 --partitions 1 
# 生产
kafka-console-producer.sh --topic ispong-topic --broker-list isxcode:30120
# 消费
kafka-console-consumer.sh --bootstrap-server isxcode:30120 --topic ispong-topic

kafka 单节点安装
https://ispong.isxcode.com/hadoop/kafka/kafka 单节点安装/
Author
ispong
Posted on
April 1, 2021
Licensed under