Installing as a Service
Currently, installing NiFi as a service is supported only for Linux and macOS users. To install the application as a service, navigate to the installation directory in a Terminal window and execute the command bin/nifi.sh install to install the service with the default name nifi. To specify a custom name for the service, execute the command with an optional second argument that is the name of the service. For example, to install NiFi as a service with the name dataflow, use the command bin/nifi.sh install dataflow.
Once installed, the service can be started and stopped using the appropriate commands, such as sudo service nifi start and sudo service nifi stop. Additionally, the running status can be checked via sudo service nifi status.

按照官网提供的说明,通过service命令来实现NiFi的开机自启动。以下是详细步骤,假设您已经下载并解压了NiFi:

  1. 安装NiFi服务
    首先,进入NiFi的安装目录,然后运行install命令安装服务:
cd /path/to/nifi
sudo bin/nifi.sh install
  • 1.
  • 2.

或者使用自定义服务名称,例如:

sudo bin/nifi.sh install my-nifi-service
  • 1.
  1. 使服务开机自启动
    安装完成后,您可以使用以下命令将服务设置为开机自启动:
    如果您使用的是默认服务名称nifi
sudo systemctl enable nifi
  • 1.

如果您使用了自定义服务名称,例如my-nifi-service

sudo systemctl enable my-nifi-service
  • 1.
  1. 管理NiFi服务
    现在,您可以使用以下命令来启动、停止和检查NiFi服务状态:
    启动NiFi服务:
sudo service nifi start
  • 1.

停止NiFi服务:

sudo service nifi stop
  • 1.

检查NiFi服务状态:

sudo service nifi status
  • 1.

如果您使用了自定义服务名称,使用相应的名称替换nifi即可,例如:

sudo service my-nifi-service start
sudo service my-nifi-service stop
sudo service my-nifi-service status
  • 1.
  • 2.
  • 3.

通过上述步骤,您便可以成功地将NiFi配置为开机自启动的服务。请确保您有足够的权限来执行这些命令,并且nifi用户具有必要的权限来运行和管理NiFi服务。