hadoop - FileInputFormat.setInputPath 中的 FTP 文件名

标签 hadoop ftp mapreduce

我有一个代码可以使用 mapreduce 代码从 FTP 服务器读取数据。我们用来连接ftp服务器的代码如下`

    String inputPath = args[0];
    String outputPath = args[1];

   Configuration conf1 = new Configuration();
    String[] otherArgs = new GenericOptionsParser(conf1, args).getRemainingArgs();

    Path arg = new Path(inputPath);
    FTPFileSystem ftpfs = new FTPFileSystem();
    Path arg1 =new Path(outputPath);
    ftpfs.setConf(conf1);
    String ftpUser = URLEncoder.encode("username", "UTF-8");
    String ftpPass = URLEncoder.encode("password", "UTF-8");

    String url = String.format("ftp://%s:%s@ftpserver.com",
            ftpUser, ftpPass);
    ftpfs.initialize(new URI(url), conf1);

    JobConf conf = new JobConf(FTPIF.class);
    FileOutputFormat.setOutputPath(conf, arg1));      
    FileInputFormat.setInputPaths(conf, ftpfs.makeQualified(arg));



        conf.setOutputKeyClass(Text.class);
        conf.setOutputValueClass(NullWritable.class);
        conf.setOutputFormat(TextOutputFormat.class);

        conf.setInputFormat(CustomInputFormat.class);
        conf.setMapperClass(CustomMap.class);
        conf.setReducerClass(CustomReduce.class);


    JobClient.runJob(conf);

`

问题是这段代码在伪模式下工作得很好,但在集群上运行时出现服务器登录失败错误。错误堆栈跟踪是

错误 security.UserGroupInformation: PriviledgedActionException as:username (auth:SIMPLE) cause:java.io.IOException: Login failed on server - 0.0.0.0, port - 21 线程“main”中的异常 java.io.IOException:服务器登录失败 - 0.0.0.0,端口 - 21 在 org.apache.hadoop.fs.ftp.FTPFileSystem.connect(FTPFileSystem.java:133) 在 org.apache.hadoop.fs.ftp.FTPFileSystem.getFileStatus(FTPFileSystem.java:389) 在 org.apache.hadoop.fs.FileSystem.getFileStatus(FileSystem.java:2106) 在 org.apache.hadoop.fs.FileSystem.globStatusInternal(FileSystem.java:1566) 在 org.apache.hadoop.fs.FileSystem.globStatus(FileSystem.java:1503) 在 org.apache.hadoop.mapred.FileInputFormat.listStatus(FileInputFormat.java:174) 在 org.apache.hadoop.mapred.FileInputFormat.getSplits(FileInputFormat.java:205) 在 org.apache.hadoop.mapred.JobClient.writeOldSplits(JobClient.java:1041) 在 org.apache.hadoop.mapred.JobClient.writeSplits(JobClient.java:1033) 在 org.apache.hadoop.mapred.JobClient.access$600(JobClient.java:172) 在 org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:943) 在 org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:896) 在 java.security.AccessController.doPrivileged( native 方法) 在 javax.security.auth.Subject.doAs(Subject.java:396) 在 org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1332) 在 org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:896) 在 org.apache.hadoop.mapred.JobClient.submitJob(JobClient.java:870) 在 org.apache.hadoop.mapred.JobClient.runJob(JobClient.java:1319) 在 FTPIF.run(FTPIF.java:164) 在 org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70) 在 org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84) 在 FTPIF.main(FTPIF.java:169) 在 sun.reflect.NativeMethodAccessorImpl.invoke0( native 方法) 在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 在 java.lang.reflect.Method.invoke(Method.java:597) 在 org.apache.hadoop.util.RunJar.main(RunJar.java:208

集群连接到 ftp 。使用的凭据是正确的。代码无法连接到 ftp 的任何想法?

最佳答案

如果您的集群上有许多节点并且多个映射器正在尝试打开到您的 FTP 服务器的连接,那么您可能会超出 FTP 服务器支持的 FTP 用户限制。

关于hadoop - FileInputFormat.setInputPath 中的 FTP 文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13737876/

相关文章:

hadoop - 增量更新 HDFS 上的数据

mapreduce - CouchDB中的map-reduce函数

javascript - 如何在 MongoDB MapReduce 中生成累积结果

hadoop程序只写逻辑,只写reducer的程序

hadoop - HDFS 平衡器不工作

apache - HBase .META。表-readRequestsCount太高

url - 当代理禁止关键字 ftp 时,如何更改 Jenkins 镜像

java - 共享网 : How to send a file over FTP using ASCII without changing LF to CRLF

javascript - FileZilla/FTP 服务器上的 JSON 文件无法正确读取

hadoop - 通过Mapper输出键的最左两位数字执行化径器