1 hadoop命令
在终端输入hadoop,会出现此命令可用的一些参数
[hadoop@izuf621gcimj21arvwjqo6z ~]$ hadoop
#Usage:使用的格式
Usage: hadoop [--config confdir] COMMAND
where COMMAND is one of:
#下面左边为命令参数,右边为参数说明
fs run a generic filesystem user client
version print the version
jar <jar> run a jar file
checknative [-a|-h] check native hadoop and compression libraries availability
distcp <srcurl> <desturl> copy file or directories recursively
archive -archiveName NAME -p <parent path> <src>* <dest> create a hadoop archive
classpath prints the class path needed to get the
credential interact with credential providers
Hadoop jar and the required libraries
daemonlog get/set the log level for each daemon
trace view and modify Hadoop tracing settings
常用参数如下:
参数 | 说明 |
---|---|
fs | 客户端跑一个文件系统命令,例如增,删,查; hadoop fs 等价于 hdfs dfs |
version | 查看hadoop的版本 |
jar | 运行一个jar到yarn上 |
checknative | 查看hadoop的压缩库是不是可用 |
classpath | 查看启动的时候,什么路径下的jar包会被加载 |
2 hdfs命令
[hadoop@izuf621gcimj21arvwjqo6z ~]$ hdfs
#Usage:使用的格式
Usage: hdfs [--config confdir] COMMAND
where COMMAND is one of:
#命令参数,左边是参数,右边是说明
dfs run a filesystem command on the file systems supported in Hadoop.
namenode -format format the DFS filesystem
secondarynamenode run the DFS secondary namenode
namenode run the DFS namenode
journalnode run the DFS journalnode
zkfc run the ZK Failover Controller daemon
datanode run a DFS datanode
dfsadmin run a DFS admin client
haadmin run a DFS HA admin client
fsck run a DFS filesystem checking utility
balancer run a cluster balancing utility
jmxget get JMX exported values from NameNode or DataNode.
mover run a utility to move block replicas across
storage types
oiv apply the offline fsimage viewer to an fsimage
oiv_legacy apply the offline fsimage viewer to an legacy fsimage
oev apply the offline edits viewer to an edits file
fetchdt fetch a delegation token from the NameNode
getconf get config values from configuration
groups get the groups which users belong to
snapshotDiff diff two snapshots of a directory or diff the
current directory contents with a snapshot
lsSnapshottableDir list all snapshottable dirs owned by the current user
Use -help to see options
portmap run a portmap service
nfs3 run an NFS version 3 gateway
cacheadmin configure the HDFS cache
crypto configure HDFS encryption zones
storagepolicies list/get/set block storage policies
version print the version
常用命令:
参数 | 说明 |
---|---|
dfs | 客户端跑一个文件系统命令,例如增,删,查; |
namenode -format | 格式化NN节点,生产上慎用,高危命令 |
fsck | 查看文件系统的健康状态 |
getconf | 获取配置文件name对应的value |
下图,我们配置的name和valude
通过getconf命令,根据name获取到value
3 hdfs dfs命令(重要)
[hadoop@izuf621gcimj21arvwjqo6z hadoop]$ hdfs dfs
Usage: hadoop fs [generic options]
[-appendToFile <localsrc> ... <dst>]
[-cat [-ignoreCrc] <src> ...]
[-checksum <src> ...]
[-chgrp [-R] GROUP PATH...]
[-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...]
[-chown [-R] [OWNER][:[GROUP]] PATH...]
[-copyFromLocal [-f] [-p] [-l] <localsrc> ... <dst>]
[-copyToLocal [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-count [-q] [-h] [-v] <path> ...]
[-cp [-f] [-p | -p[topax]] <src> ... <dst>]
[-createSnapshot <snapshotDir> [<snapshotName>]]
[-deleteSnapshot <snapshotDir> <snapshotName>]
[-df [-h] [<path> ...]]
[-du [-s] [-h] <path> ...]
[-expunge]
[-find <path> ... <expression> ...]
[-get [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-getfacl [-R] <path>]
[-getfattr [-R] {-n name | -d} [-e en] <path>]
[-getmerge [-nl] <src> <localdst>]
[-help [cmd ...]]
[-ls [-d] [-h] [-R] [<path> ...]]
[-mkdir [-p] <path> ...]
[-moveFromLocal <localsrc> ... <dst>]
[-moveToLocal <src> <localdst>]
[-mv <src> ... <dst>]
[-put [-f] [-p] [-l] <localsrc> ... <dst>]
[-renameSnapshot <snapshotDir> <oldName> <newName>]
[-rm [-f] [-r|-R] [-skipTrash] <src> ...]
[-rmdir [--ignore-fail-on-non-empty] <dir> ...]
[-setfacl [-R] [{-b|-k} {-m|-x <acl_spec>} <path>]|[--set <acl_spec> <path>]]
[-setfattr {-n name [-v value] | -x name} <path>]
[-setrep [-R] [-w] <rep> <path> ...]
[-stat [format] <path> ...]
[-tail [-f] <file>]
[-test -[defsz] <path>]
[-text [-ignoreCrc] <src> ...]
[-touchz <path> ...]
[-usage [cmd ...]]
参数 | 说明 |
---|---|
cat | 查看文件内容 |
chmod | 修改文件或文件夹的读写执权限 |
chwon | 修改文件所属用户及用户组 |
copyFromLocal | 把本地文件上传到hdfs |
copyToLocal | 把hdfs文件下载到本地 |
put | 把本地文件上传到hdfs |
get | 把hdfs文件下载到本地 |
cp | 拷贝文件(hdfs内部拷贝) |
df | 查看hdfs磁盘使用情况 |
du | 查看某个文件目录或者文件的大小 |
find | 搜索文件,可模糊搜索 |
ls | 查看某个路径下的文件和目录清单 |
mkdir | 创建文件夹 |
mv | 移动文件或着文件夹 |
rm | 删除文件或者文件夹 |
rmdir | 删除文件夹 |
text | 查看某个文件的内容 |