一、安装前准备

1、设置主机名、主机解析

[root@localhost ~]# hostnamectl set-hostname test06              
[root@test06 ~]# echo "172.16.1.16   test06" > /etc/hosts
[root@test06 ~]# bash

2、关闭SELINUX、防火墙

[root@test06 ~]# setenforce 0
[root@test06 ~]# sed -i 's/enforcing/disabled/' /etc/selinux/config	
		
[root@test06 ~]# systemctl stop firewalld && systemctl disable firewalld

3、配置时间同步

[root@test06 ~]# yum -y install ntp
[root@test06 ~]# \cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@test06 ~]# ntpdate cn.pool.ntp.org

[root@test06 ~]# systemctl start ntpdate && systemctl enable ntpdate

二、安装准备JDK

1、安装JDK

[root@test06 ~]# tar -zxvf jdk-8u131-linux-x64.tar.gz -C /usr/local/
[root@test06 ~]# cd /usr/local/jdk1.8.0_131/bin

[root@test06 bin]# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

[root@hadoop01 bin]# pwd
/usr/local/jdk1.8.0_131/bin

2、配置 JAVA 环境变量

[root@test06 ~]# cp /etc/profile /etc/profile.bak

[root@test06 ~]# cat << EOF >> /etc/profile
> export JAVA_HOME=/usr/local/jdk1.8.0_131
> export PATH=.:$PATH:$JAVA_HOME/bin
> EOF

[root@hadoop01 ~]# source /etc/profile

[root@test06 ~]# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

三、安装部署 Zookeeper

1、上传并解压缩安装包

[root@test06 ~]# tar -zxvf zookeeper-3.4.14.tar.gz -C /usr/local/
[root@test06 ~]# mv zookeeper-3.4.14 zookeeper
[root@test06 ~]# cd /usr/local/zookeeper/conf

2、修改配置文件

[root@test06 conf]# cp zoo_sample.cfg zoo.cfg
[root@test06 conf]# vim zoo.cfg

......
dataDir=/data/zookeeper/data
dataLogDir=/data/zookeeper/logs
......
server.1=172.16.1.16:2888:3888 

3、创建数据目录、日志文件目录、MYID文件

[root@test06 ~]# mkdir -p /data/zookeeper/{data,logs}
[root@test06 ~]# echo "1" > /data/zookeeper/data/myid

四、启动 Zookeeper

1、启动 ZOOKEEPER

[root@test06 ~]# cd /usr/local/zookeeper/bin/
[root@test06 ~]# zkServer.sh start

查看下集群的节点状态
[root@test06 bin]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Mode: standalone

2、配置Zookeeper的环境变量 ( 非必须 )

[root@test06 ~]# cat << EOF >> /etc/profile
> export ZOOKEEPER_HOME=/usr/local/zookeeper
> export PATH=.:$PATH:$ZOOKEEPER_HOME/bin
> EOF
[root@test06 ~]# source /etc/profile

[root@test06 ~]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Mode: standalone

五、安装部署KAFKA

1、上传并解压缩安装包

[root@test06 ~]# tar -zxvf kafka_2.11-2.3.0.tgz -C ../
[root@test06 ~]# mv kafka_2.11-2.3.0  kafka
[root@test06 ~]# cd /usr/local/kafka/config

2、修改配置文件

[root@test06 ~]# cp server.properties server.properties.default

[root@test06 ~]# vim server.properties
broker.id=1
listeners=PLAINTEXT://0.0.0.0:9092
advertised.listeners=PLAINTEXT://172.16.1.16:9092
log.dirs=/data/kafka/logs
zookeeper.connect=172.16.1.16:2181

3、创建数据目录

[root@test06 ~]# mkdir -p /data/kafka/logs

六、启动KAFKA

1、启动并验证集群

[root@test06 ~]# /usr/local/kafka/bin/kafka-server-start.sh -daemon /usr/local/kafka/config/server.properties

[root@test06 ~]# netstat -lntp | grep 9092
tcp6       0      0 172.161.1.16:9092        :::      LISTEN      2500/java

#  查看kafka的进程 ( 下面截图的是输出的前三四行 )
[root@test06 ~]# ps -ef | grep kafka 
root      2500     1  8 May24 ?        1-03:52:47 /usr/local/java/jdk1.8.0_201/bin/java -Xmx1G -Xms1G -server -XX:+UseG1GC -XX:MaxGCPauseMillis=20 -XX:InitiatingHeapOccupancyPercent=35 -XX:+ExplicitGCInvokesConcurrent -Djava.awt.headless=true -Xloggc:/usr/local/kafka/bin/../logs/kafkaServer-gc.log -verbose:gc -XX:+PrintGCDetails -

2、配置KAFKA的环境变量 ( 非必须 )

[root@test06 ~]# cat << EOF >> /etc/profile
> export KAFKA_HOME=/usr/local/kafka
> export PATH=.:$PATH:$KAFKA_HOME/bin
> EOF

[root@test06 ~]# source /etc/profile