[转]http://blog.csdn.net/xiaoping8411/article/details/7429209
一:文件操作
1、建立目录
[hadoop@hadoop1:hadoop]$bin/hadoop dfs -mkdir testdir
在HDFS中建立一个名为testdir的目录
2、上传文件到HDFS
[hadoop@hadoop1:hadoop]$bin/hadoop dfs -put /home/hadoop/test.zip testfile.zip
把本地文件large.zip拷贝到HDFS的根目录/user/hadoop/下,文件名为testfile.zip
3、查看现有文件
[hadoop@hadoop1:hadoop]$bin/hadoop dfs -ls
4、从Hadoop分布式系统复制到本地文件系统查看
[hadoop@hadoop1:hadoop]$bin/hadoop dfs -get out /home/hadoop/output
5、查看HDFS上文件
[hadoop@hadoop1:hadoop]$hadoop dfs -cat out/*
6、删除HDFS上文件
[hadoop@hadoop1:hadoop]$hadoop dfs -rmr out
二:管理与更新
1、报告HDFS的基本统计信息
[hadoop@hadoop1:hadoop]$hadoop dfsadmin -report
2、退出安全模式
[hadoop@hadoop1:hadoop]$hadoop dfsadmin -safemode leave
3、进入安全模式
[hadoop@hadoop1:hadoop]$hadoop dfsadmin -safemode enter
4、负载均衡,平衡各个节点的分布
[hadoop@hadoop1:hadoop]$bin/start-balancer.sh
5、返回是否安全模式
[hadoop@hadoop1:hadoop]$hadoop dfsadmin -safemode get
6、查看块信息
[hadoop@hadoop1:hadoop]$hadoop fsck / -files -blocks
7、并行复制
[hadoop@hadoop1:hadoop]$hadoop distcp -help hdfs://namenode1/foo hdfs://namenode2/bar
分享到:
相关推荐
throw new IOException("Failed to create directory: " + dir.getAbsolutePath()); } } private static void writeToFile(ZipInputStream zis, File outputFile) throws IOException { try (FileOutputStream...
throw new IOException("Failed to create directory: " + parentFile); } OutputStream out = new FileOutputStream(outputFile); byte[] buffer = new byte[1024]; int read; while ((read = zis.read...
throw new IOException("Failed to create parent directories for " + outputFile); } byte[] buffer = new byte[1024]; FileOutputStream fos = new FileOutputStream(outputFile); try { int length; ...
throw new RuntimeException("Failed to create parent directories for " + entryDestination); } try (FileOutputStream fos = new FileOutputStream(entryDestination)) { byte[] bytes = new byte[1024]; ...
throw new IOException("Failed to create parent directory for: " + file); } } } ``` 这个例子展示了如何遍历ZIP文件的每一个条目,创建对应的文件或目录,并将内容写入输出文件。`createOrGetParentFolder`...
throw new IOException("Failed to create directory: " + dir.getAbsolutePath()); } } } ``` 4. **注意事项**: - 在解压过程中,应处理可能出现的异常,如文件不存在、权限问题或磁盘空间不足等。 - 为了...
throw new IOException("Failed to create directory " + parentFile); } if (!entry.isDirectory()) { copyStream(zipIn, new FileOutputStream(destFile)); } zipIn.closeEntry(); } } } private ...
throw new IOException("Failed to create directory: " + parentFile.getAbsolutePath()); } FileOutputStream fos = new FileOutputStream(outputFile); byte[] buffer = new byte[1024]; int read; while ...
System.err.println("Failed to create directory: " + parentDir); return; } try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile))) { IOUtils.copy(archiveIn, ...
throw new FileNotFoundException("Failed to create directories for " + parentFile); } try (FileOutputStream fos = new FileOutputStream(outputFile)) { byte[] buffer = new byte[1024]; int length; ...
throw new FileNotFoundException("Failed to create directory " + parentFile); } if (!ze.isDirectory()) { OutputStream os = new FileOutputStream(newFile); byte[] buffer = new byte[1024]; int ...
System.out.println("Failed to create folder."); } } } ``` 现在,转向XML解析。这个项目使用了XPath,它是一种在XML文档中查找信息的语言。XPath允许我们根据节点的名称、属性、位置等条件选择XML元素。在...
System.out.println("Failed to create directory."); } // 关闭文件系统连接 fs.close(); } } ``` 在这个例子中,我们使用`FileSystem.get()`方法连接到HDFS集群,指定集群地址、配置对象以及用户身份(默认...
System.out.println("Failed to create directory."); } // 更多操作... fs.close(); } catch (IOException e) { e.printStackTrace(); } } } ``` #### 五、总结 通过以上步骤,我们已经成功搭建了...