环境需求:jdk1.8+

一、安装Zookeepeer

官网地址:http://kafka.apache.org/downloads.html,下载对应版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@ecs- ~]# wget https://mirror.bit.edu.cn/apache/kafka/2.6.0/kafka_2.12-2.6.0.tgz
--2020-09-07 09:29:18-- https://mirror.bit.edu.cn/apache/kafka/2.6.0/kafka_2.12-2.6.0.tgz
Resolving mirror.bit.edu.cn (mirror.bit.edu.cn)... 219.143.204.117, 202.204.80.77, 2001:da8:204:1205::22
Connecting to mirror.bit.edu.cn (mirror.bit.edu.cn)|219.143.204.117|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 65671917 (63M) [application/octet-stream]
Saving to: ‘kafka_2.12-2.6.0.tgz’

100%[====================================================================================================>] 65,671,917 12.0MB/s in 6.7s

2020-09-07 09:29:25 (9.38 MB/s) - ‘kafka_2.12-2.6.0.tgz’ saved [65671917/65671917]

[root@ecs ~]# tar -zxvf kafka_2.12-2.6.0.tgz
[root@ecs ~]# mv kafka_2.12-2.6.0 /opt
[root@ecs ~]# cd /opt/kafka_2.12-2.6.0/conifg
[root@ecs config]# vim zookeeper.properties

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

dataDir=/data/zookeeper kfk data
# the port at which the clients will connect
clientPort=2181
# disable the per-ip limit on the number of connections since this is a non-production config
maxClientCnxns=0
maxClientCnxns=0
tickTime=2000
initLiimit=10
svncLimit=5
# Disable the adminserver by default to avoid port conflicts.
# Set the port to something non-conflicting if choosing to enable this
admin.enableServer=false
# admin.serverPort=8080

启动一下

1
[root@ecs config]# nohup /opt/kafka_2.12-2.6.0/bin/zookeeper-server-start.sh /opt/kafka_2.12-2.6.0/config/zookeeper.properties &>> /opt/kafka_2.12-2.6.0/zookeeper.log &

查看日志没问题zookeepeer及OK

二、kafka配置

1
2
3
4
5
[root@ecs config]# cd /opt/kafka_2.12-2.6.0/
[root@ecs kafka_2.12-2.6.0]# mkdir kafka-logs-1
[root@ecs kafka_2.12-2.6.0]# cd /opt/kafka_2.12-2.6.0/config/
[root@ecs config]# vim server.properties

启动一下

1
2
[root@ecs config]# nohup /opt/kafka_2.12-2.6.0/bin/kafka-server-start.sh /opt/kafka_2.12-2.6.0/config/server.properties &>> /opt/kaf     ka_2.12-2.6.0/kafka.log &

测试一下

1
2
[root@ecs-88e7-0006 config]# /opt/kafka_2.12-2.6.0/bin/kafka-topics.sh --create --zookeeper 127.0.0.1:3181 --replication-factor 1 --partitions      1 --topic test
Created topic test.

OK