Spark 读取hdfs上的文件 错误:Caused by: java.io.IOException: Filesystem closed的处理

    xiaoxiao2021-03-25  96

    操作方式:使用HDFS的API 直接读取文件:

     

    解决办法:

    第一种方法:

    源代码:FileSystem  fs = FileSystem.get(URI.create(hdfsFilePath), config);

    改为: FileSystem  fs = FileSystem.newInstance(URI.create(hdfsFilePath), config);

    第二种方法:

    在hdfs core-site.xml里把fs.hdfs.impl.disable.cache设置为true 多个datanode在getFileSystem过程中,由于Configuration一样,会得到同一个FileSystem。如果有一个datanode在使用完关闭连接,其它的datanode在访问就会出现上述异常

    转载请注明原文地址: https://ju.6miu.com/read-20858.html

    最新回复(0)