Nifi详细部署(配置文件,单节点,集群,性能优化)

2024-04-10 08:58

本文主要是介绍Nifi详细部署(配置文件,单节点,集群,性能优化),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Nifi部署

文章目录

  • Nifi部署
    • 前言
      • 信息
      • 引用
    • 单节点部署
      • 简单配置
        • 修改使用的JDK
        • 修改Nifi端口
        • 配置Nifi使用的内存
      • 启动
      • 命令
      • 配置文件详解
        • bootstrap.conf
        • nifi.properties
    • 集群搭建
      • 步骤目录
      • 准备Zookeeper配置文件
      • 准备节点1的配置
      • 准备节点2的配置
      • 准备节点3的配置
      • Docker的配置
    • Nifi性能优化
      • 1.配置最大文件句柄
      • 2.配置最大派生进程数
      • 3.配置TCP Socket端口数
      • 4.设置Socket套接字停留时间
      • 5.禁止SWAP
      • 6.对Repository禁用atime
      • 7.排除防病毒扫描目录

前言

信息

Author: Tine Aine

Version: 1.0

protocol: None

UpdateDate: 2021年1月28日16:45:46

引用

Apache Document

单节点部署

简单配置

一般情况下nifi官方包开箱即用,不需要进行额外配置,不过默认使用的http端口为8080,极有可能和其他程序发送冲突,因此要着重关注

修改使用的JDK
vi /usr/local/nifi/bin/nifi.env.sh

其中文件改为:

export JAVA_HOME=/usr/local/jdk1.8.0_144
修改Nifi端口
vi /usr/local/nifi/bin/nifi.properties

其中内容修改为:

# nifi使用的端口,默认8080
nifi.web.http.port=9802
配置Nifi使用的内存
vi /usr/local/nifi/conf/bootstarp.conf

其中内容修改为:

# 可以修改使用的内存
java.arg.2=-Xms4096m
java.arg.3=-Xmx8192m

启动

#!/bin/sh
#
#    Licensed to the Apache Software Foundation (ASF) under one or more
#    contributor license agreements.  See the NOTICE file distributed with
#    this work for additional information regarding copyright ownership.
#    The ASF licenses this file to You under the Apache License, Version 2.0
#    (the "License"); you may not use this file except in compliance with
#    the License.  You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.# Script structure inspired from Apache Karaf and other Apache projects with similar startup approaches# Discover the path of the file# Since MacOS X, FreeBSD and some other systems lack gnu readlink, we use a more portable
# approach based on following StackOverflow comment http://stackoverflow.com/a/1116890/888876TARGET_FILE=$0cd $(dirname $TARGET_FILE)
TARGET_FILE=$(basename $TARGET_FILE)# Iterate down a (possible) chain of symlinks
while [ -L "$TARGET_FILE" ]
doTARGET_FILE=$(readlink $TARGET_FILE)cd $(dirname $TARGET_FILE)TARGET_FILE=$(basename $TARGET_FILE)
done# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
PHYS_DIR=$(pwd -P)SCRIPT_DIR=$PHYS_DIR
PROGNAME=$(basename "$0"). "${SCRIPT_DIR}/nifi-env.sh"warn() {echo "${PROGNAME}: $*"
}die() {warn "$*"exit 1
}detectOS() {# OS specific support (must be 'true' or 'false').cygwin=false;aix=false;os400=false;darwin=false;case "$(uname)" inCYGWIN*)cygwin=true;;AIX*)aix=true;;OS400*)os400=true;;Darwin)darwin=true;;esac# For AIX, set an environment variableif ${aix}; thenexport LDR_CNTRL=MAXDATA=0xB0000000@DSAecho ${LDR_CNTRL}fi# In addition to those, go around the linux space and query the widely# adopted /etc/os-release to detect linux variantsif [ -f /etc/os-release ]; then. /etc/os-releasefi
}unlimitFD() {# Use the maximum available, or set MAX_FD != -1 to use thatif [ "x${MAX_FD}" = "x" ]; thenMAX_FD="maximum"fi# Increase the maximum file descriptors if we canif [ "${os400}" = "false" ] && [ "${cygwin}" = "false" ]; thenMAX_FD_LIMIT=$(ulimit -H -n)if [ "${MAX_FD_LIMIT}" != 'unlimited' ]; thenif [ $? -eq 0 ]; thenif [ "${MAX_FD}" = "maximum" -o "${MAX_FD}" = "max" ]; then# use the system maxMAX_FD="${MAX_FD_LIMIT}"fiulimit -n ${MAX_FD} > /dev/null# echo "ulimit -n" `ulimit -n`if [ $? -ne 0 ]; thenwarn "Could not set maximum file descriptor limit: ${MAX_FD}"fielsewarn "Could not query system maximum file descriptor limit: ${MAX_FD_LIMIT}"fififi
}locateJava() {# Setup the Java Virtual Machineif $cygwin ; then[ -n "${JAVA}" ] && JAVA=$(cygpath --unix "${JAVA}")[ -n "${JAVA_HOME}" ] && JAVA_HOME=$(cygpath --unix "${JAVA_HOME}")fiif [ "x${JAVA}" = "x" ] && [ -r /etc/gentoo-release ] ; thenJAVA_HOME=$(java-config --jre-home)fiif [ "x${JAVA}" = "x" ]; thenif [ "x${JAVA_HOME}" != "x" ]; thenif [ ! -d "${JAVA_HOME}" ]; thendie "JAVA_HOME is not valid: ${JAVA_HOME}"fiJAVA="${JAVA_HOME}/bin/java"elsewarn "JAVA_HOME not set; results may vary"JAVA=$(type java)JAVA=$(expr "${JAVA}" : '.* \(/.*\)$')if [ "x${JAVA}" = "x" ]; thendie "java command not found"fififi# if command is env, attempt to add more to the classpathif [ "$1" = "env" ]; then[ "x${TOOLS_JAR}" =  "x" ] && [ -n "${JAVA_HOME}" ] && TOOLS_JAR=$(find -H "${JAVA_HOME}" -name "tools.jar")[ "x${TOOLS_JAR}" =  "x" ] && [ -n "${JAVA_HOME}" ] && TOOLS_JAR=$(find -H "${JAVA_HOME}" -name "classes.jar")if [ "x${TOOLS_JAR}" =  "x" ]; thenwarn "Could not locate tools.jar or classes.jar. Please set manually to avail all command features."fifi}init() {# Determine if there is special OS handling we must performdetectOS# Unlimit the number of file descriptors if possibleunlimitFD# Locate the Java VM to executelocateJava "$1"
}install() {detectOSif [ "${darwin}" = "true"  ] || [ "${cygwin}" = "true" ]; thenecho 'Installing Apache NiFi as a service is not supported on OS X or Cygwin.'exit 1fiSVC_NAME=nifiif [ "x$2" != "x" ] ; thenSVC_NAME=$2fi# since systemd seems to honour /etc/init.d we don't still create native systemd services# yet...initd_dir='/etc/init.d'SVC_FILE="${initd_dir}/${SVC_NAME}"if [ ! -w  "${initd_dir}" ]; thenecho "Current user does not have write permissions to ${initd_dir}. Cannot install NiFi as a service."exit 1fi# Create the init script, overwriting anything currently present
cat <<SERVICEDESCRIPTOR > ${SVC_FILE}
#!/bin/sh#
#    Licensed to the Apache Software Foundation (ASF) under one or more
#    contributor license agreements.  See the NOTICE file distributed with
#    this work for additional information regarding copyright ownership.
#    The ASF licenses this file to You under the Apache License, Version 2.0
#    (the "License"); you may not use this file except in compliance with
#    the License.  You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
#
# chkconfig: 2345 20 80
# description: Apache NiFi is a dataflow system based on the principles of Flow-Based Programming.
## Make use of the configured NIFI_HOME directory and pass service requests to the nifi.sh executable
NIFI_HOME=${NIFI_HOME}
bin_dir=\${NIFI_HOME}/bin
nifi_executable=\${bin_dir}/nifi.sh\${nifi_executable} "\$@"
SERVICEDESCRIPTORif [ ! -f "${SVC_FILE}" ]; thenecho "Could not create service file ${SVC_FILE}"exit 1fi# Provide the user execute access on the filechmod u+x ${SVC_FILE}# If SLES or OpenSuse...if [ "${ID}" = "opensuse" ] || [ "${ID}" = "sles" ]; thenrm -f "/etc/rc.d/rc2.d/S65${SVC_NAME}"ln -s "/etc/init.d/${SVC_NAME}" "/etc/rc.d/rc2.d/S65${SVC_NAME}" || { echo "Could not create link /etc/rc.d/rc2.d/S65${SVC_NAME}"; exit 1; }rm -f "/etc/rc.d/rc2.d/K65${SVC_NAME}"ln -s "/etc/init.d/${SVC_NAME}" "/etc/rc.d/rc2.d/K65${SVC_NAME}" || { echo "Could not create link /etc/rc.d/rc2.d/K65${SVC_NAME}"; exit 1; }echo "Service ${SVC_NAME} installed"# Anything other fallback to the old approachelse

这篇关于Nifi详细部署(配置文件,单节点,集群,性能优化)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


原文地址:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/890618

相关文章

Java进程CPU使用率过高排查步骤详细讲解

《Java进程CPU使用率过高排查步骤详细讲解》:本文主要介绍Java进程CPU使用率过高排查的相关资料,针对Java进程CPU使用率高的问题,我们可以遵循以下步骤进行排查和优化,文中通过代码介绍... 目录前言一、初步定位问题1.1 确认进程状态1.2 确定Java进程ID1.3 快速生成线程堆栈二、分析

Java中的登录技术保姆级详细教程

《Java中的登录技术保姆级详细教程》:本文主要介绍Java中登录技术保姆级详细教程的相关资料,在Java中我们可以使用各种技术和框架来实现这些功能,文中通过代码介绍的非常详细,需要的朋友可以参考... 目录1.登录思路2.登录标记1.会话技术2.会话跟踪1.Cookie技术2.Session技术3.令牌技

Macos创建python虚拟环境的详细步骤教学

《Macos创建python虚拟环境的详细步骤教学》在macOS上创建Python虚拟环境主要通过Python内置的venv模块实现,也可使用第三方工具如virtualenv,下面小编来和大家简单聊聊... 目录一、使用 python 内置 venv 模块(推荐)二、使用 virtualenv(兼容旧版 P

JVisualVM之Java性能监控与调优利器详解

《JVisualVM之Java性能监控与调优利器详解》本文将详细介绍JVisualVM的使用方法,并结合实际案例展示如何利用它进行性能调优,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全... 目录1. JVisualVM简介2. JVisualVM的安装与启动2.1 启动JVisualVM2

Java使用MethodHandle来替代反射,提高性能问题

《Java使用MethodHandle来替代反射,提高性能问题》:本文主要介绍Java使用MethodHandle来替代反射,提高性能问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑... 目录一、认识MethodHandle1、简介2、使用方式3、与反射的区别二、示例1、基本使用2、(重要)

Python实现一键PDF转Word(附完整代码及详细步骤)

《Python实现一键PDF转Word(附完整代码及详细步骤)》pdf2docx是一个基于Python的第三方库,专门用于将PDF文件转换为可编辑的Word文档,下面我们就来看看如何通过pdf2doc... 目录引言:为什么需要PDF转Word一、pdf2docx介绍1. pdf2docx 是什么2. by

Logback在SpringBoot中的详细配置教程

《Logback在SpringBoot中的详细配置教程》SpringBoot默认会加载classpath下的logback-spring.xml(推荐)或logback.xml作为Logback的配置... 目录1. Logback 配置文件2. 基础配置示例3. 关键配置项说明Appender(日志输出器

SpringBoot实现多环境配置文件切换

《SpringBoot实现多环境配置文件切换》这篇文章主要为大家详细介绍了如何使用SpringBoot实现多环境配置文件切换功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1. 示例代码结构2. pom文件3. application文件4. application-dev文

Web技术与Nginx网站环境部署教程

《Web技术与Nginx网站环境部署教程》:本文主要介绍Web技术与Nginx网站环境部署教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、Web基础1.域名系统DNS2.Hosts文件3.DNS4.域名注册二.网页与html1.网页概述2.HTML概述3.

Java内存区域与内存溢出异常的详细探讨

《Java内存区域与内存溢出异常的详细探讨》:本文主要介绍Java内存区域与内存溢出异常的相关资料,分析异常原因并提供解决策略,如参数调整、代码优化等,帮助开发者排查内存问题,需要的朋友可以参考下... 目录一、引言二、Java 运行时数据区域(一)程序计数器(二)Java 虚拟机栈(三)本地方法栈(四)J