if (user.equals(inode.getUserName())) { //user class
if (mode.getUserAction().implies(access)) { return; }
}
else if (groups.contains(inode.getGroupName())) { //group class
if (mode.getGroupAction().implies(access)) { return; }
}
else { //other class
if (mode.getOtherAction().implies(access)) { return; }
}
throw new AccessControlException("Permission denied: user=" + user
+ ", access=" + access + ", inode=" + inode);
}
}
在多用户提交任务时遇到Permission denied, 的原因和任务提交的过程有关。
1. 首先提交任务的客户端会把任务相关文件打包放在hadoop.tmp.dir中,这是本地目录,需要通过本地系统权限验证。由于是临时目录直接设置成为777就行.
2. 客户端会将任务文件打包写入hdfs的mapreduce.jobtracker.staging.root.dir + "/" + user + "/.staging" 目录,需要经过hdfs权限验证。通常可以选择两种方法解决。
1) 保持mapreduce.jobtracker.staging.root.dir为默认,将此目录chmod 777
2) 在hdfs的/user目录下建立用户目录,并且chown为该用户,相当于在hdfs下创建一个用户。 然后设置mapreduce.jobtracker.staging.root.dir为/user, 这是官方推荐的,可以看到这个属性的描述是这样写的: The root of the staging area for users' job files In practice, this should be the directory where users' home directories are located (usually /user)。
3)有人说可以在启动任务时加入hadoop.job.ugi属性指定用户和群组。 我验证这样不行。看源码里也是直接获取
ugi = UserGroupInformation.getCurrentUser();不过看hdfs权限策略这操行应该可以设置。
关于mapreduce.jobtracker.staging.root.dir
ParameterValueDescriptionmapred.system.dir/var/mapr/cluster/mapred/jobTracker/systemThe shared directory where MapReduce stores control files.mapred.job.tracker.persist.jobstatus.dir/var/mapr/cluster/mapred/jobTracker/jobsInfoThe directory where the job status information is persisted in a file system to be available after it drops of the memory queue and between jobtracker restarts.mapreduce.jobtracker.staging.root.dir/var/mapr/cluster/mapred/jobTracker/stagingThe root of the staging area for users' job files In practice, this should be the directory where users' home directories are located (usually /user) 启动hadoop hdfs系统的用户即为超级用户,可以进行任意的操作。