赞
踩
bin/hadoop fs 具体命令
或
bin/hdfs dfs 具体命令
(dfs是fs的实现类)
二者区别
(曾经还有hadoop dfs:专门针对hdfs分布式文件系统,已经不推荐使用)
sbin/start-dfs.sh
sbin/start-yarn.sh
hadoop@hadoop101:/opt/module/hadoop-3.1.3/bin$ hadoop fs -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.
hadoop@hadoop101:/opt/module/hadoop-3.1.3/bin$ hadoop fs -ls /
Found 1 items
drwxr-xr-x - hadoop supergroup 0 2020-02-29 00:11 /home
hadoop@hadoop101:/opt/module/hadoop-3.1.3/bin$ hadoop fs -mkdir -p /home/hadoop/op_test
hadoop@hadoop101:/opt/module/hadoop-3.1.3/bin$ hadoop fs -ls /home/hadoop
Found 2 items
drwxr-xr-x - hadoop supergroup 0 2020-02-29 00:14 /home/hadoop/input
drwxr-xr-x - hadoop supergroup 0 2020-03-02 06:42 /home/hadoop/op_test
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ touch op_test.txt
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ echo "hello,hdfs" >> op_test.txt
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -moveFromLocal ./op_test.txt /home/hadoop/op_test
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ ls
test.input
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ touch op_append.txt
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ echo "append-hdfs" >> op_append.txt
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop -appendToFile op_append.txt /home/hadoop/op_test/op_test.txt
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -cat /home/hadoop/op_test/op_test.txt
hello,hdfs
append-hdfs
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -chmod 666 /home/hadoop/op_test/op_test.txt
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -chown hadoop:hadoop /home/hadoop/op_test/op_test.txt
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ ls
op_append.txt test.input
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -copyFromLocal test.input /home/hadoop/op_test
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -copyToLocal /home/hadoop/op_test/op_test.txt ./
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ ls
op_append.txt op_test.txt test.input
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -cp /home/hadoop/op_append.txt /home/hadoop/op_test
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -mv /home/hadoop/op_test/op_append.txt /home/hadoop
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -get /home/hadoop/op_append.txt ./
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ ls
op_append.txt op_test.txt test.input
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -getmerge /home/hadoop/op_test/* ./common.txt
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ ls
common.txt op_append.txt op_test.txt test.input
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ cat common.txt
append-hdfs
hello,hadoop!
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -put ./common.txt /home/hadoop/op_test/
2020-03-02 07:15:57,049 INFO sasl.SaslDataTransferClient: SASL encryption trust check: localHostTrusted = false, remoteHostTrusted = false
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -ls /home/hadoop/op_test
Found 3 items
-rw-r--r-- 3 hadoop supergroup 26 2020-03-02 07:15 /home/hadoop/op_test/common.txt
-rw-r--r-- 3 hadoop supergroup 12 2020-03-02 07:06 /home/hadoop/op_test/op_append.txt
-rw-r--r-- 3 hadoop supergroup 14 2020-03-02 06:56 /home/hadoop/op_test/test.input
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -tail
home/hadoop/op_test/common.txt
append-hdfs
hello,hadoop!
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -rm /home/hadoop/*.txt
Deleted /home/hadoop/op_append.txt
Deleted /home/hadoop/op_test.txt
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -mkdir /test
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -rmdir /test
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -du /home/hadoop/op_test
26 78 /home/hadoop/op_test/common.txt
12 36 /home/hadoop/op_test/op_append.txt
14 42 /home/hadoop/op_test/test.input
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -du -h /home/hadoop/op_test
26 78 /home/hadoop/op_test/common.txt
12 36 /home/hadoop/op_test/op_append.txt
14 42 /home/hadoop/op_test/test.input
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -du -s /home/hadoop/op_test
52 156 /home/hadoop/op_test
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -du -s -h /home/hadoop/op_test
hadoop@hadoop101:/opt/module/hadoop-3.1.3/testinput$ hadoop fs -setrep 2 /home/hadoop/op_test/common.txt
Replication 2 set: /home/hadoop/op_test/common.txt
注:实际可存在的副本数受DataNode的数量限制,不可大于DataNode的数量。若设置的副本数大于DataNode的数量,只在NameNode中记录本次设置的数量,而实际的副本数量将自动被控制为与DataNode相同数量。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。