[报错] spark开发环境 操作hdfs 报错
报错1
22/05/0305:48:53 WARN DFSClient: Failed to connect to /10.0.24.10:9866 for block, add to deadNodes and continue. org.apache.hadoop.net.ConnectTimeoutException: 60000 millis timeout while waiting for channel to be ready for connect. ch : java.nio.channels.SocketChannel[connection-pending remote=/10.0.24.10:9866] org.apache.hadoop.net.ConnectTimeoutException: 60000 millis timeout while waiting for channel to be ready for connect. ch : java.nio.channels.SocketChannel[connection-pending remote=/10.0.24.10:9866]
查看报错信息, 是连接 datanode: 9866 时报错,为什么会使用 内网ip呢?有没有方法可以避免呢?
解决:
在resource目录添加 hdfs-site.xml
<!-- datanode 通信是否使用域名,默认为false,改为true --> <property> <name>dfs.client.use.datanode.hostname</name> <value>true</value> <description>Whether datanodes should use datanode hostnames whenconnecting to other datanodes for data transfer. </description> </property>
报错2
Exception in thread "main" org.apache.hadoop.security.AccessControlException: Permission denied: user=wst, access=WRITE, inode="/":root:supergroup:drwxr-xr-x
查看报错信息,是往 hdfs写数据时,没有权限,因为使用的是 开发环境的user=wst提交的
//TODO 5.对hdfs 的操作 object hdfs { def main(args: Array[String]): Unit = {
// 设置 hadoop用户名 System.setProperty("HADOOP_USER_NAME", "root")
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· SpringCloud带你走进微服务的世界