问题:
最近出现的一次HDFS报错问题,查看一个文件是报错Couldn't preview the file.
![](https://img-blog.csdnimg.cn/img_convert/f9a657fe6b3d403d8dabc657d8cba223.png)
造成原因
配置文件hdfs-site.xml配置有误
windows下的C:\Windows\System32\drivers\etc\hosts 与 linux下的etc/hosts下的hadoop映射地址不一致
解决方法
在hdfs-site.xml配置如下依赖
<property>
<name>dfs.webhdfs.enabled</name>
<value>true</value>
</property>
修改windows下的C:\Windows\System32\drivers\etc\hosts 文件与linux下的etc/hosts下的hadoop 映射地址保持一致
我的是
C:\Windows\System32\drivers\etc\hosts
192.168.137.121 hadoop121.hadoop.com hadoop121
192.168.137.122 hadoop122.hadoop.com hadoop122
192.168.137.123 hadoop123.hadoop.com hadoop123
etc/hosts
192.168.137.121 hadoop121.hadoop.com hadoop121
192.168.137.122 hadoop122.hadoop.com hadoop122
192.168.137.123 hadoop123.hadoop.com hadoop123
解决完成:
![](https://img-blog.csdnimg.cn/img_convert/2d48b7a7ff8e238d246547d648173c5a.png)