您的位置:首页 > 运维架构

HDFS基于ACL权限控制

2017-12-19 15:11 232 查看
一、开起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] <path>

<!-- COMMAND OPTIONS

<path>: 文件或目录路径

-R: 使用此选项可以递归地列出所有文件和目录的ACL。

-->

例如:

hdfs dfs -getfacl /data/file

 

(2)setfacl命令设置权限

<!-- 赋予ben用户读写/user/hdfs/file路径的权限 -->

hdfs dfs -setfacl -m user:ben:rw- /user/hdfs/file

<!-- 撤销alice用户组对/user/hdfs/file路径的ACL -->

hdfs dfs -setfacl -x user:alice /user/hdfs/file

<!-- 赋予用户user及hadoop用户读写权限,给group和others只读权限 -->

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

参考:http://m.blog.csdn.net/kimsungho/article/details/51418015
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  hadoop acl 权限