hadoopパッケージのアップロードレポート:間違ったFS:hdfs:// localhost:9000 / user / hadoop、予想:file:///



Hadoop Package Upload Report



hadoopパッケージのアップロードレポート:間違ったFS:hdfs:// localhost:9000 / user / hadoop、予想:file:///

//1, get the file system Configuration con = new Configuration() //2, connect to the cluster con.set('fs.hdfs.impl', 'org.apache.hadoop.hdfs.DistributedFileSystem') Path path = new Path('hdfs://bigdata01:9000/lesson/20200122031733.txt') FileSystem fileSystem = path.getFileSystem(con) //3. Upload local files to the file system fileSystem.copyFromLocalFile(new Path('/opt/soft/20200122031733.txt'),new Path('hdfs://bigdata01:9000/lesson/20200122031733.txt')) //4, close resources fileSystem.close() System.out.println('Successfully uploaded')

ローカルファイルと比較する



//1, get the file system Configuration con = new Configuration() //2, connect to the cluster con.set('fs.defaultFS','hdfs://bigdata01:9000') FileSystem fileSystem = FileSystem.get(con) //3. Upload local files to the file system fileSystem.copyFromLocalFile(new Path('F:\jdk.docx'),new Path('/jdk.docx')) //4, close resources fileSystem.close() System.out.println('Successfully uploaded')