背景:在使用Ranger鉴权的过程中,要求必须开启impersonation功能(即执行用户与提交用户保持一致,而不是统一代理的hive/spark)。但是在执行的过程中,会需要在hdfs存储临时的文件,此时容易出现权限不足的问题。对此,我们需要关注这些路径的生成/使用规则。

路径分析

报错异常的日志来自DagUtils.java,这里我们没有粘贴完全

ERROR : Failed to execute tez graph.
Caused by: org.apache.hadoop.ipc.RemoteException: Permission denied: user=your_name, access=WRITE, inode="/user":hdfs:hdfsadmingroup:drwxr-xr-x
at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.check(FSPermissionChecker.java:399)
at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkPermission(FSPermissionChecker.java:255)
at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkPermission(FSPermissionChecker.java:193)
at org.apache.hadoop.hdfs.server.namenode.FSDirectory.checkPermission(FSDirectory.java:1879)
at org.apache.hadoop.hdfs.server.namenode.FSDirectory.checkPermission(FSDirectory.java:1863)

分析源码

UserGroupInformation ugi = Utils.getUGI();
String userName = ugi.getShortUserName();
String userPathStr = HiveConf.getVar(conf, HiveConf.ConfVars.HIVE_USER_INSTALL_DIR);
Path userPath = new Path(userPathStr);
FileSystem fs = userPath.getFileSystem(conf); String jarPathStr = userPathStr + "/" + userName;

由于没有显示指定HiveConf.ConfVars.HIVE_USER_INSTALL_DIR

HIVE_JAR_DIRECTORY("hive.jar.directory", null,
"This is the location hive in tez mode will look for to find a site wide \n" +
"installed hive instance."), HIVE_USER_INSTALL_DIR("hive.user.install.directory", "/user/",
"If hive (in tez mode only) cannot find a usable hive jar in \"hive.jar.directory\", \n" +
"it will upload the hive jar to \"hive.user.install.directory/user.name\"\n" +
"and use it to run queries."),

jarPathStr = "/user/user.name"

https://cwiki.apache.org/confluence/display/hive/configuration+properties#ConfigurationProperties-hive.user.install.directory

与官方文档描述的一致:

  • hive.user.install.directory

    If Hive (in Tez mode only) cannot find a usable Hive jar in hive.jar.directory, it will upload the Hive jar to <hive.user.install.directory>/<user_name> and use it to run queries.

     

同理,spark在执行时会将文件上传到hdfs的.sparkStaging/applicationId目录下

hdfs://yourcluster/user/your_username

与官方文档描述的一致:https://spark.apache.org/docs/latest/running-on-yarn.html#spark-properties

spark.yarn.stagingDir Current user's home directory in the filesystem Staging directory used while submitting applications.

路径配置

hadoop fs -mkdir -p /user/ranger/hive/
hadoop fs -chmod -R 777 /user/ranger/hive/ hadoop fs -mkdir -p /user/ranger/spark/staging/
hadoop fs -chmod -R 777 /user/ranger/spark/staging/

hive-site.xml里的 hive.user.install.directory 参数,定义了HDFS的路径

sudo vi /etc/hive/conf/hive-site.xml,增加下面的内容

<property>
<name>hive.user.install.directory</name>
<value>/user/ranger/hive/
</value> </property>
保存后,重启服务

sudo systemctl restart hive-server2.service

 
 
sudo vi /etc/spark/conf/spark-defaults.conf
增加
spark.yarn.stagingDir /user/ranger/spark/staging

不需要重启,yarn是实时调用生效的。

Apache Ranger系列七:Hive 和 Spark 执行过程中的文件路径配置的更多相关文章

  1. 【原创】控制perl和python脚本执行过程中脚本文件是否关闭的方法

    引子 跟踪perl和python脚本对文件的访问,实际过程中,perl和python解析器在解析完脚本后,直接关闭了 脚本文件,在进程中查询不到是访问文件的脚本文件名称. shell.perl和pyt ...

  2. Hadoop概念学习系列之为什么hadoop/spark执行作业时,输出路径必须要不存在?(三十九)

    很多人只会,但没深入体会和想为什么要这样? 拿Hadoop来说,当然,spark也一样的道理. 输出路径由Hadoop自己创建,实际的结果文件遵守part-nnnn的约定. 如何指定一个已有目录作为H ...

  3. Hive扩展功能(七)--Hive On Spark

    软件环境: linux系统: CentOS6.7 Hadoop版本: 2.6.5 zookeeper版本: 3.4.8 主机配置: 一共m1, m2, m3这五部机, 每部主机的用户名都为centos ...

  4. mysql系列九、mysql语句执行过程及运行原理(分组查询和关联查询原理)

    一.背景介绍 了解一个sql语句的执行过程,了解一部分都做了什么,更有利于对sql进行优化,因为你知道它的每一个连接.where.分组.子查询是怎么运行的,都干了什么,才会知道怎么写是不合理的. 大致 ...

  5. SQL SERVER 2008:内部查询处理器错误: 查询处理器在执行过程中遇到意外错误

       今天一个同事突然告诉我,以前跑得很正常的一个SQL语句,执行时突然报如下错误:         消息1222,级别16,状态18,第1 行         已超过了锁请求超时时段.        ...

  6. Deepin下phpunit安装,以及执行过程中所遇到的问题

    Deepin下phpunit安装,以及执行过程中所遇到的问题 安装phpunit步骤 wget https://phar.phpunit.de/phpunit.phar chmod +x phpuni ...

  7. 【已解决】Makefile执行过程中出错:make: *** No rule to make target ` ‘, needed by xxx. Stop(转载)

    转自: http://www.crifan.com/makefile_error_make_no_rule_to_make_target_needed_by_stop/ [问题] 有个已有的Makef ...

  8. 转:Oracle中SQL语句执行过程中

    Oracle中SQL语句执行过程中,Oracle内部解析原理如下: 1.当一用户第一次提交一个SQL表达式时,Oracle会将这SQL进行Hard parse,这过程有点像程序编译,检查语法.表名.字 ...

  9. UI5-技术篇-jQuery.ajax执行过程中Token验证及JSON格式传值问题

    最近两天在测试OData服务类方法CREATE_DEEP_ENTITY及GET_EXPANDED_ENTITYSET,刚开始采用ODataModel方式调用没有任何问题,但是ODataModel采用的 ...

  10. maven执行过程中抛出的各类异常信息

    价值 各类异常信息分类 举例 maven源代码的模块maven-core里的各类*Exception命名的class包含里,maven执行过程中打印的各类异常日志内容 比如如下错误 错误信息分别来自( ...

随机推荐

  1. git通过ssh方式免密克隆代码仓库

    git上添加ssh公钥 略过 终端命令行 格式: git clone ssh://[user@]host.xz[:port]/path/to/repo.git/ 栗子: git clone ssh:/ ...

  2. BFS板子题

    #include <iostream> #include <string> #include <queue> using namespace std; int n, ...

  3. fiddler抓包返回304

    为了验证部分场景需要对接口返回数据进行修改后验证前端代码逻辑处理,发现同一域名下其他接口都正常返回,但是某个端口返回304. 操作步骤是页面打开后接口已经请求了,这时候才打开fiddler抓取请求拦截 ...

  4. Unity 热更新XLua

    什么是冷更新 开发者将测试好的代码,发布到应用商店的审核平台,平台方会进行稳定性及性能 测试.测试成功后,用户即可在AppStore看到应用的更新信息,用户点击应用更 新后,需要先关闭应用,再进行更新 ...

  5. select from 多表和inner join的区别

    其实两者是一样的,inner join 只是为了区分left join和right join整出来的,本质还是逐行比较

  6. Test Fixture框架结构

    Test Fixture框架 1.结构: setup() testcase() teardown() 2.新建unittest文件,命名unittestdemo.py 1 import unittes ...

  7. UF_OBJ_delete_array_of_objects函数vector转数组用法

        1 UF_initialize(); 2 std::vector<tag_t>tool_tag; 3 tag_t ObjectTag = NULL_TAG; 4 int Type, ...

  8. Linux基础命令、按照软件、数据库基础操作

    一.Linux基础命令 1.防火墙 systemctl - 控制 systemd 系统与服务管理器 systemctl 可用于 检查和控制 systemd(1) 系统与服务管理器的 状态 常用的命令: ...

  9. bzoj 4176

    题意:求$\sum_{i=1}^{n}\sum_{j=1}^{n}d(ij)$ 首先推一发式子: $\sum_{i=1}^{n}\sum_{j=1}^{n}d(ij)$ 有一个结论:$d(nm)=\s ...

  10. Loadrunner录制时弹出Microsoft Visual C++ Runtime Library解决方案

    这段时间用loadrunner测试工具,录制脚本的时候老是出现这个弹窗,刚开始就以为是软件错误,就用的软件修复,也解决了,后来还是出现这样的错误,修复也没有用 原因:可能是代理服务器在调用VC库的时候 ...