Hadoop 常用shell命令
阿新 • • 發佈:2018-12-27
Hadoop 常用shell命令
1. 檔案操作
- 檢視檔案
hadoop fs -ls /
[[email protected] logs]# hadoop fs -ls /
Found 2 items
drwxr-xr-x - root supergroup 0 2018-12-18 11:25 /hbase
drwxr-xr-x - root supergroup 0 2018-12-22 08:24 /input
- 建立資料夾
hadoop fs -mkdir /input
[[email protected] logs]# hadoop fs -mkdir /test
[[email protected] logs]# hadoop fs -ls /
Found 3 items
drwxr-xr-x - root supergroup 0 2018-12-18 11:25 /hbase
drwxr-xr-x - root supergroup 0 2018-12-22 08:24 /input
drwxr-xr-x - root supergroup 0 2018-12-22 08:27 /test
- 刪除資料夾/檔案
[[email protected]
logs]# hadoop fs -rm -R /test 18/12/22 08:28:12 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 0 minutes, Emptier interval = 0 minutes. Deleted /test [[email protected] logs]# hadoop fs -ls / Found 2 items drwxr-xr-x - root supergroup 0 2018-12-18 11:25 /hbase drwxr-xr-x - root supergroup 0 2018-12-22 08:24 /input
- 使用hdfs dfs 上傳一個檔案到指定目錄下:
[[email protected] temp]# hdfs dfs -put data.txt /input/
[[email protected] temp]# hdfs dfs -ls /input/
Found 1 items
-rw-r--r-- 3 root supergroup 108 2018-12-22 08:32 /input/data.txt
[[email protected] temp]# cat data.txt
hadoop is a good platform to analyze big data in disk.
spark is a perfet tool to deal with big data in RAM.