HDFS集群中大數據運維常用的命令概述
作者:尹正傑
版權聲明:原創作品,謝絕轉載!否則將追究法律責任。
一.HDFS集群常用命令
1>.查看hdfs集群某路徑下的文件或目錄

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /outputDir drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls -R / drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir -rw-r--r-- 3 root supergroup 60 2020-03-12 19:20 /inputDir/wc.txt drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /outputDir -rw-r--r-- 3 root supergroup 0 2020-03-12 19:20 /outputDir/_SUCCESS -rw-r--r-- 3 root supergroup 54 2020-03-12 19:20 /outputDir/part-r-00000 drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 15:40 /tmp/hadoop-yarn drwxrwx--- - root supergroup 0 2020-03-12 16:22 /tmp/hadoop-yarn/staging drwxrwx--- - root supergroup 0 2020-03-12 15:40 /tmp/hadoop-yarn/staging/history drwxrwx--- - root supergroup 0 2020-03-12 16:23 /tmp/hadoop-yarn/staging/history/done drwxrwx--- - root supergroup 0 2020-03-12 16:23 /tmp/hadoop-yarn/staging/history/done/2020 drwxrwx--- - root supergroup 0 2020-03-12 16:23 /tmp/hadoop-yarn/staging/history/done/2020/03 drwxrwx--- - root supergroup 0 2020-03-12 16:23 /tmp/hadoop-yarn/staging/history/done/2020/03/12 drwxrwx--- - root supergroup 0 2020-03-12 16:23 /tmp/hadoop-yarn/staging/history/done/2020/03/12/000000 -rwxrwx--- 3 root supergroup 33748 2020-03-12 16:23 /tmp/hadoop-yarn/staging/history/done/2020/03/12/000000/job_1583999614207_0001-1584001369965-root-word+count-1584001390351-1-1-SUCCEEDED-default-1584001376310.jhist -rwxrwx--- 3 root supergroup 203051 2020-03-12 16:23 /tmp/hadoop-yarn/staging/history/done/2020/03/12/000000/job_1583999614207_0001_conf.xml drwxrwxrwt - root supergroup 0 2020-03-12 16:22 /tmp/hadoop-yarn/staging/history/done_intermediate drwxrwx--- - root supergroup 0 2020-03-12 16:23 /tmp/hadoop-yarn/staging/history/done_intermediate/root drwx------ - root supergroup 0 2020-03-12 16:22 /tmp/hadoop-yarn/staging/root drwx------ - root supergroup 0 2020-03-12 19:20 /tmp/hadoop-yarn/staging/root/.staging drwxrwxrwt - root root 0 2020-03-12 19:20 /tmp/logs drwxrwx--- - root root 0 2020-03-12 19:20 /tmp/logs/root drwxrwx--- - root root 0 2020-03-12 19:20 /tmp/logs/root/logs drwxrwx--- - root root 0 2020-03-12 19:21 /tmp/logs/root/logs/application_1584011863930_0001 -rw-r----- 3 root root 58844 2020-03-12 19:21 /tmp/logs/root/logs/application_1584011863930_0001/hadoop103.yinzhengjie.org.cn_25441 -rw-r----- 3 root root 53748 2020-03-12 19:21 /tmp/logs/root/logs/application_1584011863930_0001/hadoop104.yinzhengjie.org.cn_34288 drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie/jobhistory drwxrwx--- - root supergroup 0 2020-03-12 16:54 /yinzhengjie/jobhistory/manager drwxrwx--- - root supergroup 0 2020-03-12 16:54 /yinzhengjie/jobhistory/manager/2020 drwxrwx--- - root supergroup 0 2020-03-12 16:54 /yinzhengjie/jobhistory/manager/2020/03 drwxrwx--- - root supergroup 0 2020-03-12 16:54 /yinzhengjie/jobhistory/manager/2020/03/12 drwxrwx--- - root supergroup 0 2020-03-12 19:20 /yinzhengjie/jobhistory/manager/2020/03/12/000000 -rwxrwx--- 3 root supergroup 33731 2020-03-12 16:54 /yinzhengjie/jobhistory/manager/2020/03/12/000000/job_1584002509171_0001-1584003247341-root-word+count-1584003263906-1-1-SUCCEEDED-default-1584003252477.jhist -rwxrwx--- 3 root supergroup 202992 2020-03-12 16:54 /yinzhengjie/jobhistory/manager/2020/03/12/000000/job_1584002509171_0001_conf.xml -rwxrwx--- 3 root supergroup 33735 2020-03-12 19:09 /yinzhengjie/jobhistory/manager/2020/03/12/000000/job_1584010951301_0001-1584011344282-root-word+count-1584011360241-1-1-SUCCEEDED-default-1584011349879.jhist -rwxrwx--- 3 root supergroup 202988 2020-03-12 19:09 /yinzhengjie/jobhistory/manager/2020/03/12/000000/job_1584010951301_0001_conf.xml -rwxrwx--- 3 root supergroup 33732 2020-03-12 19:20 /yinzhengjie/jobhistory/manager/2020/03/12/000000/job_1584011863930_0001-1584012039874-root-word+count-1584012056179-1-1-SUCCEEDED-default-1584012045689.jhist -rwxrwx--- 3 root supergroup 202988 2020-03-12 19:20 /yinzhengjie/jobhistory/manager/2020/03/12/000000/job_1584011863930_0001_conf.xml drwxrwxrwt - root supergroup 0 2020-03-12 16:54 /yinzhengjie/jobhistory/tmp drwxrwx--- - root supergroup 0 2020-03-12 19:20 /yinzhengjie/jobhistory/tmp/root [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#
2>.查看某個目錄的文件大小

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -du -x / 60 /inputDir 54 /outputDir 349391 /tmp 710166 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -du / 60 /inputDir 54 /outputDir 349391 /tmp 710166 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -du -s / 1059671 / [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -du -h / 60 /inputDir 54 /outputDir 341.2 K /tmp 693.5 K /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]#
3>.查看文件系統的使用情況

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -df Filesystem Size Used Available Use% hdfs://hadoop101.yinzhengjie.org.cn:9000 4980400128000 3477504 4976186191872 0% [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -df -h Filesystem Size Used Available Use% hdfs://hadoop101.yinzhengjie.org.cn:9000 4.5 T 3.3 M 4.5 T 0% [root@hadoop101.yinzhengjie.org.cn ~]#
4>.查看某個文本文件的內容

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 6 items -rw-r--r-- 3 root supergroup 433 2020-03-16 09:14 /hosts drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /outputDir drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie drwxr-xr-x - root supergroup 0 2020-03-16 09:16 /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -cat /hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #Hadoop cluster 172.200.4.101 hadoop101.yinzhengjie.org.cn 172.200.4.102 hadoop102.yinzhengjie.org.cn 172.200.4.103 hadoop103.yinzhengjie.org.cn 172.200.4.104 hadoop104.yinzhengjie.org.cn 172.200.4.105 hadoop105.yinzhengjie.org.cn 172.200.4.106 hadoop106.yinzhengjie.org.cn [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 6 items -rw-r--r-- 3 root supergroup 433 2020-03-16 09:14 /hosts drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /outputDir drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie drwxr-xr-x - root supergroup 0 2020-03-16 09:16 /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -text /hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #Hadoop cluster 172.200.4.101 hadoop101.yinzhengjie.org.cn 172.200.4.102 hadoop102.yinzhengjie.org.cn 172.200.4.103 hadoop103.yinzhengjie.org.cn 172.200.4.104 hadoop104.yinzhengjie.org.cn 172.200.4.105 hadoop105.yinzhengjie.org.cn 172.200.4.106 hadoop106.yinzhengjie.org.cn [root@hadoop101.yinzhengjie.org.cn ~]#
5>.刪除某個文件或目錄

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 5 items -rw-r--r-- 3 root supergroup 433 2020-03-16 09:14 /hosts drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /outputDir drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -rm /hosts Deleted /hosts [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /outputDir drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 6 items -rw-r--r-- 3 root supergroup 433 2020-03-16 09:14 /hosts drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /outputDir drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie drwxr-xr-x - root supergroup 0 2020-03-16 09:16 /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -rm -r /yum.repos.d Deleted /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 5 items -rw-r--r-- 3 root supergroup 433 2020-03-16 09:14 /hosts drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /outputDir drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 5 items -rw-r--r-- 3 root supergroup 433 2020-03-16 09:42 /HOSTS drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /output drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -rm -r /HOSTS /inputDir /output Deleted /HOSTS Deleted /inputDir Deleted /output [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 2 items drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /bigdata drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /bigdata [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -rmdir /bigdata [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /etc Found 1 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc/hadoop [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -rmdir /etc rmdir: `/etc': Directory is not empty [root@hadoop101.yinzhengjie.org.cn ~]#
6>.重命名文件或目錄

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 5 items -rw-r--r-- 3 root supergroup 433 2020-03-16 09:37 /hosts drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /outputDir drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -mv /outputDir /output [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 5 items -rw-r--r-- 3 root supergroup 433 2020-03-16 09:37 /hosts drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /output drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 5 items -rw-r--r-- 3 root supergroup 433 2020-03-16 09:37 /hosts drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /output drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -mv /hosts /HOSTS [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 5 items -rw-r--r-- 3 root supergroup 433 2020-03-16 09:37 /HOSTS drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /output drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#
7>.創建目錄

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 2 items drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -mkdir /bigdata [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /bigdata drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /bigdata drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -mkdir -p /etc/hadoop [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /bigdata drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /etc Found 1 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc/hadoop [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /etc/hadoop [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#
8>.創建文件

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -touchz /bigdata.log [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-r--r-- 3 root supergroup 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#
9>.修改目錄或文件的權限

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -chmod o+x /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--x - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--x - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -chmod o-x /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -chmod g-x /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrw---- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrw---- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -chmod g+x /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -chmod u-w /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp dr-xrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp dr-xrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -chmod u+w /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-r--r-- 3 root supergroup 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -chmod g+w /bigdata.log [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root supergroup 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]#
10>.修改文件或目錄所屬組的權限

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root supergroup 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -chgrp yinzhengjie /bigdata.log [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /etc Found 1 items drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc/hadoop [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root supergroup 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -chgrp -R yinzhengjie /etc [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /etc Found 1 items drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc/hadoop [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -chown yinzhengjie:root /yinzhengjie/ [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - yinzhengjie root 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie Found 1 items drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie/jobhistory [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - yinzhengjie root 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie Found 1 items drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie/jobhistory [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -chown -R root:yinzhengjie /yinzhengjie/ [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie Found 1 items drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie/jobhistory [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]#
11>.修改文件或目錄的名稱

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -mv /yinzhengjie /yinzhengjie2020 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.log drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -mv /bigdata.log /bigdata.txt [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.txt drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 [root@hadoop101.yinzhengjie.org.cn ~]#
12>.拷貝文件或目錄

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.txt drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -cp /bigdata.txt /bigdata.log [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 5 items -rw-r--r-- 3 root supergroup 0 2020-03-16 10:13 /bigdata.log -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.txt drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 5 items -rw-r--r-- 3 root supergroup 0 2020-03-16 10:13 /bigdata.log -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.txt drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie2020 Found 1 items drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020/jobhistory [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -cp /yinzhengjie2020 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 6 items -rw-r--r-- 3 root supergroup 0 2020-03-16 10:13 /bigdata.log -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.txt drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxr-xr-x - root supergroup 0 2020-03-16 10:14 /yinzhengjie drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie/ Found 1 items drwxr-xr-x - root supergroup 0 2020-03-16 10:14 /yinzhengjie/jobhistory [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#
13>.查看文件的校驗和

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 6 items -rw-r--r-- 3 root supergroup 0 2020-03-16 10:13 /bigdata.log -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.txt drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxr-xr-x - root supergroup 0 2020-03-16 10:14 /yinzhengjie drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -checksum /bigdata.log /bigdata.log MD5-of-0MD5-of-0CRC32 00000000000000000000000070bc8f4b72a86921468bf8e8441dce51 [root@hadoop101.yinzhengjie.org.cn ~]#
14>.設置HDFS中文件的副本數量

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-r--r-- 3 root supergroup 433 2020-03-16 10:27 /hosts drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 drwxr-xr-x - root supergroup 0 2020-03-16 10:28 /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -setrep 2 /hosts Replication 2 set: /hosts [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-r--r-- 2 root supergroup 433 2020-03-16 10:27 /hosts drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 drwxr-xr-x - root supergroup 0 2020-03-16 10:28 /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie2020/jobhistory/manager/2020/03/12/000000 Found 6 items -rwxrwx--- 3 root yinzhengjie 33731 2020-03-12 16:54 /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584002509171_0001-1584003247341-root-word+count-1584003263906-1-1-SUCCEEDED-default-1584003252477.jhist -rwxrwx--- 3 root yinzhengjie 202992 2020-03-12 16:54 /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584002509171_0001_conf.xml -rwxrwx--- 3 root yinzhengjie 33735 2020-03-12 19:09 /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584010951301_0001-1584011344282-root-word+count-1584011360241-1-1-SUCCEEDED-default-1584011349879.jhist -rwxrwx--- 3 root yinzhengjie 202988 2020-03-12 19:09 /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584010951301_0001_conf.xml -rwxrwx--- 3 root yinzhengjie 33732 2020-03-12 19:20 /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584011863930_0001-1584012039874-root-word+count-1584012056179-1-1-SUCCEEDED-default-1584012045689.jhist -rwxrwx--- 3 root yinzhengjie 202988 2020-03-12 19:20 /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584011863930_0001_conf.xml [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -setrep -R 2 /yinzhengjie2020 Replication 2 set: /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584002509171_0001-1584003247341-root-word+count-1584003263906-1-1-SUCCEEDED-default-1584003252477.jhist Replication 2 set: /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584002509171_0001_conf.xml Replication 2 set: /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584010951301_0001-1584011344282-root-word+count-1584011360241-1-1-SUCCEEDED-default-1584011349879.jhist Replication 2 set: /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584010951301_0001_conf.xml Replication 2 set: /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584011863930_0001-1584012039874-root-word+count-1584012056179-1-1-SUCCEEDED-default-1584012045689.jhist Replication 2 set: /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584011863930_0001_conf.xml [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie2020/jobhistory/manager/2020/03/12/000000 Found 6 items -rwxrwx--- 2 root yinzhengjie 33731 2020-03-12 16:54 /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584002509171_0001-1584003247341-root-word+count-1584003263906-1-1-SUCCEEDED-default-1584003252477.jhist -rwxrwx--- 2 root yinzhengjie 202992 2020-03-12 16:54 /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584002509171_0001_conf.xml -rwxrwx--- 2 root yinzhengjie 33735 2020-03-12 19:09 /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584010951301_0001-1584011344282-root-word+count-1584011360241-1-1-SUCCEEDED-default-1584011349879.jhist -rwxrwx--- 2 root yinzhengjie 202988 2020-03-12 19:09 /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584010951301_0001_conf.xml -rwxrwx--- 2 root yinzhengjie 33732 2020-03-12 19:20 /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584011863930_0001-1584012039874-root-word+count-1584012056179-1-1-SUCCEEDED-default-1584012045689.jhist -rwxrwx--- 2 root yinzhengjie 202988 2020-03-12 19:20 /yinzhengjie2020/jobhistory/manager/2020/03/12/000000/job_1584011863930_0001_conf.xml [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#
15>.下載文件到本地

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 6 items -rw-r--r-- 3 root supergroup 0 2020-03-16 10:13 /bigdata.log -rw-rw-r-- 3 root yinzhengjie 0 2020-03-16 09:59 /bigdata.txt drwxr-xr-x - root yinzhengjie 0 2020-03-16 09:46 /etc drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxr-xr-x - root supergroup 0 2020-03-16 10:14 /yinzhengjie drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll total 0 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -get /bigdata.log [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll total 0 -rw-r--r-- 1 root root 0 Mar 16 10:21 bigdata.log [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-r--r-- 2 root supergroup 433 2020-03-16 10:27 /hosts drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 drwxr-xr-x - root supergroup 0 2020-03-16 10:28 /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll total 0 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -copyToLocal /hosts [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll total 4 -rw-r--r-- 1 root root 433 Mar 16 10:57 hosts [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# cat hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #Hadoop cluster 172.200.4.101 hadoop101.yinzhengjie.org.cn 172.200.4.102 hadoop102.yinzhengjie.org.cn 172.200.4.103 hadoop103.yinzhengjie.org.cn 172.200.4.104 hadoop104.yinzhengjie.org.cn 172.200.4.105 hadoop105.yinzhengjie.org.cn 172.200.4.106 hadoop106.yinzhengjie.org.cn [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -text /hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #Hadoop cluster 172.200.4.101 hadoop101.yinzhengjie.org.cn 172.200.4.102 hadoop102.yinzhengjie.org.cn 172.200.4.103 hadoop103.yinzhengjie.org.cn 172.200.4.104 hadoop104.yinzhengjie.org.cn 172.200.4.105 hadoop105.yinzhengjie.org.cn 172.200.4.106 hadoop106.yinzhengjie.org.cn [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# ll total 0 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 5 items -rw-r--r-- 3 root supergroup 86 2020-03-16 11:15 /host.log -rw-r--r-- 2 root supergroup 519 2020-03-16 11:09 /hosts drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 drwxr-xr-x - root supergroup 0 2020-03-16 10:28 /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -text /host.log 172.200.4.107 hadoop107.yinzhengjie.org.cn 172.200.4.108 hadoop108.yinzhengjie.org.cn [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -text /hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #Hadoop cluster 172.200.4.101 hadoop101.yinzhengjie.org.cn 172.200.4.102 hadoop102.yinzhengjie.org.cn 172.200.4.103 hadoop103.yinzhengjie.org.cn 172.200.4.104 hadoop104.yinzhengjie.org.cn 172.200.4.105 hadoop105.yinzhengjie.org.cn 172.200.4.106 hadoop106.yinzhengjie.org.cn 172.200.4.107 hadoop107.yinzhengjie.org.cn 172.200.4.108 hadoop108.yinzhengjie.org.cn [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -getmerge /host.log /hosts merge.log [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll total 4 -rw-r--r-- 1 root root 605 Mar 16 11:21 merge.log [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# cat merge.log 172.200.4.107 hadoop107.yinzhengjie.org.cn 172.200.4.108 hadoop108.yinzhengjie.org.cn 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #Hadoop cluster 172.200.4.101 hadoop101.yinzhengjie.org.cn 172.200.4.102 hadoop102.yinzhengjie.org.cn 172.200.4.103 hadoop103.yinzhengjie.org.cn 172.200.4.104 hadoop104.yinzhengjie.org.cn 172.200.4.105 hadoop105.yinzhengjie.org.cn 172.200.4.106 hadoop106.yinzhengjie.org.cn 172.200.4.107 hadoop107.yinzhengjie.org.cn 172.200.4.108 hadoop108.yinzhengjie.org.cn [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#
16>.將本地文件或目錄上傳到HDFS集群

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /outputDir drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #Hadoop cluster 172.200.4.101 hadoop101.yinzhengjie.org.cn 172.200.4.102 hadoop102.yinzhengjie.org.cn 172.200.4.103 hadoop103.yinzhengjie.org.cn 172.200.4.104 hadoop104.yinzhengjie.org.cn 172.200.4.105 hadoop105.yinzhengjie.org.cn 172.200.4.106 hadoop106.yinzhengjie.org.cn [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -put /etc/hosts / [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 5 items -rw-r--r-- 3 root supergroup 433 2020-03-16 09:14 /hosts drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /outputDir drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 5 items -rw-r--r-- 3 root supergroup 433 2020-03-16 09:14 /hosts drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /outputDir drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/ total 32 -rw-r--r--. 1 root root 1664 Nov 23 2018 CentOS-Base.repo -rw-r--r--. 1 root root 1309 Nov 23 2018 CentOS-CR.repo -rw-r--r--. 1 root root 649 Nov 23 2018 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 314 Nov 23 2018 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 Nov 23 2018 CentOS-Media.repo -rw-r--r--. 1 root root 1331 Nov 23 2018 CentOS-Sources.repo -rw-r--r--. 1 root root 5701 Nov 23 2018 CentOS-Vault.repo [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -put /etc/yum.repos.d/ / [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 6 items -rw-r--r-- 3 root supergroup 433 2020-03-16 09:14 /hosts drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /inputDir drwxr-xr-x - root supergroup 0 2020-03-12 19:20 /outputDir drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie drwxr-xr-x - root supergroup 0 2020-03-16 09:16 /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yum.repos.d Found 7 items -rw-r--r-- 3 root supergroup 1664 2020-03-16 09:16 /yum.repos.d/CentOS-Base.repo -rw-r--r-- 3 root supergroup 1309 2020-03-16 09:16 /yum.repos.d/CentOS-CR.repo -rw-r--r-- 3 root supergroup 649 2020-03-16 09:16 /yum.repos.d/CentOS-Debuginfo.repo -rw-r--r-- 3 root supergroup 630 2020-03-16 09:16 /yum.repos.d/CentOS-Media.repo -rw-r--r-- 3 root supergroup 1331 2020-03-16 09:16 /yum.repos.d/CentOS-Sources.repo -rw-r--r-- 3 root supergroup 5701 2020-03-16 09:16 /yum.repos.d/CentOS-Vault.repo -rw-r--r-- 3 root supergroup 314 2020-03-16 09:16 /yum.repos.d/CentOS-fasttrack.repo [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 2 items drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -copyFromLocal /etc/hosts / [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items -rw-r--r-- 3 root supergroup 433 2020-03-16 10:27 /hosts drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# ll /etc/yum.repos.d/ total 32 -rw-r--r--. 1 root root 1664 Nov 23 2018 CentOS-Base.repo -rw-r--r--. 1 root root 1309 Nov 23 2018 CentOS-CR.repo -rw-r--r--. 1 root root 649 Nov 23 2018 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 314 Nov 23 2018 CentOS-fasttrack.repo -rw-r--r--. 1 root root 630 Nov 23 2018 CentOS-Media.repo -rw-r--r--. 1 root root 1331 Nov 23 2018 CentOS-Sources.repo -rw-r--r--. 1 root root 5701 Nov 23 2018 CentOS-Vault.repo [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -copyFromLocal /etc/yum.repos.d / [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-r--r-- 3 root supergroup 433 2020-03-16 10:27 /hosts drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 drwxr-xr-x - root supergroup 0 2020-03-16 10:28 /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yum.repos.d Found 7 items -rw-r--r-- 3 root supergroup 1664 2020-03-16 10:28 /yum.repos.d/CentOS-Base.repo -rw-r--r-- 3 root supergroup 1309 2020-03-16 10:28 /yum.repos.d/CentOS-CR.repo -rw-r--r-- 3 root supergroup 649 2020-03-16 10:28 /yum.repos.d/CentOS-Debuginfo.repo -rw-r--r-- 3 root supergroup 630 2020-03-16 10:28 /yum.repos.d/CentOS-Media.repo -rw-r--r-- 3 root supergroup 1331 2020-03-16 10:28 /yum.repos.d/CentOS-Sources.repo -rw-r--r-- 3 root supergroup 5701 2020-03-16 10:28 /yum.repos.d/CentOS-Vault.repo -rw-r--r-- 3 root supergroup 314 2020-03-16 10:28 /yum.repos.d/CentOS-fasttrack.repo [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 4 items -rw-r--r-- 2 root supergroup 519 2020-03-16 11:09 /hosts drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 drwxr-xr-x - root supergroup 0 2020-03-16 10:28 /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll total 4 -rw-r--r-- 1 root root 86 Mar 16 11:08 host.log [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -moveFromLocal host.log / [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll total 0 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 5 items -rw-r--r-- 3 root supergroup 86 2020-03-16 11:15 /host.log -rw-r--r-- 2 root supergroup 519 2020-03-16 11:09 /hosts drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root yinzhengjie 0 2020-03-12 16:51 /yinzhengjie2020 drwxr-xr-x - root supergroup 0 2020-03-16 10:28 /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#
17>.將本地文件內容追加到hdfs集群中已經存在的文件

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -text /hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #Hadoop cluster 172.200.4.101 hadoop101.yinzhengjie.org.cn 172.200.4.102 hadoop102.yinzhengjie.org.cn 172.200.4.103 hadoop103.yinzhengjie.org.cn 172.200.4.104 hadoop104.yinzhengjie.org.cn 172.200.4.105 hadoop105.yinzhengjie.org.cn 172.200.4.106 hadoop106.yinzhengjie.org.cn [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll total 4 -rw-r--r-- 1 root root 86 Mar 16 11:08 host.log [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# cat host.log 172.200.4.107 hadoop107.yinzhengjie.org.cn 172.200.4.108 hadoop108.yinzhengjie.org.cn [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -appendToFile host.log /hosts [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll total 4 -rw-r--r-- 1 root root 86 Mar 16 11:08 host.log [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -text /hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #Hadoop cluster 172.200.4.101 hadoop101.yinzhengjie.org.cn 172.200.4.102 hadoop102.yinzhengjie.org.cn 172.200.4.103 hadoop103.yinzhengjie.org.cn 172.200.4.104 hadoop104.yinzhengjie.org.cn 172.200.4.105 hadoop105.yinzhengjie.org.cn 172.200.4.106 hadoop106.yinzhengjie.org.cn 172.200.4.107 hadoop107.yinzhengjie.org.cn 172.200.4.108 hadoop108.yinzhengjie.org.cn [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#
18>.顯示一個文件的末尾

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -tail /hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #Hadoop cluster 172.200.4.101 hadoop101.yinzhengjie.org.cn 172.200.4.102 hadoop102.yinzhengjie.org.cn 172.200.4.103 hadoop103.yinzhengjie.org.cn 172.200.4.104 hadoop104.yinzhengjie.org.cn 172.200.4.105 hadoop105.yinzhengjie.org.cn 172.200.4.106 hadoop106.yinzhengjie.org.cn 172.200.4.107 hadoop107.yinzhengjie.org.cn 172.200.4.108 hadoop108.yinzhengjie.org.cn [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -tail -f /hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 #Hadoop cluster 172.200.4.101 hadoop101.yinzhengjie.org.cn 172.200.4.102 hadoop102.yinzhengjie.org.cn 172.200.4.103 hadoop103.yinzhengjie.org.cn 172.200.4.104 hadoop104.yinzhengjie.org.cn 172.200.4.105 hadoop105.yinzhengjie.org.cn 172.200.4.106 hadoop106.yinzhengjie.org.cn 172.200.4.107 hadoop107.yinzhengjie.org.cn 172.200.4.108 hadoop108.yinzhengjie.org.cn
19>.查找文件或目錄

[root@hadoop101.yinzhengjie.com ~]# hdfs dfs -ls / Found 4 items drwxrwxrwx - root admingroup 0 2020-10-22 19:38 /input drwxr-xr-x - root admingroup 0 2020-11-09 06:23 /output drwxrwxrwx - root admingroup 0 2020-10-22 20:03 /user drwxrwxrwx - root admingroup 0 2020-11-09 03:41 /yinzhengjie [root@hadoop101.yinzhengjie.com ~]# [root@hadoop101.yinzhengjie.com ~]# hdfs dfs -mkdir /LOGS [root@hadoop101.yinzhengjie.com ~]# [root@hadoop101.yinzhengjie.com ~]# hdfs dfs -ls / Found 5 items drwxr-xr-x - root admingroup 0 2020-11-09 07:21 /LOGS drwxrwxrwx - root admingroup 0 2020-10-22 19:38 /input drwxr-xr-x - root admingroup 0 2020-11-09 06:23 /output drwxrwxrwx - root admingroup 0 2020-10-22 20:03 /user drwxrwxrwx - root admingroup 0 2020-11-09 03:41 /yinzhengjie [root@hadoop101.yinzhengjie.com ~]# [root@hadoop101.yinzhengjie.com ~]# [root@hadoop101.yinzhengjie.com ~]# hdfs dfs -find / -name LOGS -print /LOGS [root@hadoop101.yinzhengjie.com ~]# [root@hadoop101.yinzhengjie.com ~]#

[root@hadoop101.yinzhengjie.com ~]# hdfs dfs -find / -name LOGS -print /LOGS [root@hadoop101.yinzhengjie.com ~]# [root@hadoop101.yinzhengjie.com ~]# hdfs dfs -find / -iname LOGS -print /LOGS /user/root/.Trash/Current/yinzhengjie/logs /user/root/.Trash/Current/yinzhengjie/logs/nodemanager/aggregation/root/logs /yinzhengjie/logs [root@hadoop101.yinzhengjie.com ~]# [root@hadoop101.yinzhengjie.com ~]#
20.查看命令的幫助信息

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -help rm -rm [-f] [-r|-R] [-skipTrash] [-safely] <src> ... : Delete all files that match the specified file pattern. Equivalent to the Unix command "rm <src>" -f If the file does not exist, do not display a diagnostic message or modify the exit status to reflect an error. -[rR] Recursively deletes directories. -skipTrash option bypasses trash, if enabled, and immediately deletes <src>. -safely option requires safety confirmation, if enabled, requires confirmation before deleting large directory with more than <hadoop.shell.delete.limit.num.files> files. Delay is expected when walking over large directory recursively to count the number of files to be deleted before the confirmation. [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.com ~]# hdfs dfs -usage rm Usage: hadoop fs [generic options] -rm [-f] [-r|-R] [-skipTrash] [-safely] <src> ... [root@hadoop101.yinzhengjie.com ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -help mkdir -mkdir [-p] <path> ... : Create a directory in specified location. -p Do not fail if the directory already exists [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.com ~]# hdfs dfs -usage mkdir Usage: hadoop fs [generic options] -mkdir [-p] <path> ... [root@hadoop101.yinzhengjie.com ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -help cp -cp [-f] [-p | -p[topax]] [-d] <src> ... <dst> : Copy files that match the file pattern <src> to a destination. When copying multiple files, the destination must be a directory. Passing -p preserves status [topax] (timestamps, ownership, permission, ACLs, XAttr). If -p is specified with no <arg>, then preserves timestamps, ownership, permission. If -pa is specified, then preserves permission also because ACL is a super-set of permission. Passing -f overwrites the destination if it already exists. raw namespace extended attributes are preserved if (1) they are supported (HDFS only) and, (2) all of the source and target pathnames are in the /.reserved/raw hierarchy. raw namespace xattr preservation is determined solely by the presence (or absence) of the /.reserved/raw prefix and not by the -p option. Passing -d will skip creation of temporary file(<dst>._COPYING_). [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.com ~]# hdfs dfs -usage cp Usage: hadoop fs [generic options] -cp [-f] [-p | -p[topax]] [-d] <src> ... <dst> [root@hadoop101.yinzhengjie.com ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -help setrep -setrep [-R] [-w] <rep> <path> ... : Set the replication level of a file. If <path> is a directory then the command recursively changes the replication factor of all files under the directory tree rooted at <path>. -w It requests that the command waits for the replication to complete. This can potentially take a very long time. -R It is accepted for backwards compatibility. It has no effect. [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.com ~]# hdfs dfs -usage setrep Usage: hadoop fs [generic options] -setrep [-R] [-w] <rep> <path> ... [root@hadoop101.yinzhengjie.com ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -help getmerge -getmerge [-nl] [-skip-empty-file] <src> <localdst> : Get all the files in the directories that match the source file pattern and merge and sort them to only one file on local fs. <src> is kept. -nl Add a newline character at the end of each file. -skip-empty-file Do not add new line character for empty file. [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.com ~]# hdfs dfs -usage getmerge Usage: hadoop fs [generic options] -getmerge [-nl] [-skip-empty-file] <src> <localdst> [root@hadoop101.yinzhengjie.com ~]#

[root@hadoop101.yinzhengjie.com ~]# hdfs dfs -help find -find <path> ... <expression> ... : Finds all files that match the specified expression and applies selected actions to them. If no <path> is specified then defaults to the current working directory. If no expression is specified then defaults to -print. The following primary expressions are recognised: -name pattern -iname pattern Evaluates as true if the basename of the file matches the pattern using standard file system globbing. If -iname is used then the match is case insensitive. -print -print0 Always evaluates to true. Causes the current pathname to be written to standard output followed by a newline. If the -print0 expression is used then an ASCII NULL character is appended rather than a newline. The following operators are recognised: expression -a expression expression -and expression expression expression Logical AND operator for joining two expressions. Returns true if both child expressions return true. Implied by the juxtaposition of two expressions and so does not need to be explicitly specified. The second expression will not be applied if the first fails. [root@hadoop101.yinzhengjie.com ~]#

[root@hadoop101.yinzhengjie.com ~]# hdfs dfs -usage find Usage: hadoop fs [generic options] -find <path> ... <expression> ... [root@hadoop101.yinzhengjie.com ~]#
二.NameNode的鏡像文件和編輯日志管理相關命令
1>.下載鏡像文件

[root@hadoop101.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/hadoop-2.10.0/data/tmp/dfs/name/current/ total 10396 -rw-r--r-- 1 root root 42 Mar 12 03:27 edits_0000000000000000001-0000000000000000002 -rw-r--r-- 1 root root 42 Mar 12 03:27 edits_0000000000000000003-0000000000000000004 -rw-r--r-- 1 root root 1048576 Mar 12 03:27 edits_0000000000000000005-0000000000000000005 -rw-r--r-- 1 root root 1048576 Mar 12 03:27 edits_0000000000000000006-0000000000000000006 -rw-r--r-- 1 root root 42 Mar 12 03:29 edits_0000000000000000007-0000000000000000008 -rw-r--r-- 1 root root 1048576 Mar 12 03:29 edits_0000000000000000009-0000000000000000009 -rw-r--r-- 1 root root 42 Mar 12 03:32 edits_0000000000000000010-0000000000000000011 -rw-r--r-- 1 root root 42 Mar 12 04:32 edits_0000000000000000012-0000000000000000013 -rw-r--r-- 1 root root 1048576 Mar 12 04:32 edits_0000000000000000014-0000000000000000014 -rw-r--r-- 1 root root 42 Mar 12 04:57 edits_0000000000000000015-0000000000000000016 -rw-r--r-- 1 root root 1048576 Mar 12 04:57 edits_0000000000000000017-0000000000000000017 -rw-r--r-- 1 root root 42 Mar 12 05:03 edits_0000000000000000018-0000000000000000019 -rw-r--r-- 1 root root 1048576 Mar 12 05:03 edits_0000000000000000020-0000000000000000020 -rw-r--r-- 1 root root 42 Mar 12 07:46 edits_0000000000000000021-0000000000000000022 -rw-r--r-- 1 root root 1048576 Mar 12 07:46 edits_0000000000000000023-0000000000000000023 -rw-r--r-- 1 root root 42 Mar 12 08:41 edits_0000000000000000024-0000000000000000025 -rw-r--r-- 1 root root 42 Mar 12 09:41 edits_0000000000000000026-0000000000000000027 -rw-r--r-- 1 root root 42 Mar 12 10:41 edits_0000000000000000028-0000000000000000029 -rw-r--r-- 1 root root 42 Mar 12 11:41 edits_0000000000000000030-0000000000000000031 -rw-r--r-- 1 root root 42 Mar 12 12:41 edits_0000000000000000032-0000000000000000033 -rw-r--r-- 1 root root 42 Mar 12 13:41 edits_0000000000000000034-0000000000000000035 -rw-r--r-- 1 root root 42 Mar 12 14:41 edits_0000000000000000036-0000000000000000037 -rw-r--r-- 1 root root 672 Mar 12 15:41 edits_0000000000000000038-0000000000000000046 -rw-r--r-- 1 root root 1048576 Mar 12 15:41 edits_0000000000000000047-0000000000000000047 -rw-r--r-- 1 root root 42 Mar 12 15:54 edits_0000000000000000048-0000000000000000049 -rw-r--r-- 1 root root 23130 Mar 12 16:54 edits_0000000000000000050-0000000000000000237 -rw-r--r-- 1 root root 1140 Mar 12 17:54 edits_0000000000000000238-0000000000000000246 -rw-r--r-- 1 root root 42 Mar 12 18:54 edits_0000000000000000247-0000000000000000248 -rw-r--r-- 1 root root 24270 Mar 12 19:54 edits_0000000000000000249-0000000000000000448 -rw-r--r-- 1 root root 1048576 Mar 12 19:54 edits_0000000000000000449-0000000000000000449 -rw-r--r-- 1 root root 42 Mar 17 15:07 edits_0000000000000000450-0000000000000000451 -rw-r--r-- 1 root root 42 Mar 17 16:07 edits_0000000000000000452-0000000000000000453 -rw-r--r-- 1 root root 1048576 Mar 17 16:07 edits_inprogress_0000000000000000454 -rw-r--r-- 1 root root 3595 Mar 17 14:08 fsimage_0000000000000000449 -rw-r--r-- 1 root root 62 Mar 17 14:08 fsimage_0000000000000000449.md5 -rw-r--r-- 1 root root 3595 Mar 17 16:07 fsimage_0000000000000000453 -rw-r--r-- 1 root root 62 Mar 17 16:07 fsimage_0000000000000000453.md5 -rw-r--r-- 1 root root 4 Mar 17 16:07 seen_txid -rw-r--r-- 1 root root 217 Mar 17 14:08 VERSION [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll total 0 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs oiv -p XML -i /yinzhengjie/softwares/hadoop-2.10.0/data/tmp/dfs/name/current/fsimage_0000000000000000453 -o ./fsimage.xml 20/03/17 16:47:56 INFO offlineImageViewer.FSImageHandler: Loading 3 strings [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll total 16 -rw-r--r-- 1 root root 13956 Mar 17 16:47 fsimage.xml [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#
2>.下載編輯日志

[root@hadoop101.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/hadoop-2.10.0/data/tmp/dfs/name/current/ total 10396 -rw-r--r-- 1 root root 42 Mar 12 03:27 edits_0000000000000000001-0000000000000000002 -rw-r--r-- 1 root root 42 Mar 12 03:27 edits_0000000000000000003-0000000000000000004 -rw-r--r-- 1 root root 1048576 Mar 12 03:27 edits_0000000000000000005-0000000000000000005 -rw-r--r-- 1 root root 1048576 Mar 12 03:27 edits_0000000000000000006-0000000000000000006 -rw-r--r-- 1 root root 42 Mar 12 03:29 edits_0000000000000000007-0000000000000000008 -rw-r--r-- 1 root root 1048576 Mar 12 03:29 edits_0000000000000000009-0000000000000000009 -rw-r--r-- 1 root root 42 Mar 12 03:32 edits_0000000000000000010-0000000000000000011 -rw-r--r-- 1 root root 42 Mar 12 04:32 edits_0000000000000000012-0000000000000000013 -rw-r--r-- 1 root root 1048576 Mar 12 04:32 edits_0000000000000000014-0000000000000000014 -rw-r--r-- 1 root root 42 Mar 12 04:57 edits_0000000000000000015-0000000000000000016 -rw-r--r-- 1 root root 1048576 Mar 12 04:57 edits_0000000000000000017-0000000000000000017 -rw-r--r-- 1 root root 42 Mar 12 05:03 edits_0000000000000000018-0000000000000000019 -rw-r--r-- 1 root root 1048576 Mar 12 05:03 edits_0000000000000000020-0000000000000000020 -rw-r--r-- 1 root root 42 Mar 12 07:46 edits_0000000000000000021-0000000000000000022 -rw-r--r-- 1 root root 1048576 Mar 12 07:46 edits_0000000000000000023-0000000000000000023 -rw-r--r-- 1 root root 42 Mar 12 08:41 edits_0000000000000000024-0000000000000000025 -rw-r--r-- 1 root root 42 Mar 12 09:41 edits_0000000000000000026-0000000000000000027 -rw-r--r-- 1 root root 42 Mar 12 10:41 edits_0000000000000000028-0000000000000000029 -rw-r--r-- 1 root root 42 Mar 12 11:41 edits_0000000000000000030-0000000000000000031 -rw-r--r-- 1 root root 42 Mar 12 12:41 edits_0000000000000000032-0000000000000000033 -rw-r--r-- 1 root root 42 Mar 12 13:41 edits_0000000000000000034-0000000000000000035 -rw-r--r-- 1 root root 42 Mar 12 14:41 edits_0000000000000000036-0000000000000000037 -rw-r--r-- 1 root root 672 Mar 12 15:41 edits_0000000000000000038-0000000000000000046 -rw-r--r-- 1 root root 1048576 Mar 12 15:41 edits_0000000000000000047-0000000000000000047 -rw-r--r-- 1 root root 42 Mar 12 15:54 edits_0000000000000000048-0000000000000000049 -rw-r--r-- 1 root root 23130 Mar 12 16:54 edits_0000000000000000050-0000000000000000237 -rw-r--r-- 1 root root 1140 Mar 12 17:54 edits_0000000000000000238-0000000000000000246 -rw-r--r-- 1 root root 42 Mar 12 18:54 edits_0000000000000000247-0000000000000000248 -rw-r--r-- 1 root root 24270 Mar 12 19:54 edits_0000000000000000249-0000000000000000448 -rw-r--r-- 1 root root 1048576 Mar 12 19:54 edits_0000000000000000449-0000000000000000449 -rw-r--r-- 1 root root 42 Mar 17 15:07 edits_0000000000000000450-0000000000000000451 -rw-r--r-- 1 root root 42 Mar 17 16:07 edits_0000000000000000452-0000000000000000453 -rw-r--r-- 1 root root 1048576 Mar 17 16:07 edits_inprogress_0000000000000000454 -rw-r--r-- 1 root root 3595 Mar 17 14:08 fsimage_0000000000000000449 -rw-r--r-- 1 root root 62 Mar 17 14:08 fsimage_0000000000000000449.md5 -rw-r--r-- 1 root root 3595 Mar 17 16:07 fsimage_0000000000000000453 -rw-r--r-- 1 root root 62 Mar 17 16:07 fsimage_0000000000000000453.md5 -rw-r--r-- 1 root root 4 Mar 17 16:07 seen_txid -rw-r--r-- 1 root root 217 Mar 17 14:08 VERSION [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll total 16 -rw-r--r-- 1 root root 13956 Mar 17 16:47 fsimage.xml [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs oev -p XML -i /yinzhengjie/softwares/hadoop-2.10.0/data/tmp/dfs/name/current/edits_inprogress_0000000000000000454 -o ./edits.xml [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# ll total 20 -rw-r--r-- 1 root root 204 Mar 17 16:54 edits.xml -rw-r--r-- 1 root root 13956 Mar 17 16:47 fsimage.xml [root@hadoop101.yinzhengjie.org.cn ~]#
3>.
三.其它常用命令
1>.集群鍵數據拷貝
比如將"hdfs://hadoop101.yinzhengjie.org.cn:9000/yinzhengjie/hosts"的文件拷貝到另一個HDFS集群"hdfs://hadoop110.yinzhengjie.org.cn:9000/yinzhengjie2020/hosts" [root@hadoop101.yinzhengjie.org.cn ~]# hadoop distcp hdfs://hadoop101.yinzhengjie.org.cn:9000/yinzhengjie/hosts hdfs://hadoop110.yinzhengjie.org.cn:9000/yinzhengjie2020/hosts 博主推薦閱讀: http://hadoop.apache.org/docs/stable3/hadoop-distcp/DistCp.html
2>.歸檔小文件
HDFS存儲小文件的弊端分析:
每個文件均按塊存儲,每個塊的元數據存儲在NameNode的內存中,因此HDFS存儲小文件會非常低效率。因為大量小文件會耗盡NameNode中的大部分內存。但注意,存儲小文件所需要的磁盤容量和數據塊的大小無關。
例如,一個1MB的文件設置未128MB的塊存儲,實際使用的是1MB的磁盤空間,而不是128MB空間喲。
解決方案:
HDFS存檔文件或HAR文件,是一個更高效的文件存檔工具,它將文件存儲HDFS塊,在減少NameNode內存使用的同時,允許對文件進行透明的訪問。
具體來說,HDFS存檔文件對內還是一個一個獨立文件,對NameNode而言卻是一個整體一,減少了NameNode的內存消耗。

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-17 23:17 /yinzhengjie drwxr-xr-x - root supergroup 0 2020-03-17 23:20 /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie Found 1 items drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie/jobhistory [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yum.repos.d Found 7 items -rw-r--r-- 3 root supergroup 1664 2020-03-17 23:20 /yum.repos.d/CentOS-Base.repo -rw-r--r-- 3 root supergroup 1309 2020-03-17 23:20 /yum.repos.d/CentOS-CR.repo -rw-r--r-- 3 root supergroup 649 2020-03-17 23:20 /yum.repos.d/CentOS-Debuginfo.repo -rw-r--r-- 3 root supergroup 630 2020-03-17 23:20 /yum.repos.d/CentOS-Media.repo -rw-r--r-- 3 root supergroup 1331 2020-03-17 23:20 /yum.repos.d/CentOS-Sources.repo -rw-r--r-- 3 root supergroup 5701 2020-03-17 23:20 /yum.repos.d/CentOS-Vault.repo -rw-r--r-- 3 root supergroup 314 2020-03-17 23:20 /yum.repos.d/CentOS-fasttrack.repo [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hadoop archive -archiveName myFile.har -p /yum.repos.d /yinzhengjie 20/03/17 23:21:33 INFO client.RMProxy: Connecting to ResourceManager at hadoop106.yinzhengjie.org.cn/172.200.4.106:8032 20/03/17 23:21:34 INFO client.RMProxy: Connecting to ResourceManager at hadoop106.yinzhengjie.org.cn/172.200.4.106:8032 20/03/17 23:21:34 INFO client.RMProxy: Connecting to ResourceManager at hadoop106.yinzhengjie.org.cn/172.200.4.106:8032 20/03/17 23:21:34 INFO mapreduce.JobSubmitter: number of splits:1 20/03/17 23:21:34 INFO Configuration.deprecation: yarn.resourcemanager.system-metrics-publisher.enabled is deprecated. Instead, use yarn.system-metrics-publisher.enabled20/03/17 23:21:34 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1584457946785_0002 20/03/17 23:21:34 INFO conf.Configuration: resource-types.xml not found 20/03/17 23:21:34 INFO resource.ResourceUtils: Unable to find 'resource-types.xml'. 20/03/17 23:21:34 INFO resource.ResourceUtils: Adding resource type - name = memory-mb, units = Mi, type = COUNTABLE 20/03/17 23:21:34 INFO resource.ResourceUtils: Adding resource type - name = vcores, units = , type = COUNTABLE 20/03/17 23:21:35 INFO impl.YarnClientImpl: Submitted application application_1584457946785_0002 20/03/17 23:21:35 INFO mapreduce.Job: The url to track the job: http://hadoop106.yinzhengjie.org.cn:8088/proxy/application_158445794 6785_0002/20/03/17 23:21:35 INFO mapreduce.Job: Running job: job_1584457946785_0002 20/03/17 23:21:40 INFO mapreduce.Job: Job job_1584457946785_0002 running in uber mode : false 20/03/17 23:21:40 INFO mapreduce.Job: map 0% reduce 0% 20/03/17 23:21:48 INFO mapreduce.Job: map 100% reduce 0% 20/03/17 23:21:52 INFO mapreduce.Job: map 100% reduce 100% 20/03/17 23:21:52 INFO mapreduce.Job: Job job_1584457946785_0002 completed successfully 20/03/17 23:21:52 INFO mapreduce.Job: Counters: 49 File System Counters FILE: Number of bytes read=782 FILE: Number of bytes written=416013 FILE: Number of read operations=0 FILE: Number of large read operations=0 FILE: Number of write operations=0 HDFS: Number of bytes read=12415 HDFS: Number of bytes written=12347 HDFS: Number of read operations=24 HDFS: Number of large read operations=0 HDFS: Number of write operations=11 Job Counters Launched map tasks=1 Launched reduce tasks=1 Other local map tasks=1 Total time spent by all maps in occupied slots (ms)=5851 Total time spent by all reduces in occupied slots (ms)=2067 Total time spent by all map tasks (ms)=5851 Total time spent by all reduce tasks (ms)=2067 Total vcore-milliseconds taken by all map tasks=5851 Total vcore-milliseconds taken by all reduce tasks=2067 Total megabyte-milliseconds taken by all map tasks=5991424 Total megabyte-milliseconds taken by all reduce tasks=2116608 Map-Reduce Framework Map input records=8 Map output records=8 Map output bytes=759 Map output materialized bytes=782 Input split bytes=116 Combine input records=0 Combine output records=0 Reduce input groups=8 Reduce shuffle bytes=782 Reduce input records=8 Reduce output records=0 Spilled Records=16 Shuffled Maps =1 Failed Shuffles=0 Merged Map outputs=1 GC time elapsed (ms)=417 CPU time spent (ms)=2840 Physical memory (bytes) snapshot=486158336 Virtual memory (bytes) snapshot=4331356160 Total committed heap usage (bytes)=287309824 Shuffle Errors BAD_ID=0 CONNECTION=0 IO_ERROR=0 WRONG_LENGTH=0 WRONG_MAP=0 WRONG_REDUCE=0 File Input Format Counters Bytes Read=701 File Output Format Counters Bytes Written=0 [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls / Found 3 items drwxrwx--- - root supergroup 0 2020-03-12 19:20 /tmp drwxrwx--- - root supergroup 0 2020-03-17 23:21 /yinzhengjie drwxr-xr-x - root supergroup 0 2020-03-17 23:20 /yum.repos.d [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie/ Found 2 items drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie/jobhistory drwxr-xr-x - root supergroup 0 2020-03-17 23:21 /yinzhengjie/myFile.har [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie/myFile.har Found 4 items -rw-r--r-- 3 root supergroup 0 2020-03-17 23:21 /yinzhengjie/myFile.har/_SUCCESS -rw-r--r-- 3 root supergroup 726 2020-03-17 23:21 /yinzhengjie/myFile.har/_index -rw-r--r-- 3 root supergroup 23 2020-03-17 23:21 /yinzhengjie/myFile.har/_masterindex -rw-r--r-- 3 root supergroup 11598 2020-03-17 23:21 /yinzhengjie/myFile.har/part-0 [root@hadoop101.yinzhengjie.org.cn ~]#

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie/myFile.har Found 4 items -rw-r--r-- 3 root supergroup 0 2020-03-17 23:21 /yinzhengjie/myFile.har/_SUCCESS -rw-r--r-- 3 root supergroup 726 2020-03-17 23:21 /yinzhengjie/myFile.har/_index -rw-r--r-- 3 root supergroup 23 2020-03-17 23:21 /yinzhengjie/myFile.har/_masterindex -rw-r--r-- 3 root supergroup 11598 2020-03-17 23:21 /yinzhengjie/myFile.har/part-0 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls har:///yinzhengjie/myFile.har Found 7 items -rw-r--r-- 3 root supergroup 1664 2020-03-17 23:20 har:///yinzhengjie/myFile.har/CentOS-Base.repo -rw-r--r-- 3 root supergroup 1309 2020-03-17 23:20 har:///yinzhengjie/myFile.har/CentOS-CR.repo -rw-r--r-- 3 root supergroup 649 2020-03-17 23:20 har:///yinzhengjie/myFile.har/CentOS-Debuginfo.repo -rw-r--r-- 3 root supergroup 630 2020-03-17 23:20 har:///yinzhengjie/myFile.har/CentOS-Media.repo -rw-r--r-- 3 root supergroup 1331 2020-03-17 23:20 har:///yinzhengjie/myFile.har/CentOS-Sources.repo -rw-r--r-- 3 root supergroup 5701 2020-03-17 23:20 har:///yinzhengjie/myFile.har/CentOS-Vault.repo -rw-r--r-- 3 root supergroup 314 2020-03-17 23:20 har:///yinzhengjie/myFile.har/CentOS-fasttrack.repo [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#
3>.解壓歸檔文件

[root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie/ Found 2 items drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie/jobhistory drwxr-xr-x - root supergroup 0 2020-03-17 23:21 /yinzhengjie/myFile.har [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie/myFile.har Found 4 items -rw-r--r-- 3 root supergroup 0 2020-03-17 23:21 /yinzhengjie/myFile.har/_SUCCESS -rw-r--r-- 3 root supergroup 726 2020-03-17 23:21 /yinzhengjie/myFile.har/_index -rw-r--r-- 3 root supergroup 23 2020-03-17 23:21 /yinzhengjie/myFile.har/_masterindex -rw-r--r-- 3 root supergroup 11598 2020-03-17 23:21 /yinzhengjie/myFile.har/part-0 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hadoop fs -cp har:///yinzhengjie/myFile.har/* /yinzhengjie/ [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie/ Found 9 items -rw-r--r-- 3 root supergroup 1664 2020-03-17 23:28 /yinzhengjie/CentOS-Base.repo -rw-r--r-- 3 root supergroup 1309 2020-03-17 23:28 /yinzhengjie/CentOS-CR.repo -rw-r--r-- 3 root supergroup 649 2020-03-17 23:28 /yinzhengjie/CentOS-Debuginfo.repo -rw-r--r-- 3 root supergroup 630 2020-03-17 23:28 /yinzhengjie/CentOS-Media.repo -rw-r--r-- 3 root supergroup 1331 2020-03-17 23:28 /yinzhengjie/CentOS-Sources.repo -rw-r--r-- 3 root supergroup 5701 2020-03-17 23:28 /yinzhengjie/CentOS-Vault.repo -rw-r--r-- 3 root supergroup 314 2020-03-17 23:28 /yinzhengjie/CentOS-fasttrack.repo drwxrwx--- - root supergroup 0 2020-03-12 16:51 /yinzhengjie/jobhistory drwxr-xr-x - root supergroup 0 2020-03-17 23:21 /yinzhengjie/myFile.har [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]# hdfs dfs -ls /yinzhengjie/myFile.har Found 4 items -rw-r--r-- 3 root supergroup 0 2020-03-17 23:21 /yinzhengjie/myFile.har/_SUCCESS -rw-r--r-- 3 root supergroup 726 2020-03-17 23:21 /yinzhengjie/myFile.har/_index -rw-r--r-- 3 root supergroup 23 2020-03-17 23:21 /yinzhengjie/myFile.har/_masterindex -rw-r--r-- 3 root supergroup 11598 2020-03-17 23:21 /yinzhengjie/myFile.har/part-0 [root@hadoop101.yinzhengjie.org.cn ~]# [root@hadoop101.yinzhengjie.org.cn ~]#