今天有个etl开发在drop partition的时候遇到了问题,因为是使用了自己的账号,而hdfs中对应partition的文件属主是hdfs的,在删除时会因为权限问题报错,切换用户为hdfs,做drop partition的错误,还是报错,看来没这么简单。
查看表的hdfs属性,目录的属主不是hdfs且目录对 hdfs没有写权限:
1
2
3
|
[hdfs
@nfzm
~]$ hadoop fs -ls -d hdfs:
//xxxx:9000/bip/external_table/vipdw/droptest
Found
1
items
drwxr-x r-x - ericni hdfs
0
2014
-
08
-
21
17
:
13
hdfs:
//xxxxx:9000/bip/external_table/vipdw/droptest
|
drop partition报错,报hdfs用户没有权限,在hive中是设置了hdfs为超级管理员的,所以如果直接用hadoop fs命令是可以删除的,也就是权限问题不是出在hdfs上,而是在hive上,这里怎么会没有权限呢?
1
2
|
hive (vipdw)> ALTER TABLE droptest DROP PARTITION(dt=
'20140840'
);
14
/
08
/
21
17
:
31
:
21
ERROR metastore.RetryingHMSHandler: MetaException(message:Table partition not deleted since hdfs:
//xxxx:9000/bip/external_table/vipdw/droptest is not writable by hdfs
|
根据调用信息,异常是在HiveMetaStore类中的verifyIsWritablePath 方法中抛出, verifyIsWritablePath类用来判断本目录的上层目录对当前用户是否可写,按照一般的思路,所有的hdfs目录都应该对超级管理员可写的。
1
2
3
4
5
6
7
8
9
10
11
12
|
private
void
verifyIsWritablePath(Path dir)
throws
MetaException {
try
{
if
(!wh.isWritable(dir.getParent())) {
|