无法连接到hdfs

r1zk6ea1  于 2021-06-03  发布在  Hadoop
关注(0)|答案(0)|浏览(278)

我正在尝试使用hdfs创建一个目录,我的hadoop集群没有在localhost上运行,而是在另一个网络上运行。请告诉我如何正确连接。我使用以下代码连接到hdfs:

import java.io.BufferedInputStream;
    import java.io.IOException;

    import org.apache.hadoop.conf.Configuration;
    import org.apache.hadoop.fs.FileSystem;
    import org.apache.hadoop.fs.Path;

    public class HadoopJava {

        public static void main(String[] args) throws IOException {

            HadoopJava hadoopJava = new HadoopJava();
            hadoopJava.mkdir("/home/anoop/javamkdir");
        }

        public void mkdir(String directory) throws IOException {

            Configuration obj = new Configuration();
            obj.set("fs.default.name", "hdfs://10.111.214.124:50070");

            FileSystem fs = FileSystem.get(obj);
            Path path = new Path(directory);
            fs.mkdirs(path);
            System.out.println("created");
            fs.close();

        }
    }

错误跟踪如下:
java.lang.processbuilder.start(processbuilder。java:1010)在org.apache.hadoop.util.shell.runcommand(shell。java:404)在org.apache.hadoop.util.shell.run(shell。java:379)在org.apache.hadoop.util.shell$shellcommandexecutor.execute(shell。java:589)在org.apache.hadoop.util.shell.execcommand(shell。java:678)在org.apache.hadoop.util.shell.execcommand(shell。java:661)位于org.apache.hadoop.fs.rawlocalfilesystem.setpermission(rawlocalfilesystem)。java:639)在org.apache.hadoop.fs.filterfilesystem.setpermission(filterfilesystem。java:468)在org.apache.hadoop.fs.checksumfilesystem.create(checksumfilesystem。java:456)在org.apache.hadoop.fs.checksumfilesystem.create(checksumfilesystem。java:424)在org.apache.hadoop.fs.filesystem.create(filesystem。java:905)在org.apache.hadoop.fs.filesystem.create(filesystem。java:886)在org.apache.hadoop.fs.filesystem.create(filesystem。java:783)在org.apache.hadoop.fs.fileutil.copy(fileutil。java:365)在org.apache.hadoop.fs.fileutil.copy(fileutil。java:338)在org.apache.hadoop.fs.fileutil.copy(fileutil。java:289)在org.apache.hadoop.fs.filesystem.copytolocalfile(filesystem。java:2086)在org.apache.hadoop.fs.filesystem.copytolocalfile(filesystem。java:2055)在org.apache.hadoop.fs.filesystem.copytolocalfile(filesystem。java:2031)在copyfilefromhdfstolocal(hadoopjava。java:74)在hadoopjava.main(hadoopjava。java:29)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题