基本文件命令
hadoop fs -cmd<args>
cmd的命令通常与unix的命令相同,如 hadoop fs -ls
查看列表
hadoop fs -ls /
查看目录结构
hadoop fs -lsr /
创建目录(root 是当前用户的目录)
hadoop fs mkdir /user/root
加入文件
hadoop fs put example.txt .
注意上面这个命令最后一个参数是(.)。这意味着我们把文件放入了默认的工作目录。
等价于
hadoop fs put example.txt /user/root/
删除
hadoop fs rm /user/root/example.txt //如果rm不行,用rmr
查看
hadoop fs -cat /user/root/example.txt
hadoop fs -cat hdfs://192.168.1.77:9002/user/root/example.txt
查看最后的一千个字节
会出现hadoop命令格式以及hadoop有的命令结果如下:
Usage: hadoop [--config confdir] COMMAND
where COMMAND is one of:
namenode-format format the DFS filesystem
secondarynamenode run the DFS secondary namenode
namenode run the DFS namenode
datanode run a DFS datanode
dfsadmin run a DFS admin client
mradmin run a Map-Reduce admin client
fsck run a DFS filesystem checking utility
fs run a generic filesystem user client
balancer run a cluster balancing utility
jobtracker run the MapReduce job Tracker node
pipes run a Pipes job
tasktracker run a MapReduce task Tracker node
job manipulate MapReduce jobs
queue get information regarding JobQueues
version print the version
jar run a jar file
distcp copy file or directoriesrecursively
archive -archiveName NAME * create a hadooparchive
daemonlog get/set the log level for each daemon
or
CLASSNAME run the class named CLASSNAME
Most commands print help when invoked w/o parameters.
获取到本地,注意上面这个命令最后一个参数是(.)
hadoop fs -get /user/root/example.txt .
查看帮助,如查看ls帮助
hadoop fs -help ls
hadoop fs -cmd<args>
cmd的命令通常与unix的命令相同,如 hadoop fs -ls
查看列表
hadoop fs -ls /
查看目录结构
hadoop fs -lsr /
创建目录(root 是当前用户的目录)
hadoop fs mkdir /user/root
加入文件
hadoop fs put example.txt .
注意上面这个命令最后一个参数是(.)。这意味着我们把文件放入了默认的工作目录。
等价于
hadoop fs put example.txt /user/root/
删除
hadoop fs rm /user/root/example.txt //如果rm不行,用rmr
查看
hadoop fs -cat /user/root/example.txt
hadoop fs -cat hdfs://192.168.1.77:9002/user/root/example.txt
查看最后的一千个字节
hadoop fs -tail /user/root/example.txt
1.进入hadoop
/usr/mahout/hadoop-0.20.2/bin$hadoop
Usage: hadoop [--config confdir] COMMAND
where COMMAND is one of:
Most commands print help when invoked w/o parameters.
获取到本地,注意上面这个命令最后一个参数是(.)
hadoop fs -get /user/root/example.txt .
查看帮助,如查看ls帮助
hadoop fs -help ls