============================================================
INSTALL SINGLE INSTANCE OF APACHE NIFI 

Date: Wed Feb  4 10:41:35 AM EST 2026

OS: Linux
Platform: Rocky Linux 9.6
Hadoop Version: 3.3.6
Java Version: java-11-openjdk.aarch64
Java Version: java-11-openjdk.x86_64
============================================================

# NOTE: Newer version of NiFi require secure TLS keys to operatei (https).
# This version cn be maed to work with basic http access.

# Basic LHM install procedure for NiFi 1.17.0 follows.

# The following may need some additional configuration for your environment.
#
# As will all other packages, pull down the bin archive into /tmp 
# and install in /opt (alos include the Nifi

  wget --no-check-certificate -P /tmp https://archive.apache.org/dist/nifi/1.17.0/nifi-1.17.0-bin.zip
  unzip /tmp/nifi-1.17.0-bin.zip -d /opt

  wget --no-check-certificate -P /tmp https://archive.apache.org/dist/nifi/1.17.0/nifi-toolkit-1.17.0-bin.zip
  unzip /tmp/nifi-toolkit-1.17.0-bin.zip -d /opt

# set user profile for NiFi

  echo 'export PATH=$PATH:/opt/nifi-1.17.0/bin:/opt/nifi-toolkit-1.17.0/bin; export NIFI_HOME=/opt/nifi-1.17.0' >/etc/profile.d/nifi.sh

# Once NiFi is extracted into /opt, the follwing steps will make
# copies of the original configuration file and env file, then 
# replace them with versions that work on the LHM.
# (original files were also copied to the files and scripts directory)

 /bin/cp /opt/nifi-1.17.0/conf/nifi.properties /opt/nifi-1.17.0/conf/nifi.properties.orig
 /bin/cp files/nifi.properties /opt/nifi-1.17.0/conf
 /bin/cp files/nifi.properties.template /opt/nifi-1.17.0/conf
 /bin/cp /opt/nifi-1.17.0/bin/nifi-env.sh /opt/nifi-1.17.0/bin/nifi-env.sh.orig
 /bin/cp scripts/nifi-env.sh /opt/nifi-1.17.0/bin


Hive Support
------------

# In order to support Hive v3 (3.1.2 is installed) two additional nar files
# from the Nifi repository are needed) These files are placed in
# the /opt/nifi-VERSION/lib directoy (using wget)

  wget -P /opt/nifi-1.17.0/lib https://repository.apache.org/content/repositories/releases/org/apache/nifi/nifi-hive3-nar/1.17.0/nifi-hive3-nar-1.17.0.nar

  wget -P /opt/nifi-1.17.0/lib https://repository.apache.org/content/repositories/releases/org/apache/nifi/nifi-hive-services-api-nar/1.17.0/nifi-hive-services-api-nar-1.17.0.nar

Create Nifi User and Log Directory
----------------------------------

# Create a NiFi user and change ownership (do as root)

  useradd nifi -g hadoop
  chown -R nifi:hadoop /opt/nifi-1.17.0
  chown -R nifi:hadoop /opt/nifi-toolkit-1.17.0 

# provide password for nifi user (nifiLHM)

  echo "nifi:nifiLHM" | chpasswd

# Create HDFS /user/nifi working directory (as root become user hdfs)
# Not strickly need, however, the Nifi example uses this directory
# data

  su - hdfs
  hdfs dfs -mkdir /user/nifi
  hdfs dfs -chown nifi:hadoop /user/nifi
  exit

# make the log directory (nifi-env.sh has been modified to use /tmp/nifi)

  mkdir /var/log/nifi
  chown nifi:hadoop /var/log/nifi

# Config NiFi Tools for user nifi !! double check base URL IP

  cat << EOF > /home/nifi/.nifi-cli.config
  nifi.props=/home/nifi/.nifi-cli.config
  baseUrl=http\://10.0.2.15\:18085
  EOF

  chown nifi:hadoop /home/nifi/.nifi-cli.config

Start-up/Shut-down Systemd
--------------------------

# Copy Systemd nifi start and stop scripts to /opt/services

  cp scripts/*-nifi.sh /opt/services/
  chown nifi:hadoop /opt/services/*-nifi.sh
  chmod u+x /opt/services/*-nifi.sh

# Copy the systemd service script

  cp files/nifi.service /etc/systemd/system

# Run the following if you want Nifi to start when the system
# boots. If you do not plan on using NiFi, it is RECOMENDED
# that you DO NOT enable NiFi to automatically start (preserves
# resources)

  systemctl enable nifi.service

# To disable NiFi from starting automatically (after using the
# comand above) run the following:

  systemctl disable nifi.service

# Without auto-start, use Systemd to start, stop Nifi:
 
  systemctl start nifi
  systemctl stop nifi

# The start and stop scripts used by Systemd are located in
# /opt/services. You should not have to use these scripts

  /opt/services/start-nifi.sh
  /opt/services/stop-nifi.sh

Testing:
========
# The logs are in /var/log/nifi.
# Once Nifi is started, the Web UI should be available at

  http://localhost:18085/nifi/

# from your host computer. Be aware it may take several minutes
# for the UI to become ready ater NifFi starts.

