为什么查询外部配置单元表需要对hdfs目录的写访问?

nuypyhwy  于 2021-05-29  发布在  Hadoop
关注(0)|答案(0)|浏览(231)

在设置外部表以查看配置单元中的一些avro文件时,遇到了一个有趣的权限问题。
avro文件位于以下目录中:

drwxr-xr-x   - myserver hdfs          0 2017-01-03 16:29 /server/data/avrofiles/

服务器可以写入此文件,但普通用户不能。
作为数据库管理员,我在配置单元中创建了一个引用以下目录的外部表:

hive> create external table test_table (data string) stored as avro location '/server/data/avrofiles';

现在作为一个普通用户,我尝试查询表:

hive> select * from test_table limit 10;
FAILED: HiveException java.security.AccessControlException: Permission denied: user=regular.joe, access=WRITE, inode="/server/data/avrofiles":myserver:hdfs:drwxr-xr-x
        at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.check(FSPermissionChecker.java:319)

奇怪的是,我只是想用hive读取文件的内容,而不是写。
奇怪的是,当我像这样划分表时,我没有遇到同样的问题:
作为数据库管理员:

hive> create external table test_table_partitioned (data string) partitioned by (value string) stored as avro;
OK
Time taken: 0.104 seconds
hive> alter table test_table_partitioned add if not exists partition (value='myvalue') location '/server/data/avrofiles';
OK

作为普通用户:

hive> select * from test_table_partitioned where value = 'some_value' limit 10;
OK

有人能解释一下吗?
我注意到的一件有趣的事情是,这两个表的位置值不同,并且具有不同的权限:

hive> describe formatted test_table;
Location:               hdfs://server.companyname.com:8020/server/data/avrofiles

$ hadoop fs -ls /apps/hive/warehouse/my-database/
drwxr-xr-x   - myserver hdfs          0 2017-01-03 16:29 /server/data/avrofiles/

用户无法写入

hive> describe formatted test_table_partitioned;
Location:               hdfs://server.companyname.com:8020/apps/hive/warehouse/my-database.db/test_table_partitioned

$ hadoop fs -ls /apps/hive/warehouse/my-database.db/
drwxrwxrwx   - database_admin         hadoop          0 2017-01-04 14:04 /apps/hive/warehouse/my-database.db/test_table_partitioned

任何人都可以做任何事:)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题