Apache Nifi - 由于 /opt/nifi/nifi-current 无法创建而无法启动 Nifi

问题描述 投票:0回答:1

我将 Nifi 提取到 /opt/nifi/nifi-current 并使用 /bin/nifi.sh start 启动它

日志如下:

Starting NiFi service

Java home: /home/dev/.sdkman/candidates/java/current
NiFi home: /opt/nifi/nifi-current

Bootstrap Config File: /opt/nifi/nifi-current/conf/bootstrap.conf

Exception in thread "main" java.io.IOException: /opt/nifi/nifi-current could not be created
    at org.apache.nifi.util.file.FileUtils.ensureDirectoryExistAndCanAccess(FileUtils.java:85)
    at org.apache.nifi.bootstrap.RunNiFi.getBootstrapFile(RunNiFi.java:453)
    at org.apache.nifi.bootstrap.RunNiFi.getStatusFile(RunNiFi.java:464)
    at org.apache.nifi.bootstrap.RunNiFi.loadProperties(RunNiFi.java:477)
    at org.apache.nifi.bootstrap.RunNiFi.getCurrentPort(RunNiFi.java:583)
    at org.apache.nifi.bootstrap.RunNiFi.start(RunNiFi.java:1118)
    at org.apache.nifi.bootstrap.RunNiFi.main(RunNiFi.java:294)

检查 RunNifi 显示它使用这段代码检查 /opt/nifi/nifi-current 路径:

   protected File getBootstrapFile(final Logger logger, String directory, String defaultDirectory, String fileName) throws IOException {

        final File confDir = bootstrapConfigFile.getParentFile();
        final File nifiHome = confDir.getParentFile();

        String confFileDir = System.getProperty(directory);

        final File fileDir;

        if (confFileDir != null) {
            fileDir = new File(confFileDir.trim());
        } else {
            fileDir = new File(nifiHome, defaultDirectory);
        }

        FileUtils.ensureDirectoryExistAndCanAccess(fileDir);
        final File statusFile = new File(fileDir, fileName);
        logger.debug("Status File: {}", statusFile);
        return statusFile;
    }
    public static void ensureDirectoryExistAndCanAccess(final File dir) throws IOException {
        if (dir.exists() && !dir.isDirectory()) {
            throw new IOException(dir.getAbsolutePath() + " is not a directory");
        } else if (!dir.exists()) {
            final boolean made = dir.mkdirs();
            if (!made) {
                throw new IOException(dir.getAbsolutePath() + " could not be created");
            }
        }
        if (!(dir.canRead() && dir.canWrite())) {
            throw new IOException(dir.getAbsolutePath() + " directory does not have read/write privilege");
        }
    }

但这似乎是错误的:

  • 文件夹存在,但逻辑仍然跳到抛出情况

  • 权限没问题(我更改了文件夹的所有者和权限)

我可以进一步做些什么来解决这个问题?

  • 尝试使用 nifi.sh start 启动 Nifi
  • 设置所有所有者和权限
java apache-nifi
1个回答
0
投票

像这样的权限问题可能与conf/bootstrap.conf runas有关。 runas 必须设置为具有权限的用户。这可能就是创建目录时出现权限问题的原因。

© www.soinside.com 2019 - 2024. All rights reserved.