问题是您的本地路径/home/mohammed
无法作为hdfs
您运行整个命令的 sudo 用户访问。由于本地 linux 用户hdfs
无法进入,该命令会因无法定位或读取提供的文件而/home/mohammed
引发错误并退出。No such file or directory
在大多数打包的 HDFS 安装中,hdfs
用户通常是分布式文件系统的超级用户,并且管理命令通常以该用户身份运行。hdfs
但是,在使用用户为普通用户提供权限和所有权之后,可以并且应该以普通用户的身份对数据进行处理。
mohammed
对于您的情况,如果此帐户也具有 sudo 权限,您可以作为您的用户执行以下操作:
# Superuser-provisioning part (do once)
# Ensure the HDFS directory exists by creating it as a superuser
~> sudo -u hdfs hadoop fs -mkdir -p /kareem/corpora
# Ensure also the HDFS-home path exists by creating it as a superuser
~> sudo -u hdfs hadoop fs -mkdir -p /user/mohammed
# Grant ownership entirely to user mohammed for both paths
~> sudo -u hdfs hadoop fs -chown -R mohammed:mohammed /kareem /user/mohammed
# Final usage part (continue or repeat as many times) without superuser
# Upload the local file (note the absence of sudo)
~> hadoop fs -copyFromLocal -f /home/mohammed/Documents/bbc.txt /kareem/corpora/
# Now read it, etc., all done as the regular non-'hdfs' user
~> hadoop fs -text /home/mohammed/Documents/bbc.txt