HDFS:Hadoop Distributed File System。Hadoop分布式存储系统
一种允许文件通过网络在多台主机上分享的文件系统,可以让多机器上的用户分享文件和存储空间。
两大特性:通透性、容错性
分布式文件管理系统的实现很多,HDFS只是其中一种,HDSF不适合存储小文件。GFS、TFS。
# 查看
[root@cent7-1 hadoop-3.2.4]# bin/hdfs dfs -ls hdfs://cent7-1:9000/
Found 3 items
drwxr-xr-x - root supergroup 0 2023-09-07 14:25 hdfs://cent7-1:9000/hbase
drwx-wx-wx - root supergroup 0 2023-09-01 16:49 hdfs://cent7-1:9000/tmp
drwxr-xr-x - root supergroup 0 2023-09-01 16:47 hdfs://cent7-1:9000/user
# 上传文件(到根目录)
[root@cent7-1 hadoop-3.2.4]# bin/hdfs dfs -put README.txt hdfs://cent7-1:9000/
# 查看的简写
[root@cent7-1 hadoop-3.2.4]# bin/hdfs dfs -ls /
Found 4 items
-rw-r--r-- 1 root supergroup 1361 2023-10-16 21:35 /README.txt
drwxr-xr-x - root supergroup 0 2023-09-07 14:25 /hbase
drwx-wx-wx - root supergroup 0 2023-09-01 16:49 /tmp
drwxr-xr-x - root supergroup 0 2023-09-01 16:47 /user
# 查看文件内容
[root@cent7-1 hadoop-3.2.4]# bin/hdfs dfs -cat /README.txt
For the latest information about Hadoop, please visit our website at:
# 下载文件
[root@cent7-1 hadoop-3.2.4]# bin/hdfs dfs -get /tmp
[root@cent7-1 hadoop-3.2.4]# ls
bin etc include lib libexec LICENSE.txt nohup.out NOTICE.txt README.txt sbin share tmp
# 创建多级文件夹
[root@cent7-1 hadoop-3.2.4]# hdfs dfs -mkdir /dirtest
[root@cent7-1 hadoop-3.2.4]# hdfs dfs -mkdir /dirtest/xixi
## 或者使用命令[root@cent7-1 hadoop-3.2.4]# hdfs df s -mkdir -p /dirtest/xixi
[root@cent7-1 hadoop-3.2.4]# hdfs dfs -ls /
Found 5 items
-rw-r--r-- 1 root supergroup 1361 2023-10-16 21:35 /README.txt
drwxr-xr-x - root supergroup 0 2023-10-16 21:51 /dirtest
drwxr-xr-x - root supergroup 0 2023-09-07 14:25 /hbase
drwx-wx-wx - root supergroup 0 2023-09-01 16:49 /tmp
drwxr-xr-x - root supergroup 0 2023-09-01 16:47 /user
# 删除文件
[root@cent7-1 hadoop-3.2.4]# hdfs dfs -rm /README.txt
Deleted /README.txt
# 删除文件夹
[root@cent7-1 hadoop-3.2.4]# hdfs dfs -rm -r /dirtest
Deleted /dirtest
File和Block List
的关系,对应的关系信息存储在fsimages和edits文件中(当NameNode启动的时候会把文件中的内容加载到内存中)