centos搭建zookeeer、kafka服务

1、下载zookeeper以及kafka的可执行文件,解压到一个目录,比如/usr/local/bin

2、在/usr/lib/systemd/system目录下创建zk以及kafka对应的服务文件

zookeepr.service文件内容如下

[Unit]
Description=Zookeeper service
After=network.target

[Service]
Type=forking
Environment=/home/software/zookeeper-3.6.1
ExecStart=/home/software/zookeeper-3.6.1/bin/zkServer.sh start
ExecStop=/home/software/zookeeper-3.6.1/bin/zkServer.sh stop
ExecReload=/home/software/zookeeper-3.6.1/bin/zkServer.sh restart

[Install]
WantedBy=multi-user.target

 

kafka.service文件内容如下

[Unit]
Description=Kafka service
After=network.target,zookeeper.service

[Service]
Type=forking
ExecStart=/home/software/kafka_2.12-2.5.0/bin/kafka-server-start.sh -daemon  /home/software/kafka_2.12-2.5.0/config/server.properties
ExecStop=/home/software/kafka_2.12-2.5.0/bin/kafka-server-stop.sh

[Install]
WantedBy=multi-user.target

 

3、设置服务随系统启动

systemctl enable kafka.service

systemctl enable zookeeper.service

4、启动zk以及kafka服务

systemctl start zookeeper

systemctl start kafka

 

当然你也可以使用docker创建zk以及kafka服务,笔者选择了更轻量级的方式,像kafka这种高吞吐量的应用在线上环境最好也是部署在物理机上。

你可能感兴趣的:(centos)