1.安装JDK
目前官网不能直接下载,在网上找到1.8.0版本安装包下载到本地。
1.1.下载jdk并解压
[root@iz2zei2y693gtrgwlibzlwz java]# ls jdk1.8.0_191 jdk-8u191-linux-x64.tar.gz
1.2.配置java环境变量
在文件中/etc/profile追加配置:
export JAVA_HOME=/usr/local/java/jdk1.8.0_191 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
使配置生效
[root@iz2zei2y693gtrgwlibzlwz java]# source /etc/profile
1.3.验证jdk是否安装成功
[root@iz2zei2y693gtrgwlibzlwz java]# java -version java version "1.8.0_191" Java(TM) SE Runtime Environment (build 1.8.0_191-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)
2.安装zookeeper
2.1.下载
http://zookeeper.apache.org/releases.html
2.2.解压
tar –zxvf zookeeper-3.4.10.tar.gz
2.3.复制conf目录下的zoo_sample.cfg,并命名为zoo.cfg
2.4.修改zoo.cfg配置文件
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/usr/local/zookeeper/zookeeper-3.4.10/data
dataLogDir=/usr/local/zookeeper/zookeeper-3.4.10/logs
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
#2888,3888 are election port
server.1=39.**.**.**:2888:3888 #改成自己ip
其中,2888端口号是服务之间通信的端口,而3888是;zookeeper与其他应用程序通信的端口.
2.5.创建myid文件
创建dataDir参数指定的目录(这里指的是“/usr/local/zookeeper/zookeeper-3.4.10/data”),并在目录下创建文件,命名为“myid”。
2.6.编辑myid文件
在对应的IP的机器上输入对应的编号。如在zookeeper上,“myid”文件内容就是1。由于本次只在单点上进行安装配置,所以只有一个server.1。若还有其他服务器,比如地址为192.168.1.102,则在zoo.cfg文件中还需加入server.2=192.168.1.102:2888:3888。那么myid文件在192.168.1.102服务器上的内容就是2。至此,如果是多服务器配置,就需要将zookeeper-3.4.3目录拷贝到其他服务器,然后按照上述的方法修改myid。
2.7.在/etc/profile文件设置PATH
在profile文件尾追加:
export PATH=$PATH:/usr/local/zookeeper/zookeeper-3.4.10/bin
安装完毕!
2.8.启动
zkServer.sh start
输入jps命令查看进程
1573 QuorumPeerMain 1654 Jps
其中,QuorumPeerMain是zookeeper进程,启动正常。
查看状态:zkServer.sh status
- JMX enabled by default Using config: /usr/local/zookeeper-3.4.6/bin/../conf/zoo.cfg Mode: standalone
启动客户端脚本:zkCli.sh -server ip:2181
停止zookeeper进程:zkServer.sh stop
3.安装kafka
下载地址:https://mirrors.cnnic.cn/apache/kafka
3.1.下载kafka
wget https://mirrors.cnnic.cn/apache/kafka/2.1.0/kafka_2.11-2.1.0.tgz
解压
tar -zxvf kafka_2.12-1.1.0.tgz
3.2.配置kafka环境变量
在/etc/profile文件中追加配置:
export KAFKA_HOME=/usr/local/kafka/kafka_2.11-2.1.0 export PATH=$KAFKA_HOME/bin:$PATH
使配置生效
[root@iz2zei2y693gtrgwlibzlwz kafka]# source /etc/profile
3.3.验证kafka是否安装成功
[root@iz2zei2y693gtrgwlibzlwz kafka]# echo $KAFKA_HOME /usr/local/kafka/kafka_2.11-2.1.0
3.4.修改kafka配置文件中以下配置
broker.id=0 listeners=PLAINTEXT://:9092 advertised.listeners=PLAINTEXT://你的ip:9092 zookeeper.connect=localhost:2181
3.4.启动kafka服务
[root@iz2zei2y693gtrgwlibzlwz config]# kafka-server-start.sh -daemon $KAFKA_HOME/config/server.properties
[root@iz2zei2y693gtrgwlibzlwz config]# jps 24177 QuorumPeerMain 899 Kafka 8506 Jps
3.4.关闭服务
先关闭kafka,在关闭zookeeper
kafka-server-stop.sh
zookeeper-server-stop.sh
查看服务是否已关闭
[root@localhost ~]# jps 15462 Jps