一、开起ACL权限开关
(1)如果是Apache Hadoop:修改hdfs-site.xml的配置,并重启
<property>
<name>dfs.namenode.acls.enabled</name>
<value>true</value>
</property>
(2)如果是CDH,登陆Cloudera Manager,选中HDFS,点击【配置】,在搜索栏中输入acl进行搜索,将【启用访问控制列表】选项选中,然后点 击【保存更改】,然后重启HDFS
二、使用shell来设置和获取文件的访问控制列表
(1)查询命令
hdfs dfs -getfacl [-R]
例如:
hdfs dfs -getfacl /data/file
(2)setfacl命令设置权限
hdfs dfs -setfacl -m user:ben:rw- /user/hdfs/file
hdfs dfs -setfacl -x user:alice /user/hdfs/file
hdfs dfs -setfacl --set user::rw-,user:hadoop:rw-,group::r–,other::r-- /user/hdfs/file
注意:如果是针对hive数据库,要想用户有查询表的权限,必须将执行权限赋给当前用户即可,例如:
hdfs dfs -setfacl --set user::rwx,user:zhangsan:rwx,group::rwx,other::— /user/hive/warehouse/mydb.db