hadoop权限说明 2.4.1

来源:互联网 发布:阿佳妮 知乎 编辑:程序博客网 时间:2024/06/05 03:55

需要交流请进群-- 494831900 --我和群中朋友会及时回答

hdfs文件系统对文件和文件夹的权限很多都借鉴了POSIX model(不懂),每个文件和文件夹都只能被他的拥有者或者组访问,文件拥有者,其他用户组的成员,和其他用户,对文件或文件夹拥有独立的权限。

对于文件,r 代表能读取文件的权限,w 代表写权限或者追加到源文件。对文文件夹 ,r 权限是列出文件夹中的内容包括文件夹和文件,w是创建或者删除文件或者文件夹,x是访问文件夹的子节点。
与POSIX model相比, hdfs文件系统的权限 没有setuid和setgid 原因是hdfs的文件是不能执行的。而文件夹没有setuid和setgid是为了简单化。
关键的文件可以放进文件夹中,防止除了superuser,文件夹拥有者,和文件拥有者删除或者移动文件。
把关键内容设置成一个文件是没有作用的,总的来说文件或者文件夹的权限是其状态,一般来说,Unix海关代表和显示模式将使用,包括使用八进制数字描述。
当文件或者文件夹被创建它的拥有者就是操作客户端的用户,他的所属组是父目录的所属组
HDFS还提供了可选支持POSIX acl(访问控制列表),以增加文件权限与细粒度的规则命名的为特定的用户或组。acl将在本文的后面更详细地讨论。
每个访问hdfs的客户端都要经过用户名和用户组的验证,客户端访问文件或者文件夹时都要经过权限检查。
If the user name matches the owner of foo, then the owner permissions are tested;
Else if the group of foo matches any of member of the groups list, then the group permissions are tested;
Otherwise the other permissions of foo are tested.
如果用户权限检查不通过,用户操作无效


1:身份验证
自hadoop0.22起hadoop支持2种身份验证一种是simple,另一种是kerberos
simple :在这中模式下,身份验证取决于主机操作系统
2:组映射
一个和上文所说的用户,他的用户组是取决于用户组服务,可以通过配置hadoop.security.group.mapping property.来设置,默认配置是unix shell -c groups来解析这个用户的用户组
对于hdfs ,组用户的操作都是在namenode上的,因此主机配置文件决定了所访问的用户
注意,HDFS存储的用户和组文件或目录作为字符串;没有转换用户和组身份号码是传统的Unix。
3:理解权限实现
namenode 会通过文件全路径来检查权限,客户端会在后台检查用户权限,是为了减少api的变化。这样也可能导致如果一个文件不存在出现问题,例如当读取一个文件是第一个请求读取一个文件块成功,第二个请求读取文件块失败。另一方面,由于添加了权限,客户端访问文件在撤回请求之间,改变权限不能限制访问在客户端知道访问地址的情况下
4:filesystem api的改变
所有传入文件路径的方法会抛出一个权限异常(当权限验证失败时)
public FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException;
public boolean mkdirs(Path f, FsPermission permission) throws IOException;
public void setPermission(Path p, FsPermission permission) throws IOException;
public void setOwner(Path p, String username, String groupname) throws IOException;
public FileStatus getFileStatus(Path f) throws IOException;


文件或文件夹被umask配置参数所限制,当用create(path)时没有使用权限参数,文件的权限是0666&umask,当使用了权限参数,文件的模式是 P&^umask&0666
文件夹是777


chmod [-R] mode file …
只有拥有者或者超级用户才有权限改权限
chgrp [-R] group file …
The user invoking chgrp must belong to the specified group and be the owner of the file, or be the super-user.
chown [-R] [owner][:[group]] file …
The owner of a file may only be altered by a super-user.
ls file …
lsr file …
The output is reformatted to display the owner, group and mode.
5超级用户
The super-user is the user with the same identity as name node process itself. Loosely, if you started the name node, then you are the super-user. The super-user can do anything in that permissions checks never fail for the super-user. There is no persistent notion of who was the super-user; when the name node is started the process identity determines who is the super-user for now. The HDFS super-user does not have to be the super-user of the name node host, nor is it necessary that all clusters have the same super-user. Also, an experimenter running HDFS on a personal workstation, conveniently becomes that installation's super-user without any configuration.
In addition, the administrator my identify a distinguished group using a configuration parameter. If set, members of this group are also super-users.


超级用户和namenode一样拥有所有权限,没有一个用户是固定的超级用户这个概念,如果启动用户是什么他就是超级用户,超级用户拥有一切权限。
当名字节点启动进程标识确定谁是超级用户。HDFS超级用户没有超级用户名称节点的主机,也不是必要的,所有集群有相同的超级用户。同时,HDFS运行的实验者在个人工作站,方便安装的超级用户没有任何配置。
此外,管理员我的确定一个杰出的小组使用一个配置参数。如果设置,这个小组的成员也得到。







0 0
原创粉丝点击