美文网首页
NiFi的分布式安装与启动

NiFi的分布式安装与启动

作者: 涛O_O | 来源:发表于2018-12-19 21:30 被阅读53次

1 简介

NiFi是一个易用、可靠、功能强大的数据处理与分发系统,是Apache的开源项目。只需在web界面中用拖拽的方式定义数据处理节点,数据处理流程和配置相关参数,NiFi即可自动完成复杂的数据处理任务,非常方便。

这里介绍NiFi 1.8.0的安装和启动方法。

2 安装

NiFi的安装使用非常简单,只需配置好JAVA环境,将官网上下载的NiFi二进制包解压,然后进入bin目录,执行./nifi.sh start,即可启动NiFi。

当然,这种方式运行的是单机版的NiFi,如果要进行分布式安装,还需要进行其他一些配置。

分布式的NiFi需要使用Zookeeper作为集群的管理工具,NiFi本身内置了Zookeeeper,也可以使用独立安装的Zookeeper。

2.1 使用内置Zookeeper

对每一个节点完成以下配置(建议在一个节点配置好,复制到其他节点再稍作修改)

① 修改conf/zookeeper.properties

clientPort=2181
initLimit=10
autopurge.purgeInterval=24
syncLimit=5
tickTime=2000
dataDir=./state/zookeeper
autopurge.snapRetainCount=30

#
# Specifies the servers that are part of this zookeeper ensemble. For
# every NiFi instance running an embedded zookeeper, there needs to be
# a server entry below. For instance:
#
server.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888
#

最后三行根据集群的实际情况修改

② 在state/zookeeper文件夹下新建myid文件,写入节点编号

mkdir state
mkdir state/zookeeper
echo 1 > state/zookeeper/myid

不同节点写入的标号不同,要与第一步中的server编号对应

③ 修改conf/nifi.properties

#是否启动内置的zk
nifi.state.management.embedded.zookeeper.start=true
#配置zk节点
nifi.zookeeper.connect.string=master:2181,slave1:2181,slave2:2181
#这里配置为非安全性的nifi
nifi.cluster.protocol.is.secure=false
nifi.cluster.is.node=true
nifi.cluster.node.address=master
nifi.cluster.node.protocol.port=11443
nifi.cluster.node.protocol.threads=10
nifi.cluster.node.event.history.size=25
nifi.cluster.node.connection.timeout=5 sec
nifi.cluster.node.read.timeout=5 sec
nifi.cluster.firewall.file=

#各节点Site2Site协议接口配置
nifi.remote.input.host=master
nifi.remote.input.secure=false
nifi.remote.input.socket.port=10443
nifi.remote.input.http.enabled=true
nifi.remote.input.http.transaction.ttl=30 sec

#web ui
nifi.web.http.host=master
nifi.web.http.port=8080

其他节点需要根据实际情况修改host为节点的主机名(slave1,slave2等)

Slave1:

nifi.remote.input.host=slave1
nifi.web.http.host=slave1
nifi.cluster.node.address=slave1

Slave2:

nifi.remote.input.host=slave2
nifi.web.http.host=slave2
nifi.cluster.node.address=slave2

④ 修改conf/state-management.xml

<cluster-provider>
  <id>zk-provider</id>
  <class>org.apache.nifi.controller.state.providers.zookeeper.ZooKeeperStateProvider</class>
  <property name="Connect String">master:2181,slave1:2181,slave2:2181</property>
  <property name="Root Node">/nifi</property>
  <property name="Session Timeout">10 seconds</property>
  <property name="Access Control">Open</property>
</cluster-provider>

主要是修改Connect String,和第三步中的nifi.zookeeper.connect.string一致。

2.2 使用独立的Zookeeper

配置步骤比使用内置的Zookeeper方法要简单,对比来看:

① 无需修改conf/zookeeper.properties,保持默认配置即可。
(即无需定义server.1,server.2,server.3等条目)

② 无需在state/zookeeper文件夹下新建myid文件

③ 修改conf/nifi.properties
与使用内置的Zookeeper配置基本相同,不同的配置是:

#是否启动内置的zk
nifi.state.management.embedded.zookeeper.start=false

其他配置一致,按独立安装的Zookeeper实际情况填写。

④ 修改conf/state-management.xml
与使用内置的Zookeeper配置相同,按独立安装的Zookeeper实际情况填写。

3 启动

在每一个节点中执行命令:

nifi/bin/nifi.sh start

启动需要一定的时间,jps查看NiFi进程是否成功启动:

2162 RunNiFi
2178 NiFi
1413 QuorumPeerMain
2330 Jps

从任意一个节点访问http://localhost:8080/nifi即可访问NiFi主界面。(端口以配置文件中的为准)

成功启动.png 查看节点.png

4 关闭

在每一个节点中执行命令:

nifi/bin/nifi.sh stop

可能遇到的问题

  1. 端口冲突
    若logs/nifi-bootstrap.log中出现“Address already in use”,则说明端口冲突,修改conf/nifi.properties中的nifi.web.http.port。NiFi的Web端口默认是8080,很容易与其他应用,建议修改。

  2. 集群启动后,无法打开web页面
    集群启动后,有一个选取主节点的过程,在此期间可能无法访问web页面或者提示与集群断开连接,等待一会儿后(5-8分钟)即可恢复正常。

参考资料

NiFi安装(单机+集群)
NIFI1.7.1安装
官方文档

相关文章

  • NiFi的分布式安装与启动

    1 简介 NiFi是一个易用、可靠、功能强大的数据处理与分发系统,是Apache的开源项目。只需在web界面中用拖...

  • 使用NiFi将数据从Mysql导入至HBase

    1. 启动并登录NiFi 1.1 在本机启动nifi ./bin/nifi.sh start 1.2 登录nifi...

  • Apache NiFi初体验

    安装与使用从官网下载zip包解压,执行./bin/run-nifi.bat即可启动,默认端口8080,打开浏览器h...

  • NiFi安装(单机+集群)

    单机版安装 NIFI下载 地址:http://nifi.apache.org/download.html [图片上...

  • 2019-06-25

    在CentOS7中安装配置单机nifi的方法 首先需要安装Java jdk,因为nifi是Java语言编写的,在配...

  • NiFi UI与创建流程

    1. NiFi主界面 NiFi启动后,我们可以使用浏览器访问用户界面http://localhost:8080/n...

  • NIFI-安装配置

    1.下载安装包 NIFI官方下载地址 nifi-1.11.4-bin.tar.gz 2.解压 上传到linux随便...

  • Apache NiFi 安装

    Apache NiFi 是一个易于使用、功能强大而且可靠的数据处理和分发系统。Apache NiFi 是为数据流设...

  • Apache NiFi如何工作?

    什么是Apache NiFi Apache NiFi官网对NiFi的定义如下: An easy to use, p...

  • NiFi 授权配置

    NiFi 授权配置 通过证书授权 下载nifi-toolkit nifi-toolkit-1.6.0-bin.ta...

网友评论

      本文标题:NiFi的分布式安装与启动

      本文链接:https://www.haomeiwen.com/subject/gfdskqtx.html