Kafka单节点部署

2024-01-09 14:27:26
  1. 配置JAVA环境变量
$ tar xf jdk-8u202-linux-x64.tar.gz
$ mv jdk1.8.0_202 /usr/local/java
$ vim /etc/profile
export JAVA_HOME=/usr/local/java
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
$ source /etc/profile
  1. 解压kafka安装包
$ wget https://downloads.apache.org/kafka/3.4.1/kafka_2.13-3.4.1.tgz
$ tar xf kafka_2.13-3.4.1.tgz
$ mv kafka_2.13-3.4.1 /data/kafka
  1. 修改zk配置
$ vim /data/kafka/config/zookeeper.properties
dataDir=/data/kafka/zookeeper
clientPort=2181
maxClientCnxns=0
admin.enableServer=false
  1. 修改kafka配置
$ vim /data/kafka/config/server.properties
broker.id=0
listeners=PLAINTEXT://192.168.0.218:9092
log.dirs=/data/kafka/kafka-logs
zookeeper.connect=192.168.0.218:2181
  1. zk托管到systemd
$ vim /usr/lib/systemd/system/zookeeper.service
[Unit]
Description=Apache Zookeeper service
Requires=network.target
After=network.target

[Service]
Type=forking
Environment=JAVA_HOME=/usr/local/java
ExecStart=/data/kafka/bin/zookeeper-server-start.sh  -daemon /data/kafka/config/zookeeper.properties
ExecStop=/data/kafka/bin/zookeeper-server-stop.sh
Restart=on-failure
RestartSec=10s

[Install]
WantedBy=multi-user.target
  1. kafka托管到systemd
$ vim /usr/lib/systemd/system/kafka.service
[Unit]
Description=Apache Kafka server
Documentation=http://kafka.apache.org/documentation.html
Requires=network.target remote-fs.target
After=network.target remote-fs.target zookeeper.service

[Service]
Type=forking
Environment=JAVA_HOME=/usr/local/java
ExecStart=/data/kafka/bin/kafka-server-start.sh -daemon /data/kafka/config/server.properties
ExecStop=/data/kafka/bin/kafka-server-stop.sh
Restart=on-failure
RestartSec=10s

[Install]
WantedBy=multi-user.target
  1. 重载systemd配置并启动服务
$ systemctl daemon-reload
$ systemctl start zookeeper
$ systemctl start kafka

文章来源:https://blog.csdn.net/yuanfangPOET/article/details/135466098
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。