hadoop streaming多用户权限问题

原文地址:http://blog.sina.com.cn/s/blog_605f5b4f0101897z.html

hdfs的权限判断十分简单,就是拿发出指令的user name和文件的user name 做比较
   private void check(INode inode, FsAction access
         ) throws AccessControlException {
      if (inode == null) {
         return;
      }
      FsPermission mode = inode.getFsPermission();

      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权限策略这操行应该可以设置。

还有一些如设置 dfs.permissions参数关闭权限校验,改源码直接不校验之类的。。。

最后要注意,任务的out put需要当前用户拥有权限,不然还是不成功。设置成为用户目录就好了

另外,关于/tmp目录也要注意:
 ERROR org.apache.pig.impl.io.FileLocalizer - org.apache.hadoop.security.AccessControlException: org.apache.hadoop.security.AccessControlException:  Permission denied: user=shashaa, access=WRITE, inode="tmp":pwang7:supergroup:rwxr-xr-x
 碰到这种情况,当然是使用chmod把tmp目录的权限改为777了。

关于mapreduce.jobtracker.staging.root.dir
Parameter Value Description
mapred.system.dir /var/mapr/cluster/mapred/jobTracker/system The shared directory where MapReduce stores control files.
mapred.job.tracker.persist.jobstatus.dir /var/mapr/cluster/mapred/jobTracker/jobsInfo The 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/staging 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)

启动hadoop hdfs系统的用户即为超级用户,可以进行任意的操作。

如想让leaf用户也可执行hadoop的作业,执行如下操作:

用超级用户hadoop,创建文件    hadoop fs -mkdir /user/leaf

使用hadoop fs -chown 以及-chgrp 命令改变该文件的用户和用户组权限为leaf

在配置文件hdfs-site-xml 中添加项  dfs.permissions.enabled的值为 true (hadoop0.21版本)

要保证leaf这个用户几个节点能ssh无密码相互登录,java环境变量没问题(我们配置时就忽略了这点,幸亏大飞哥的帮助才搞定)

这样leaf用户就可以提交任务数据到HDFS的/user/leaf目录中,并且可执行hadoop任务, 注意如果不修改staging,任务仍旧无法提交,虽然这时候可以对hdfs的/user/leaf目录进行操作

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值