把kafka_2.10-0.10.2.0.tgz放到/usr/local文件夹下
解压
tar -zxvf kafka_2.10-0.10.2.0.tgz
解压得到的文件夹重命名为kafka
mv kafka_2.10-0.10.2.0 kafka
进入kafka配置文件的文件夹中
cd kafka/config
修改server的配置文件
vim server.properties
更改配置为自己ip地址,端口为9092
listeners=PLAINTEXT://192.168.30.11:9092
在kafka的目录下后台启动zookeeper和kafka服务
nohup ./bin/zookeeper-server-start.sh config/zookeeper.properties &
nohup ./bin/kafka-server-start.sh config/server.properties &
运行了之后查看kafka进场有无启动
ps -ef | grep kafka
两个进程都有则代表kafka安装成功
设置kafka开机自启
进入/lib/systemd/system目录下
新建zookeeper.service
vim zookeeper.service
[Unit]
Description=Zookeeper service
After=network.target
[Service]
Type=simple
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/jdk/bin"
User=root
Group=root
ExecStart=/usr/local/kafka/bin/zookeeper-server-start.sh /usr/local/kafka/config/zookeeper.properties
ExecStop=/usr/local/kafka/bin/zookeeper-server-stop.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target
新建kafka.service
vim kafka.service
[Unit]
Description=Apache Kafka server (broker)
After=network.target zookeeper.service
[Service]
Type=simple
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/jdk/bin"
User=root
Group=root
ExecStart=/usr/local/kafka/bin/kafka-server-start.sh /usr/local/kafka/config/server.properties
ExecStop=/usr/local/kafka/bin/kafka-server-stop.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target
保存退出之后执行systemctl daemon-reload
systemctl enable zookeeper
systemctl enable kafka
systemctl start zookeeper
systemctl start kafka
开机自启设置完毕