# kafka单体安装
### 下载并上传[安装包](https://archive.apache.org/dist/kafka/2.4.0/kafka_2.11-2.4.0.tgz)
> 以`kafka_2.11-2.4.0.tgz`为例
### 解压
```shell
tar -zxvf kafka_2.11-2.4.0.tgz -C /usr/local/
rm -rf kafka_2.11-2.4.0.tgz # 删除安装包
```
### 创建`log`目录
```shell
mkdir /usr/local/kafka_2.11-2.4.0/log
```
### 修改配置文件
1. 修改监听端口
```shell
sed -i '/listeners=PLAINTEXT:\/\/:9092/alisteners=PLAINTEXT:\/\/:9092' /usr/local/kafka_2.11-2.4.0/config/server.properties
```
2. 修改`log`目录
```shell
sed -i '/log.dirs=\/tmp\/kafka-logs/clog.dirs=\/usr\/local\/kafka_2.11-2.4.0\/log' /usr/local/kafka_2.11-2.4.0/config/server.properties
```
3. 其他不用修改但要注意:
```
broker.id=0 # id唯一,集群时用得到。
zookeeper.connect=localhost:2181 # zookeeper客户端url
```
### 启动kafka
```shell
/usr/local/kafka_2.11-2.4.0/bin/kafka-server-start.sh /usr/local/kafka_2.11-2.4.0/config/server.properties
```
> 启动前先将`zookeeper`服务启动起来。