Support Questions

Find answers, ask questions, and share your expertise

Switch root user to non-root in NIFI

avatar
Expert Contributor

Hi ,

NIFI was installed before with root user in our enviorment, now in order to switch it to non-root user, i'm wondering if you can help in the steps that i need to follow. Should i clean and re-install it again?

The version is 2.4.2.0

Thanks

SJ

1 ACCEPTED SOLUTION

avatar
Master Mentor
@Sanaz Janbakhsh

Re-installing from scratch is not necessary. Shutdown your NiFi instance, create the user on your system that you want to run NiFi as and change ownership of all the files and directories used by NiFi to that user. This includes all 4 NiFi repositories (Database, Provenance, Content, and FlowFile). The "NiFi user" must be able to read and write to the repos, nifi logs, and state directories. If you are unsure where to find these directories your user needs access to, look in the various config files found in NiFi's conf directory. NiFi will be able to continue working on FlowFiles that were still active in the flow as long as ownership of those files was successfully changed. After that you can either start NiFi while logged in as that new user or set the "run.as=" property in the NiFI bootstrap.conf file. After starting NiFi as the user, tail the nifi-app.log and watch for any permission denied errors. If you encounter any, adjusted permissions on the reported file/dir and you should be good to go.

There is no such thing as NiFi version 2.4.2.0? Are you running an Apache Nifi release (0.x or 1.x) or a HDF release (1.x or 2.0)? You can see your NiFi version by clicking on "about" in the upper right corner of the NiFi UI.

Thanks,

Matt

View solution in original post

9 REPLIES 9

avatar
Master Mentor
@Sanaz Janbakhsh

Re-installing from scratch is not necessary. Shutdown your NiFi instance, create the user on your system that you want to run NiFi as and change ownership of all the files and directories used by NiFi to that user. This includes all 4 NiFi repositories (Database, Provenance, Content, and FlowFile). The "NiFi user" must be able to read and write to the repos, nifi logs, and state directories. If you are unsure where to find these directories your user needs access to, look in the various config files found in NiFi's conf directory. NiFi will be able to continue working on FlowFiles that were still active in the flow as long as ownership of those files was successfully changed. After that you can either start NiFi while logged in as that new user or set the "run.as=" property in the NiFI bootstrap.conf file. After starting NiFi as the user, tail the nifi-app.log and watch for any permission denied errors. If you encounter any, adjusted permissions on the reported file/dir and you should be good to go.

There is no such thing as NiFi version 2.4.2.0? Are you running an Apache Nifi release (0.x or 1.x) or a HDF release (1.x or 2.0)? You can see your NiFi version by clicking on "about" in the upper right corner of the NiFi UI.

Thanks,

Matt

avatar
Expert Contributor

Hi Matt,

Thanks alot for the comment, it is really helpful. I'm running HDF version . i hope this is the one that you recommend.

SJ

avatar
Expert Contributor

Hi Matt,

The user that i logged in is different than "nifi" user and it is generic account. I assume that i can set "run-as=" with the same user that i logged in with and also change all the files with root owner to this generic user t and it should not be necessary "nifi" user. right?

Also i need to change the owner of /nifi/bin folder from root to the same user too. Right?

SJ

avatar
Expert Contributor

Hi Matt,

The user that i logged in is different than "nifi" user and it is generic account. I assume that i can set "run-as=" with the same user that i logged in with and also change all the files with root owner to this generic user t and it should not be necessary "nifi" user. right?

Also i need to change the owner of /nifi/bin folder from root to the same user too. Right?

SJ

avatar
Master Mentor

NiFi sets no specific requirement for what user account is used to run NiFi. as long as that user has the ability to read and write to the various NiFi directories, you will be good. what ever user you decide on will need the execute permissions on the files in the bin directory.

The purpose of serving the run.as= property is so that NiFi will start as that set user even if the executable is trigger by root.

avatar
Expert Contributor

Thanks alot Matt for the confirmation.

SJ

avatar
Master Mentor

@sanaz Janbakhsh

Please accept the answer that helped you.

avatar
New Contributor

Thanks Matt ... seeing and fixing all directories ownership was key to start again NiFi ...

avatar
Expert Contributor

Hi Matt,

The solution perfectly helped me and fixed my issue. I don't know how to accept the answer though. 🙂

SJ