命令:
(1)创建文件夹hdfs dfs -mkdir /demo
hdfs dfs -put 文件名 /路径/新文件名(新文件名可不写)(3 )删除一个文件(注意文件不能覆盖,只能删除之后再上传)
hdfs dfs -rm -f /路径/文件名(4)查看文件内容
hdfs dfs -cat /路径/文件名(5)下载文件到本地
hdfs dfs -get /路径/文件名(6)统计目录文件大小
hdfs dfs -du /路径/文件名
(7)授权
hdfs dfs -chmod 777 /文件夹名(文件名) --777是一种权限三、HDFS 客户端文件读入写入 1、导入依赖
org.apache.hadoop
hadoop-common
2.6.0
org.apache.hadoop
hadoop-hdfs
2.6.0
test
org.apache.hadoop
hadoop-client
2.6.0
public static void main( String[] args ) throws Exception {
FileSystem fs = FileSystem.get(new URI("hdfs://192.168.64.10:9000"),new Configuration());
// 拷贝文件到本地 一
// InputStream is = fs.open(new Path("/logs/log01"));
// OutputStream os = new FileOutputStream("d:/abc.log");
// IOUtils.copyBytes(is,os,4096,true);
//拷贝文件到本地 二
// fs.copyToLocalFile(false,new Path("/logs/log01"),new Path("d:/aaa.log"),true);
// 上传文件 上传前需要查看是否拥有权限
fs.copyFromLocalFile(new Path("d:/abc.log"),new Path("/logs/"));
}



