HDFS基于ACL权限控制

来源:互联网 发布:软件退税计算公式 编辑:程序博客网 时间:2024/05/20 00:17

一、开起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


原创粉丝点击