首页 > 其他分享 >HDFS报错:Couldn‘t preview the file.

HDFS报错:Couldn‘t preview the file.

时间:2024-04-09 17:30:03浏览次数:25  
标签:HDFS fs etc 192.168 hosts 报错 org import preview

package com.qm.hdfs;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;


public class HdfsClient {

    private FileSystem fs;

    @Before
    public void init() throws URISyntaxException, IOException, InterruptedException {
        URI uri = new URI("hdfs://hadoop102:8020");
        Configuration configuration = new Configuration();
        String user = "qm";
        fs = FileSystem.get(uri, configuration,user);
    }

    @After
    public void close() throws IOException {
        fs.close();
    }

    //创建目录
    @Test
    public void testmkdir() throws URISyntaxException, IOException, InterruptedException {
        //创建文件夹
        fs.mkdirs(new Path("/xiyou/huaguoshan"));
    }

    //上传
    @Test
    public void testPut() throws IOException {
        // 参数解读:
        // 参数一:表示删除原数据;
        // 参数二:是否允许覆盖;
        // 参数三:原数据路径;
        // 参数四:目的地路径
        fs.copyFromLocalFile(false,false,
                new Path("/Users/qmmm666666/Desktop/DEPT.txt"),
                new Path("hdfs://hadoop102/xiyou/huaguoshan"));
    }
}

问题:

最近出现的一次HDFS报错问题,查看一个文件是报错Couldn't preview the file.

 

造成原因

  1. 配置文件hdfs-site.xml配置有误

  1. mac下的/etc/hosts 与 linux下的/etc/hosts下的hadoop映射地址或名称不一致

 

解决方法

  1. 在hdfs-site.xml配置如下依赖

    <property>
        <name>dfs.webhdfs.enabled</name>
        <value>true</value>
    </property>
  1. 修改mac下的/etc/hosts 与 linux下的etc/hosts下的hadoop 映射地址保持一致

我的是

Mac的/etc/hosts

192.168.164.1   macbook
192.168.164.102   qm102
192.168.164.103   qm103
192.168.164.104   qm104

 Linux的/etc/hosts

192.168.164.1   macbook
192.168.164.102   qm102
192.168.164.103   qm103
192.168.164.104   qm104

 解决完成:

标签:HDFS,fs,etc,192.168,hosts,报错,org,import,preview
From: https://blog.csdn.net/Qmmm666666/article/details/137560352

相关文章

  • 克隆虚拟机网络重启报错:Failed to start LSB: Bring up/down networking
    1.虚拟机环境[root@master~]#cat/etc/redhat-releaseCentOSLinuxrelease7.9.2009(Core)[root@master~]#cat/proc/versionLinuxversion3.10.0-1160.el7.x86_64([email protected])(gccversion4.8.520150623(RedHat4.8.5-44)(GCC))#1SM......
  • crictl images报错runtime connect using default endpoints: [unix:///var/run/docke
    想试试containerd运行k8s,结果报错还在找dockershim,网上找了解决方法crictl依次查找容器运行时,当查找第一个unix:///var/run/dockershim.sock没有找到,所以报错了,需要你手动指定当前kubernetes的容器运行时,使用什么,例如:kubernetes1.24+之后,dockershim已经变成了cri-docker,所以......
  • CEF编译报错:ValueError: path is on mount '\\\\tab_group_types.mojom-webui.js'
    F:\code\chromium_git\chromium\src>autoninja-Cout\Debug_GN_x64cef"f:\code\depot_tools\bootstrap-2@3_11_6_chromium_30_bin\python3\bin\python3.exe"F:\code\depot_tools\ninja.py-Cout\Debug_GN_x64cef-j10ninja:Enteringdirec......
  • CRC报错查看
    前言查看交换机接口是否有CRC报错,本案例以华三交换机为例。CRC是指循环冗余校验错使用仪器测试链路。链路质量差或者线路光信号衰减过大会导致报文在传输过程中出错。如链路故障请更换网线或光纤。与别的正常的端口更换网线或光纤光模块,如端口更换后错包消失,端口更换回来错......
  • 20240409报错修改学习
    未配置SpringBoot配置注解处理器spring:datasource:druid:driver-class-name:com.mysql.jdbc.Driverurl:jdbc:mysql://localhost:3306/mini_springmvc?serverTimezone=UTCusername:rootpassword:1234mybatis-plus:global-config:......
  • 民航电子数据库:表主键为自增,insert时报错:[E16005] 字段xxx不能取空值
    目录一、场景二、报错信息三、排查四、原因五、解决一、场景1、对接民航电子数据库2、表的主键为自增主键,使用mybatis封装好的insert方法新增记录时报错二、报错信息###Errorupdatingdatabase.Cause:java.sql.SQLException:[E16005]字段ID不能取空值......
  • webrtc分支切换到m94 下载报错 FileNotFoundError: [Errno 2] No such file or direct
    FileNotFoundError:[Errno2]Nosuchfileordirectory:'vpython' 此问题翻遍整个网络,没有解决方案,希望能帮忙到需要的人 描述:      正常下载代码后,基于master(默认)编译通过,现需要切到m94分支(参考 Linux/Ubuntu编译WebRTC&libmediasoupclient_linuxg++......
  • YOLO报错AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common
    解决方案:model/common.py里面去找到这个SPPF的类,把它拷过来到Tags5的model/common.py里面,这样你的代码就也有这个类了,还要引入一个warnings包1、把importwarnings放在上面去:importwarnings2、把SPPF类的代码复制到common.py中classSPPF(nn.Module):#SpatialP......
  • IDEA中Servlet中的注解@WebServlet报错,import javax.servlet.annotation.WebServlet;
    IDEA报错信息:[java.lang.LinkageError:loaderconstraintviolation:loader(instanceoforg/apache/jasper/servlet/检查pom依赖,看到这个,其实是因为selvlet这个依赖的version太低了,和你用的tomcatserver版本不匹配,所以可以降低tomcat版本,降成tomcat7及以下,或者提升pom中se......
  • 【mac权限】解决 mac 运行报错 150: Operation not permitted
    Couldnotsetenvironment:150:OperationnotpermittedwhileSystemIntegrityProtectionisengagedMac下操作文件,遇到Operationnotpermitted原来是索引服务被关闭,导致对文件夹的操作权限失效解决步骤打开系统偏好设置,隐私与安全性,左侧选择‘文件和文件夹’,......