Caused by: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.AccessControlException): Permission denied: user=1hdfs, access=WRITE, inode="/hdfsapi/test/a.txt":hdfs:supergroup:-rw-r--r--
at org.apache.hadoop.hdfs.server.namenode.DefaultAuthorizationProvider.checkFsPermission(DefaultAuthorizationProvider.java:281)
昨天搭建好CDH集群后,在没开启认证的时候,以前的代码就跑不起来。像上面的问题不是说去修改文件目录权限的。根据之前的课程介绍和错误信息提示,将下面的admin 修改为hdfs去连接就成功了。
configuration = new Configuration(); fileSystem = FileSystem.get(new URI(HDFS_PATH), configuration, "admin"); Path path = new Path("/hdfsapi/test"); boolean exist = fileSystem.exists(path); if(exist){ System.out.println("HDFS目录 "+path.toUri()+" 已经存在"); }else{ fileSystem.mkdirs(path); System.out.println("创建成功~!~~~");