Hadoop 常用shell命令

版权声明:如若转载,请联系作者。 https://blog.csdn.net/liu16659/article/details/85193533

Hadoop 常用shell命令

1. 文件操作

  • 查看文件
    hadoop fs -ls /
[root@server4 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
[root@server4 logs]# hadoop fs -mkdir /test
[root@server4 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
  • 删除文件夹/文件
[root@server4 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
[root@server4 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 上传一个文件到指定目录下:
[root@server4 temp]# hdfs dfs -put data.txt /input/
[root@server4 temp]# hdfs dfs -ls /input/
Found 1 items
-rw-r--r--   3 root supergroup        108 2018-12-22 08:32 /input/data.txt
[root@server4 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.

猜你喜欢

转载自blog.csdn.net/liu16659/article/details/85193533