NIFI配置 Bootstrap Properties & Notification Services

本文介绍了如何配置NiFi的Bootstrap Properties,包括Java启动参数和系统属性。同时讲解了NiFi的Notification Services,特别是电子邮件通知服务的设置,详细说明了配置XML文件的位置和语法,并给出了配置示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Bootstrap Properties

conf目录下的bootstrap.conf文件允许用户配置NiFi应该如何启动的设置。 这包括参数,例如Java堆的大小,运行的Java命令以及Java系统属性。

只有在NiFi停止并重新启动之后,对此文件的任何更改才会生效。

PropertyDescription
java指定要运行的完全限定的java命令。 默认情况下,它只是java,但可以改为绝对路径或引用一个环境变量,如$ JAVA_HOME / bin / java
run.as运行NiFi的用户名。 例如,如果NiFi应该作为nifi用户运行,则将此值设置为nifi将导致NiFi进程作为nifi用户运行。 在Windows上忽略此属性。 对于Linux,指定的用户可能需要sudo权限。
lib.dir用于NiFi的lib目录。 默认情况下,它被设置为./lib
conf.dir用于NiFi的conf目录。 默认情况下,它被设置为./conf
graceful.shutdown.seconds当NiFi被指示关闭时,Bootstrap会等待这个秒数,以便进程彻底关闭。 在这段时间内,如果服务仍在运行,Bootstrap将“终止”该进程,或强制终止进程。
java.arg.N当进程启动时,任何数量的JVM参数都可以传递给NiFi JVM。 缺省值包括最小和最大Java堆大小的属性,要使用的垃圾回收器等
notification.services.file当NiFi启动或停止时,或Bootstrap检测到NiFi已经死亡时,Bootstrap能够向相关方发送这些事件的通知。 这是通过指定一个定义可以使用哪个通知服务的XML文件来配置的。 有关此文件的更多信息,请参阅通知服务部分。
notification.max.attempts如果配置了通知服务但无法执行其功能,则会再次尝试最多次尝试次数。 该属性配置最大尝试次数。 默认值是5。
nifi.start.notification.services此属性是通知服务标识符的逗号分隔列表,与notification.services.file属性中定义的Notification Services对应。 具有指定标识符的服务将用于在NiFi启动时通知其配置的收件人。
nifi.stop.notification.services此属性是通知服务标识符的逗号分隔列表,与notification.services.file属性中定义的Notification Services对应。 具有指定标识符的服务将用于在NiFi停止时通知其配置的收件人。
nifi.died.notification.services此属性是通知服务标识符的逗号分隔列表,与notification.services.file属性中定义的Notification Services对应。 具有指定标识符的服务将用于在NiFi停止时通知其配置的收件人。

通知服务 Notification Services

当NiFi引导程序启动或停止NiFi,或者检测到它意外死亡时,它可以通知已配置的收件人。 目前,唯一提供的机制是发送电子邮件或HTTP POST通知。 通知服务配置文件是配置通知功能的XML文件。

XML文件的默认位置是conf / bootstrap-notification-services.xml,但可以在conf / bootstrap.conf文件中更改此值。

XML文件的语法如下所示:

<services>
    <!-- any number of service elements can be defined. -->
    <service>
        <id>some-identifier</id>
        <!-- The fully-qualified class name of the Notification Service. -->
        <class>org.apache.nifi.bootstrap.notification.email.EmailNotificationService</class>

        <!-- Any number of properties can be set using this syntax.
             The properties available depend on the Notification Service. -->
        <property name="Property Name 1">Property Value</property>
        <property name="Another Property Name">Property Value 2</property>
    </service>
</services>

一旦配置了所需的服务,就可以在bootstrap.conf文件中引用它们。

电子邮件通知服务Email Notification Service

通过电子邮件发送通知,实现是org.apache.nifi.bootstrap.notification.email.EmailNotificationService。 它具有以下属性:

PropertyRequiredDescription
SMTP Hostnametrue用于发送电子邮件通知的SMTP服务器的主机名
SMTP Porttrue用于SMTP通信的端口
SMTP UsernametrueUsername for the SMTP account
SMTP PasswordPassword for the SMTP account
SMTP AuthFlag indicating whether authentication should be used
SMTP TLS是否应启用TLS的标志
SMTP Socket Factoryjavax.net.ssl.SSLSocketFactory
SMTP X-Mailer Header在发送电子邮件的标题中使用的X-Mailer
Content Type电子邮件内容的MIME类型,例如text / plain或text / html
Fromtrue指定用作发件人的电子邮件地址。
To收件人列表
CCThe recipients to include in the CC-Line of the email
BCCThe recipients to include in the BCC-Line of the email

除了上面标记为必需的属性之外,还必须至少设置一个“收件人”,“抄送”或“密件抄送”属性。

配置电子邮件服务的完整示例如下所示:

  <service>
        <id>email-notification</id>
        <class>org.apache.nifi.bootstrap.notification.email.EmailNotificationService</class>
        <property name="SMTP Hostname">smtp.gmail.com</property>
        <property name="SMTP Port">587</property>
        <property name="SMTP Username">username@gmail.com</property>
        <property name="SMTP Password">super-secret-password</property>
        <property name="SMTP TLS">true</property>
        <property name="From">"NiFi Service Notifier"</property>
        <property name="To">username@gmail.com</property>
     </service>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值