参考:https://blog.csdn.net/yang1393214887/article/details/123425715
1. 官网下载https://kafka.apache.org/downloads
https://dlcdn.apache.org/kafka/3.1.0/kafka_2.12-3.1.0.tgz
2. 上传到centos7 /usr/目录,解压到此目录
tar -zxvf kafka_2.12-3.2.1.tgz
4. 配置kafka单节点
4.1 配置zookeeper单节点(kafka自带,不需要重新下载)
进入kafka安装目录:cd /usr/kafka_2.12-3.2.1/
创建zookeeper数据存放目录:mkdir -p zookeeper/data
创建zookeeper日志存放目录:mkdir -p zookeeper/logs
进入配置文件目录:cd config/
备份原来的配置文件:mv zookeeper.properties zookeeper.properties.bak20220830
重写配置文件:(路径根据自己情况改)
[root@xxxxpcV7-03 config]# pwd
/usr/kafka_2.12-3.2.1/config
[root@xxxxpcV7-03 config]#vi zookeeper.properties
添加:
tickTime=2000
dataDir=/usr/kafka_2.12-3.2.1/zookeeper/data/
dataLogDir=/usr/kafka_2.12-3.2.1/zookeeper/logs/
clientPort=2181
4.2 配置kafka单节点
进入kafka安装目录:cd /usr/kafka_2.12-3.2.1/
创建日志存放目录:mkdir logs
进入配置文件目录:cd config/
备份原来的配置文件:mv server.properties server.properties.bak20220830
重新写配置文件(也可以在上一步用复制命令,再修改配置文件对应内容)
[root@xxxxpcV7-03 config]#vi zookeeper.properties
添加:
broker.id=1
listeners=PLAINTEXT://192.168.78.203:9092
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=/usr/kafka_2.12-3.2.1/logs
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=192.168.78.203:2181
zookeeper.connection.timeout.ms=6000
上边配置的server.properties的内容基本都是原server.properties的默认配置,到自己安装时主要修改:
broker.id broker的id修改为任意自己想要的数值(和zookeeper中的id类似的)
listeners 监听址址;修改为kafka要监听的地址
num.partitions 修改每个topic的默认分区参数,默认是1,具体合适的取值需要根据服务器配置进程确定
log.dirs 日志文件存放目录(修改为自己要存放日志的目录)
zookeeper.connect zookeeper监听地址。修改为自己的zookeeper的监听地址,如果是集群所有地址全写上用逗号(半角)隔开即可
5、启动
kafka的bin目录:
"-daemon" 参数代表以守护进程的方式启动kafka server-dae
./zookeeper-server-start.sh -daemon ../config/zookeeper.properties #启动zookeeper
./kafka-server-start.sh -daemon ../config/server.properties #启动kafka
注意:如果启动后查不到进程,可以看JAVA_HOME是否配置
查看是否有进程:
jps
6、停止
./zookeeper-server-stop.sh #停止zookeeper
./kafka-server-stop.sh #停止kafka,centos7上可能关不了用kill -9直接杀掉
标签:config,zookeeper,server,centos7,2.12,kafka,安装,properties From: https://www.cnblogs.com/qsds/p/16641388.html