红联Linux门户
Linux帮助

提示inode="/lcy/test5.txt":hdfs:hdfs:drwxr-xr-x的解决

发布时间:2017-05-22 11:21:01来源:linux网站作者:LCYong_
环境:
centos 7
hadoop2.7
 
今天使用root用户Hadoop上传文件测试的时候,怎么弄都无法上传成功,报错:
#hdfs dfs -mkdir -p /lcy/test5.txt
mkdir: Permission denied: user=root, access=WRITE, inode="/lcy/test5.txt":hdfs:hdfs:drwxr-xr-x
 
这是权限问题,后来更改为hdfs用户后可以成功上传,后来分析了原因hadoop官方文档是这样说的:
The Hadoop Distributed File System (HDFS) implements a permissions model for files and directories that shares much of the POSIX model. Each file and directory is associated with an owner and a group.When a file or directory is created, its owner is the user identity of the client process, and its group is the group of the parent directory (the BSD rule).Each client process that accesses HDFS has a two-part identity composed of the user name, and groups list. Whenever HDFS must do a permissions check for a file or directory ‘foo’ accessed by a client process As of Hadoop 0.22, Hadoop supports two different modes of operation to determine the user’s identity, specified by the hadoop.security.authentication property: In this mode of operation, the identity of a client process is determined by the host operating system. On Unix-like systems, the user name is the equivalent of `whoami`.
 
意思就是说文件在访问HDFS的时候,会检查用户名和所在的组,创建文件的时候用的是hdfs用户,所以报错权限不足。
后来修改了hdfs的读写权限为777,还是不行。
 
最后搞了半天,一句话搞定了:
#sudo -u hdfs hdfs dfs -mkdir -p /lcy/test5.txt
就是首先更换为hdfs用户,然后在hdfs中创建/lcy文件夹,并在lcy文件夹下创建test5.txt文件。
打开http://192.168.10.189:50070/explorer.html
看到了令人激动的lcy文件夹和之下的test5.txt文件。
 
本文永久更新地址:http://www.linuxdiyf.com/linux/30977.html