Bobcares

Apache NiFi Docker Compose | All About

by | Feb 11, 2024

Learn more about Apache NiFi Docker Compose from our experts. Our Apache Support team is here to help you with your questions and concerns.

Apache NiFi Docker Compose | All About

Did you know that NiFi Registry helps with managing data flows and configurations?

Today, we are going to explore the steps to persist NiFi Registry data by mounting volumes, optimizing settings, and more.

Mounting Volumes for Persistence:

NiFi Registry uses two main volumes for data persistence – `flow_storage` and `database`. The former includes buckets and flows, identified by universally unique identifiers.

The directory structure with a bucket inside follows a certain. Additionally, the `database` directory houses a single file for loading buckets and flows from `flow_storage`.

Here is a sample directory structure:

Apache NiFi Docker Compose | All About

For persistent storage, these volumes are mounted to the local machine. Regardless of container restarts or recreations, the files remain intact outside of the container’s influence.

How to set up NiFi Registry

If we have Docker up and running, and specific ports are available, we can easily create the necessary volumes for persistence as seen below:

sudo mkdir -p /opt/nifi
sudo chown -R 1000:1000 /opt/nifi
sudo mkdir -p /opt/dockerfiles/nifi
sudo vi /opt/dockerfiles/nifi/docker-compose.yml

Then, we have to add the following configuration to the `docker-compose.yml` file:

version: '3'
services:
nifi:
cap_add:
- NET_ADMIN # low port bindings
image: apache/nifi
container_name: nifi
ports:
- "8080:8080/tcp" # HTTP interface
- "8443:8443/tcp" # HTTPS interface
- "514:514/tcp" # Syslog
- "514:514/udp" # Syslog
- "2055:2055/udp" # NetFlow
volumes:
- /opt/nifi/drivers:/opt/nifi/nifi-current/drivers
- /opt/nifi/certs:/opt/certs
- nifi-conf:/opt/nifi/nifi-current/conf
restart: unless-stopped
volumes:
nifi-conf:

Then, bring up the containers:
cd /opt/dockerfiles/nifi/
sudo docker-compose up -d

How to Configure NiFi Bootstrap for More

We can optimize performance by adjusting NiFi’s memory settings:

sudo docker exec -u 0 -it nifi bash
apt-get install vim # Install text editor if needed
vi /opt/nifi/nifi-current/conf/bootstrap.conf

We have to edit the following lines for JVM memory settings:

# JVM memory settings
#java.arg.2=-Xms512m
#java.arg.3=-Xmx512m
java.arg.2=-Xms2g
java.arg.3=-Xmx2g

Then, exit the container, and restart NiFi:

exit
sudo docker restart nifi

Enabling SSL and Authentication

For added security, set up SSL and authentication using NGINX:

sudo mkdir -p /opt/nginx/conf /opt/nginx/keys /opt/nifi/drivers /opt/dockerfiles/nifi/
cd /opt/nginx/keys
sudo openssl req -x509 -sha256 -newkey rsa:2048 -keyout certificate.key -out certificate.crt -days 1024 -nodes -subj '/CN=my.domain.internal'
sudo vi /opt/nginx/conf/nginx.conf

Then, add NGINX configuration:

events {
}
http {
server {
listen 8443 ssl;
server_name my.domain.internal;
ssl_certificate /keys/certificate.crt;
ssl_certificate_key /keys/certificate.key;
proxy_ssl_certificate /keys/certificate.crt;
proxy_ssl_trusted_certificate /keys/certificate.key;
location /nifi {
proxy_pass http://nifi:8080;
proxy_set_header Host $http_host;
proxy_set_header X-ProxyScheme https;
auth_basic "NiFi Authentication";
auth_basic_user_file /keys/nginx.htpasswd;
}
}
}

Now, we have to generate a password for user authentication:

htpasswd -n admin > /opt/nginx/keys/nginx.htpasswd
cat /opt/nginx/keys/nginx.htpasswd # Check the file for output

Finally, it is time to bring up the Docker containers:

cd /opt/dockerfiles/nifi
docker-compose up -d

With the above steps, we can successfully configure NiFi Registry for persistent storage, optimize its performance, and boost security with SSL and authentication.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

In brief, our Support Experts introduced us to Apache NiFi Docker Compose and more.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF