Kafka系统列1、Kafka的安装(单机&集群)
一、软件下载和准备
1、Zookeeper & Kafka下载
Zookeeper 下载地址: http://www.apache.org/dyn/closer.cgi/zookeeper/ 或 http://distfiles.macports.org/zookeeper/zookeeper-3.4.6.tar.gz
Kafka下载地址: http://kafka.apache.org/downloads 或 https://www.apache.org/dyn/closer.cgi?path=/kafka/2.5.0/kafka_2.12-2.5.0.tgz
二、安装软件
1、Zookeeper的单机&集群安装
$ tar -zxvf zookeeper-3.4.6.tar.gz# 设置环境变量
$ vim /root/.bash_profile
export ZOOKEEPER_HOME=/data/app/zookeeper-3.4.6
PATH=$PATH:$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin
$ source /root/.bash_profile
# 配置Zookeeper
$ cd /data/app/zookeeper-3.4.6/conf
$ mv zoo_sample.cfg zoo.cfg
# 集群规划,Zookeeper 规划3台node1 node2 node3 ID分别为 1 2 3 (node1~3 可换成对应IP)
# 如果是单机,只需要配置一个Server
$ vim zoo.cfg
server.1=node1:2888:3888
server.2=node2:2888:3888
server.3=node3:2888:3888
# 设置myid 分别在node1 node2 node3的conf目录下写入 1 2 3
$ vim myid
# 写入
1
# 启动Zookeeper ,分别启动三台
$ bin/zkServer.sh start
JMX enabled by default
Using config: /data/app/zookeeper-3.4.6/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
# jps查看启动结果
$ jps
8210 Kafka
6900 QuorumPeerMain
8654 Jps
也可以通过客户端连接Zookeeper 客户端下载地址: https://issues.apache.org/jira/secure/attachment/12436620/ZooInspector.zip
2、安装Kafka
$ tar -zxvf kafka_2.12-2.5.0.tgz$ cd kafka_2.12-2.5.0
# 配置环境变量
export ZOOKEEPER_HOME=/data/app/zookeeper-3.4.6
export KAFKA_HOME=/data/app/kafka_2.12-2.5.0
PATH=$PATH:$JAVA_HOME/bin:$ZOOKEEPER_HOME/bin:$KAFKA_HOME/bin
# 配置文件
$ cd kafka_2.12-2.5.0/config
$ vim server.properties
# 单机配置一个Zookeeper就行了,多台Kafka的broker.id不能相同
broker.id=1
zookeeper.connect=node1:2181,node2:2181,node3:2181
log.dirs=/opt/data/kafka-logs
num.partitions=3
#启动Kafka
$ cd kafka_2.12-2.5.0
$ bin/kafka-server-start.sh ./config/server.properties &
# 查看
$ jps
8210 Kafka
6900 QuorumPeerMain
8654 Jps
启动成功后,可以通过Zookeeper的客户端工具查看:
本文参考:
https://www.cnblogs.com/sandea/p/12078442.html
以上是 Kafka系统列1、Kafka的安装(单机&集群) 的全部内容, 来源链接: utcz.com/z/519158.html