系统相关
首页 > 系统相关> > CentOS7部署kafka服务

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安装部署。 

标签:bin,部署,kafka,CentOS7,usr,host1,linux,root
来源: https://www.cnblogs.com/sunnyyangwang/p/11241435.html