1.权限问题
Permission denied: user=Administrator, access=READ_EXECUTE, inode="/user/test/": test:hdfs:drwx------
2.解决办法
一: 在系统环境变量或者JVM变量中添加HADOOP_USER_NAME
二:代码中设置环境变量(推荐)
Configuration conf = new Configuration();
// 设定Java客户端访问HDFS的身份
System.setProperty("HADOOP_USER_NAME","hdfs");
FileSystem fs = FileSystem.get(new URI("hdfs://masternode:8020"),conf);
//或者直接下面
FileSystem fs = FileSystem.get(new URI("hdfs://masternode:8020"),conf,"hdfs");