hdfs文件读写报错:
AccessControlException: Permission denied: user=root, access=WRITE, inode="/user/chaojunwang":chaojunwang:supergroup:drwxr-xr-x
【解决方法】
1. 不要sudo启动hadoop或pyspark
2. 在hadoop路径下 ./bin/hdfs dfs -chmod 777 /user 修改 hdfs 文件系统中/user/chaojunwang 路径的权限
3. 在pyspark中即可完成 hdfs 的文件读写
>>> textFile = sc.textFile("hdfs://localhost:9000/user/chaojunwang/word.txt") >>> textFile.saveAsTextFile("hdfs://localhost:9000/user/chaojunwang/writeback.txt") >>> textFile = sc.textFile("hdfs://localhost:9000/user/chaojunwang/writeback.txt") >>> textFile.first() ‘It is a start for me to pyspark learning.‘
原文:https://www.cnblogs.com/chaojunwang-ml/p/13285061.html