【问题标题】:Hive Permission denied with insert overwrite directory插入覆盖目录时 Hive 权限被拒绝
【发布时间】:2014-10-23 09:17:14
【问题描述】:

我在运行以下命令时从 hdfs 收到权限被拒绝失败:

hive -e "insert overwrite directory '/user/hadoop/a/b/c/d/e/f' select * from table_name limit 10;"

错误信息是:

Permission denied: user=hadoop, access=WRITE, inode="/user/hadoop/a/b":hdfs:hive:drwxrwxr-x

但是当我运行时:hadoop fs -ls /user/hadoop/a,我得到:

drwxrwxrwx   - hadoop supergroup          0 2014-04-08 00:56 /user/hadoop/a/b

好像我打开了文件夹b的完全权限,为什么还是被拒绝?

PS:我在 hive 配置文件中设置了hive.insert.into.multilevel.dirs=true

【问题讨论】:

  • 其他嵌套目录呢?你试过'hadoop fs -chmod 777 -R /user/hadoop/a'吗?
  • @arghtype 是的,我已经尝试过了,但它仍然不起作用。我想知道为什么 hive 获得权限“drwxrwxr-x”而“hadoop fs -ls”获得同一文件夹的权限“drwxrwxrwx”?

标签: hadoop permissions hive hdfs


【解决方案1】:

我遇到了同样的问题,我已经通过使用完全限定的 HDFS 路径解决了它。像这样。

hive -e "insert overwrite directory 'hdfs://<cluster>/user/hadoop/a/b/c/d/e/f' select * from table_name limit 10;"

请参阅 here 提及此问题。

但是,我不知道根本原因,但它与权限无关。

【讨论】:

    【解决方案2】:

    打开一个新的终端然后试试这个:

    1.) 将用户更改为 root:

    su
    

    2.) 将用户更改为 hdfs:

    su hdfs
    

    3.) 然后运行这个命令:

    hadoop fs -chown -R hadoop /user/hadoop/a
    

    现在你可以试试你正在运行的命令了。

    希望对你有帮助...!!!

    【讨论】:

    • 用hadoop fs -ls /user/hadoop/检查一下,是hadoop/hive哪个用户有权限?
    【解决方案3】:

    问题实际上不在于目录权限。 Hive 应该可以访问路径,我的意思是不在文件级别。

    以下是有关如何向用户/组授予对 hdfs 路径和数据库的访问权限的步骤。每个命令的注释以#开头

    #Login as hive superuser to perform the below steps
    create role <role_name_x>;
    
    #For granting to database
    grant all on database to role <role_name_x>;
    
    #For granting to HDFS path
    grant all on URI '/hdfs/path' to role <role_name_x>;
    
    #Granting the role to the user you will use to run the hive job
    grant role <role_name_x> to group <your_user_name>;
    
    #After you perform the below steps you can validate with the below commands
    #grant role should show the URI or database access when you run the grant role check on the role name as below
    
    show grant role <role_name_x>;
    
    #Now to validate if the user has access to the role
    
    show role grant group <your_user_name>;
    

    Here 是我通过 impala 对类似问题的回答之一。 More on hive permissions

    基于此处其他答案和 cmets 的其他建议,如果您想查看某些 hdfs 路径或文件的权限,hdfs dfs -ls 不是您的朋友,需要更多地了解权限及其老派方法。您可以使用hdfs dfs -getfacl /hdfs/path 将为您提供完整的详细信息,结果如下所示。

     hdfs dfs -getfacl /tmp/
    # file: /tmp
    # owner: hdfs
    # group: supergroup
    # flags: --t
    user::rwx
    group::rwx
    other::rwx
    

    【讨论】:

      猜你喜欢
      • 2017-11-25
      • 1970-01-01
      • 2013-04-13
      • 2020-12-20
      • 2016-06-25
      • 2011-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多