hadoop hdfs uri详解

时间:2023-01-09 13:01:43

body{ font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI",Tahoma,Helvetica,Sans-Serif,"Microsoft YaHei", Georgia,Helvetica,Arial,sans-serif,宋体, PMingLiU,serif; font-size: 10.5pt; line-height: 1.5;}html, body{ }h1 { font-size:1.5em; font-weight:bold;}h2 { font-size:1.4em; font-weight:bold;}h3 { font-size:1.3em; font-weight:bold;}h4 { font-size:1.2em; font-weight:bold;}h5 { font-size:1.1em; font-weight:bold;}h6 { font-size:1.0em; font-weight:bold;}img { border:0; max-width: 100%;}blockquote { margin-top:0px; margin-bottom:0px;}table { border-collapse:collapse; border:1px solid #bbbbbb;}td { border-collapse:collapse; border:1px solid #bbbbbb;}hadoop hdfs uri详解

hadoop hdfs uri详解

一、hdfs基本命令:
hadoop fs -cmd <args>
选项:
cmd: 具体的操作,基本上与UNIX的命令行相同
args: 参数

二、hdfs资源uri格式:
用法:scheme://authority/path
选项:
scheme–>协议名,file或hdfs
authority–>namenode主机名
path–>路径
范例:hdfs://localhost:54310/user/hadoop/test.txt
假设已经在/home/hadoop/hadoop-1.1.1/conf/core-site.xml里配置了fs.default.name=hdfs://localhost:54310,则仅使用/user/hadoop/test.txt即可。hdfs默认工作目录为/user/$USER,$USER是当前的登录用户名。

三、hdfs命令范例
hadoop fs -mkdir /user/hadoop
hadoop fs -ls /user
hadoop fs -lsr /user(递归的)
hadoop fs -put test.txt /user/hadoop(复制到hdfs://localhost:54310/user/hadoop目录下,首先要创建当前目录)
hadoop fs -get /user/hadoop/test.txt .(复制test.txt文件到本地当前目录下)
hadoop fs -cat /user/hadoop/test.txt
hadoop fs -tail /user/hadoop/test.txt(查看最后1000字节)
hadoop fs -rm /user/hadoop/test.txt
hadoop fs -help ls(查看ls命令的帮助文档)

四、在put时遇到的问题
异常信息: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create file/user/hadoopadmin. Name node is in safe mode.
解决办法:hadoop dfsadmin -safemode leave