HDFS的常用 *** 作及其相关问题

HDFS的常用 *** 作及其相关问题,第1张

HDFS的常用 *** 作及其相关问题

在Hadoop的安装目录下,查看hdfs下的文件的命令:

./bin/hdfs dfs -ls /

创建新的文件目录:

./bin/hdfs dfs -mkdir /a

上传文件到指定的目录:

./bin/hdfs dfs -put a.txt /a

下载HDFS上的文件至本地:

./bin/hdfs dfs -get /input/a.txt ~

查看文件内容:

./bin/hdfs dfs -cat /input/a.txt

在IDEA中执行HDFS的相关 *** 作可能出现的问题:

org.apache.hadoop.ipc.RemoteException(java.io.IOException): File /a.txt could only be written to 0 of the 1 minReplication nodes. There are 1 datanode(s) running and 1 node(s) are excluded in this operation.

解决方法:在代码中添加如下代码

conf.set("dfs.client.use.datanode.hostname", "true");//添加此配置信息即可

添加此信息以后还报如下错误:

java.nio.channels.UnresolvedAddressException

需要在hosts文件中添加对应的配置信息

hosts文件的地址C:WindowsSystem32driversetc

在里边添加ip与主机名的映射关系

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5715922.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-18

发表评论

登录后才能评论

评论列表(0条)

保存