CentOS7部署kafka服务

Posted sunnyyangwang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7部署kafka服务相关的知识,希望对你有一定的参考价值。

1、安装jdk

[root@linux-host1 ~]# tail /etc/profile

export JAVA_HOME=/usr/local/jdk1.8.0_161

export PATH=$JAVA_HOME/bin:$PATH

[root@linux-host1 ~]# source /etc/profile

[root@linux-host1 ~]# which  java

/usr/local/jdk1.8.0_161/bin/java

[root@linux-host1 ~]# java -version

 

2、安装zookeeper

[root@linux-host1 ~]# cd  /opt/zookeeper-3.4.14/

[root@linux-host1 zookeeper-3.4.14]# ./bin/zkServer.sh start

[root@linux-host1 ~]# netstat  -lnpt

Proto Recv-Q Send-Q Local Address     Foreign Address     State     PID/Program name   

tcp        0      0 0.0.0.0:22        0.0.0.0:*               LISTEN      939/sshd           

tcp6       0      0 :::43727           :::*                    LISTEN      5399/java          

tcp6       0      0 :::80             :::*                    LISTEN      940/httpd          

tcp6       0      0 :::22             :::*                    LISTEN      939/sshd           

tcp6       0      0 :::2181           :::*                    LISTEN      5399/java    

配置systemd启动服务,

 技术图片

[root@linux-host1 ~]# vim /usr/lib/systemd/system/zookeeper.service

[Unit]

Description=zookeeper service

After=network.target

 

[Service]

Type=forking

Environment="PATH=/usr/local/jdk1.8.0_161/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin"

User=root

Group=root

ExecStart=/opt/zookeeper-3.4.14/bin/zkServer.sh start

ExecStop=/opt/zookeeper-3.4.14/bin/zkServer.sh stop

Restart=on-failure

 

[Install]

WantedBy=multi-user.target

[root@linux-host1 ~]# systemctl daemon-reload

[root@linux-host1 ~]# systemctl stop zookeeper 

[root@linux-host1 ~]# systemctl status zookeeper

 

3、安装kafka

Kafka解压目录:/root/ansibles/kafka/kafka_2.12-1.0.0

[root@linux-host1 ~]# vim /lib/systemd/system/kafka.service

[Unit]

Description=Apache Kafka server (broker)

After=network.target

 

[Service]

Type=forking

Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/jdk1.8.0_161/bin"

User=root

Group=root

ExecStart=/opt/kafka_2.12-1.0.0/bin/kafka-server-start.sh -daemon /opt/kafka_2.12-1.0.0/config/server.properties
ExecStop=/opt/kafka_2.12-1.0.0/bin/kafka-server-stop.sh

 

[Install]

WantedBy=multi-user.target

技术图片

[root@linux-host1 ~]# systemctl daemon-reload

[root@linux-host1 ~]# systemctl status kafka

[root@linux-host1 ~]# systemctl start kafka

相关服务端口,

 技术图片

完成kafka安装部署。 

以上是关于CentOS7部署kafka服务的主要内容,如果未能解决你的问题,请参考以下文章

基于centos7部署hadoop集群的准备环境部署

centos7搭建kafka集群

Centos7 安装kafka+zookeeper实践

CentOS7下Kafka安装

CentOS7安装和使用kafka

CentOS7部署Apache Mesos