[报错] 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")

 

posted @   学而不思则罔!  阅读(519)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· SpringCloud带你走进微服务的世界
点击右上角即可分享
微信分享提示