Nifi部署
文章目录
前言
信息
Author: Tine Aine
Version: 1.0
protocol: None
UpdateDate: 2021年1月28日16:45:46
引用
单节点部署
简单配置
一般情况下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/888876
TARGET_FILE=$0
cd $(dirname $TARGET_FILE)
TARGET_FILE=$(basename $TARGET_FILE)
# Iterate down a (possible) chain of symlinks
while [ -L "$TARGET_FILE" ]
do
TARGET_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)" in
CYGWIN*)
cygwin=true
;;
AIX*)
aix=true
;;
OS400*)
os400=true
;;
Darwin)
darwin=true
;;
esac
# For AIX, set an environment variable
if ${aix}; then
export LDR_CNTRL=MAXDATA=0xB0000000@DSA
echo ${LDR_CNTRL}
fi
# In addition to those, go around the linux space and query the widely
# adopted /etc/os-release to detect linux variants
if [ -f /etc/os-release ]; then
. /etc/os-release
fi
}
unlimitFD() {
# Use the maximum available, or set MAX_FD != -1 to use that
if [ "x${MAX_FD}" = "x" ]; then
MAX_FD="maximum"
fi
# Increase the maximum file descriptors if we can
if [ "${os400}" = "false" ] && [ "${cygwin}" = "false" ]; then
MAX_FD_LIMIT=$(ulimit -H -n)
if [ "${MAX_FD_LIMIT}" != 'unlimited' ]; then
if [ $? -eq 0 ]; then
if [ "${MAX_FD}" = "maximum" -o "${MAX_FD}" = "max" ]; then
# use the system max
MAX_FD="${MAX_FD_LIMIT}"
fi
ulimit -n ${MAX_FD} > /dev/null
# echo "ulimit -n" `ulimit -n`
if [ $? -ne 0 ]; then
warn "Could not set maximum file descriptor limit: ${MAX_FD}"
fi
else
warn "Could not query system maximum file descriptor limit: ${MAX_FD_LIMIT}"
fi
fi
fi
}
locateJava() {
# Setup the Java Virtual Machine
if $cygwin ; then
[ -n "${JAVA}" ] && JAVA=$(cygpath --unix "${JAVA}")
[ -n "${JAVA_HOME}" ] && JAVA_HOME=$(cygpath --unix "${JAVA_HOME}")
fi
if [ "x${JAVA}" = "x" ] && [ -r /etc/gentoo-release ] ; then
JAVA_HOME=$(java-config --jre-home)
fi
if [ "x${JAVA}" = "x" ]; then
if [ "x${JAVA_HOME}" != "x" ]; then
if [ ! -d "${JAVA_HOME}" ]; then
die "JAVA_HOME is not valid: ${JAVA_HOME}"
fi
JAVA="${JAVA_HOME}/bin/java"
else
warn "JAVA_HOME not set; results may vary"
JAVA=$(type java)
JAVA=$(expr "${JAVA}" : '.* \(/.*\)$')
if [ "x${JAVA}" = "x" ]; then
die "java command not found"
fi
fi
fi
# if command is env, attempt to add more to the classpath
if [ "$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" ]; then
warn "Could not locate tools.jar or classes.jar. Please set manually to avail all command features."
fi
fi
}
init() {
# Determine if there is special OS handling we must perform
detectOS
# Unlimit the number of file descriptors if possible
unlimitFD
# Locate the Java VM to execute
locateJava "$1"
}
install() {
detectOS
if [ "${darwin}" = "true" ] || [ "${cygwin}" = "true" ]; then
echo 'Installing Apache NiFi as a service is not supported on OS X or Cygwin.'
exit 1
fi
SVC_NAME=nifi
if [ "x$2" != "x" ] ; then
SVC_NAME=$2
fi
# 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}" ]; then
echo "Current user does not have write permissions to ${initd_dir}. Cannot install NiFi as a service."
exit 1
fi
# 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} "\$@"
SERVICEDESCRIPTOR
if [ ! -f "${SVC_FILE}" ]; then
echo "Could not create service file ${SVC_FILE}"
exit 1
fi
# Provide the user execute access on the file
chmod u+x ${SVC_FILE}
# If SLES or OpenSuse...
if [ "${ID}" = "opensuse" ] || [ "${ID}" = "sles" ]; then
rm -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 approach
else
rm -f "/etc/rc2.d/S65${SVC_NAME}"
ln -s "/etc/init.d/${SVC_NAME}" "/etc/rc2.d/S65${SVC_NAME}" || {
echo "Could not create link /etc/rc2.d/S65${SVC_NAME}"; exit 1; }
rm -f "/etc/rc2.d/K65${SVC_NAME}"
ln -s "/etc/init.d/${SVC_NAME}" "/etc/rc2.d/K65${SVC_NAME}" || {
echo "Could not create link /etc/rc2.d/K65${SVC_NAME}"; exit 1; }
echo "Service ${SVC_NAME} installed"
fi