大数据 分布式文件系统HDFS

软件版本

hadoop-2.6.0-cdh5.7.0.tar.gz

目录:

1.分布式文件系统HDFS
2.HDFS优缺点
3.分布式文件系统的设计思想
4.HDFS架构图
5.Hadoop下载和JDK的安装
6.shh安装及HDFS文件参数配置
7.HDFS shell操作
8.HDFS Java API编程
9.HDFS读写数据流程
10.hadoop新特性

11.HDFS日志收集实战案例


1.分布式文件系统HDFS

1) dataset 量达到一定规模时,那么单机就没有办法处理

2) 把数据分布到各个独立的机器上(多台机器共同协作)

官网查找资料,hadoop.apache.org

 



介绍

HDFSHadoop Distributed File System)是一个分布式的文件系统,被设计运行在廉价的硬盘上,和目前一些分布式的文件系统有很大的相似点,但是比起其它的分布式文件系统也有很大不同。HDFS是个高容错(fault-tolerant)的系统,被部署在廉价的硬盘上。HEFS提供高吞吐量来访问应用数据,并且适合大数据的访问。HDFS放松了一些POSIX的要求,使其能流式的访问文件系统。HDFS最开始是Apache Nutch搜索引擎的基础设备。HDFSapache的一个核心项目(The Hadoop Distributed File System (HDFS) is a distributed file system designed to run on commodity hardware. It has many similarities with existing distributed file systems. However, the differences from other distributed file systems are significant. HDFS is highly fault-tolerant and is designed to be deployed on low-cost hardware. HDFS provides high throughput access to application data and is suitable for applications that have large data sets. HDFS relaxes a few POSIX requirements to enable streaming access to file system data. HDFS was originally built as infrastructure for the Apache Nutch web search engine project. HDFS is part of the Apache Hadoop Core project. The project URL is http://hadoop.apache.org/

2.HDFS优缺点

优点 1.构建在廉价的机器上。 2.使用大数据处理。 3.高容错

官方说明

1. 硬件错误(Hardware Failure

硬件错误是一个常态而不是异常.一个HDFS有可能包含成百上千的服务机器,每一台服务器存储文件的一个部分。事实上包含很大的结构,每一部分很大可能出错,这意味着HDFS大部分是不能用的,因此,自动发现错误和快递自动的恢复他们是HDFS的一个目标。(Hardware failure is the norm rather than the exception. An HDFS instance may consist of hundreds or thousands of server machines, each storing part of the file system’s data. The fact that there are a huge number of components and that each component has a non-trivial probability of failure means that some component of HDFS is always non-functional. Therefore, detection of faults and quick, automatic recovery from them is a core architectural goal of HDFS.

2. 流式的访问数据(Streaming Data Access

HDFS上面的应用程序需要用流式的方式访问数据。这一点是他和普通的应用程序的区别.HDFS更多的是用于批处理,而不是用户的交互式使用。重点是数据访问的高吞吐量,而不是数据访问的低延迟。(Applications that run on HDFS need streaming access to their data sets. They are not general purpose applications that typically run on general purpose file systems. HDFS is designed more for batch processing rather than interactive use by users. The emphasis is on high throughput of data access rather than low latency of data access. POSIX imposes many hard requirements that are not needed for applications that are targeted for HDFS. POSIX semantics in a few key areas has been traded to increase data throughput rates.

3. 大规模的数据集(large Data Sets

HDFS运行的应用程序具有大数据集,一个典型的HDFS可以是gb,也可以是tb.HDFS被调优以支持大文件,它应该为单个集群中的数百个节点提供高聚合的数据带宽和规模,能能在在一个HDFS上支持数以千计的文件。(Applications that run on HDFS have large data sets. A typical file in HDFS is gigabytes to terabytes in size. Thus, HDFS is tuned to support large files. It should provide high aggregate data bandwidth and scale to hundreds of nodes in a single cluster. It should support tens of millions of files in a single instance.

4. 简单的一致性模式(Simple Coherency Model

HDFS是一个一次写入多次读取的模式。一个文件一旦创建,写入,关闭,就不会被更改,除非是附加和结尾。它能够把你添加的内容附加到文件末尾,但是不能任意点更新。这种假设就解决的数据一致性问题,使得支持高吞吐量访问。MapReduce应用和爬虫应用就适合这种模型。(HDFS applications need a write-once-read-many access model for files. A file once created, written, and closed need not be changed except for appends and truncates. Appending the content to the end of the files is supported but cannot be updated at arbitrary point. This assumption simplifies data coherency issues and enables high throughput data access. A MapReduce application or a web crawler application fits perfectly with this model.

5. 移动计算比移动数据更划算(Moving Computation is Cheaper than Moving Data”)

如果在其操作的数据附近执行,应用程序请求的计算效率会更高。当数据量非常大的时候,这一点非常重要,这将最小化网络拥塞,并增加系统的总体吞吐量。我们的假设是,将计算迁移到数据所在的位置,而不是将数据移动到应用程序运行的位置通常更好。(A computation requested by an application is much more efficient if it is executed near the data it operates on. This is especially true when the size of the data set is huge. This minimizes network congestion and increases the overall throughput of the system. The assumption is that it is often better to migrate the computation closer to where the data is located rather than moving the data to where the application is running. HDFS provides interfaces for applications to move themselves closer to where the data is located.

6. 异构软硬件平台之间的可移植性(Portability Across Heterogeneous Hardware and Software Platforms

HDFS被设计成易于从一个平台移植到另一个平台。这促进了HDFS的广泛采用,作为一组大型应用程序的首选平台。

缺点

不适合低延迟数据访问。 2.不适合小文件存储

3.分布式文件系统的设计思想

1.将一个文件拆分成多个Block

2.每个block以多副本的方式存储在各个节点上

3.保存元数据映射关系

4.负载均衡

5.分布式并行计算



4.HDFS架构图


HDFS是一个master/slave的架构,HDFS集群由一个NameNode组成,它是管理文件系统名称空间的主服务器,并管理客户端对文件的访问。此外,还有许多datanode,通常是集群中的一个节点,负责管理存储。HDFS公开一个文件系统名称空间,并允许将用户数据存储在文件中。在内部,一个文件被分割成一个或多个块,这些块存储在一组datanode中。NameNode执行文件系统名称空间操作,如打开,关闭,重命名文件和目录。它还决定了块到datanode的映射。datanode负责从文件系统的客户端提供读和写请求。datanode也会在NameNode的指令下执行块创建、删除和复制。(HDFS has a master/slave architecture. An HDFS cluster consists of a single NameNode, a master server that manages the file system namespace and regulates access to files by clients. In addition, there are a number of DataNodes, usually one per node in the cluster, which manage storage attached to the nodes that they run on. HDFS exposes a file system namespace and allows user data to be stored in files. Internally, a file is split into one or more blocks and these blocks are stored in a set of DataNodes. The NameNode executes file system namespace operations like opening, closing, and renaming files and directories. It also determines the mapping of blocks to DataNodes. The DataNodes are responsible for serving read and write requests from the file system’s clients. The DataNodes also perform block creation, deletion, and replication upon instruction from the NameNode.

 

NameNodeDataNode一般都运行在一些廉价的机器上。这些典型的机器运行在linux的操作系统上面,HDFS是用Java语言的,任意机器只要能运行java,就能运行,一个典型的部署有专门的机器,只运行NameNode软件。集群中的每台机器都运行DataNode软件的一个实例。但是在生产环境上不是这么干的。(The NameNode and DataNode are pieces of software designed to run on commodity machines. These machines typically run a GNU/Linux operating system (OS). HDFS is built using the Java language; any machine that supports Java can run the NameNode or the DataNode software. Usage of the highly portable Java language means that HDFS can be deployed on a wide range of machines. A typical deployment has a dedicated machine that runs only the NameNode software. Each of the other machines in the cluster runs one instance of the DataNode software. The architecture does not preclude running multiple DataNodes on the same machine but in a real deployment that is rarely the case.)

 

HDFS文件副本存放

  

 

文件系统(The File System Namespace

HDFS支持传统的层级的文件组织。用户或应用程序可以在这些目录中创建目录和储存文件。文件系统名称空间层次结构类似于大多数其他现有的文件系统;一个人可以创造和快速眼动(HDFS supports a traditional hierarchical file organization. A user or an application can create directories and store files inside these directories. The file system namespace hierarchy is similar to most other existing file systems; one can create and remove files, move a file from one directory to another, or rename a file.

NameNode维护文件系统名称空间。对文件系统名称空间或其属性的任何更改都由NameNode记录。一个应用程序可以指定应该由HDFS维护的文件的副本数量,应用程序可以指定应该由HDFS维护的文件的副本数量。文件的拷贝数称为该文件的副本因子。这些信息由NameNode存储(The NameNode maintains the file system namespace. Any change to the file system namespace or its properties is recorded by the NameNode. An application can specify the number of replicas of a file that should be maintained by HDFS. The number of copies of a file is called the replication factor of that file. This information is stored by the NameNode.

 

数据复制(Data Replication

HDFS被设计成可靠地在大型集群中跨机器存储非常大的文件。它将每个文件存储为一个块的序列。文件的块被复制用于容错。块大小和复制因子是每个文件可配置的。(HDFS is designed to reliably store very large files across machines in a large cluster. It stores each file as a sequence of blocks. The blocks of a file are replicated for fault tolerance. The block size and replication factor are configurable per file.

一个blocks除了最后一个block,其它都一样。(All blocks in a file except the last block are the same size, while users can start a new block without filling out the last block to the configured block size after the support for variable length block was added to append and hsync

应用程序可以指定文件的副本系数(An application can specify the number of replicas of a file. The replication factor can be specified at file creation time and can be changed later. Files in HDFS are write-once (except for appends and truncates) and have strictly one writer at any time.

NameNode做出关于块复制的所有决定。它定期接收集群中每个datanode的心跳和阻塞报告。接收心跳意味着DataNode正常工作。(The NameNode makes all decisions regarding replication of blocks. It periodically receives a Heartbeat and a Blockreport from each of the DataNodes in the cluster. Receipt of a Heartbeat implies that the DataNode is functioning properly. A Blockreport contains a list of all blocks on a DataNode.

 

自己总结:

MasterNameNode/NN)带NSlavesDataNode/DN

HDFS/YARN/HBase也是类似结构

1个文件会被拆分成多个Block

Blocksize:128m

130M ==> 2block: 128M2M

NN

1)负责客户端请求的响应

2)负责元数据(文件的名词,副本系数,Block存放的DN)的管理

DN

1)存储用户的文件对应的数据块

2)要定期向NN发送心跳信息,汇报本身及其所有的Block信息,健康状况

NameNode + NDataNode

建议:NNDN是部署在不同的节点上

Replication factor:副本系数,副本因子

All blocks in a file except the last block are the same size


5.Hadoop下载和JDK的安装


6.shh安装及HDFS文件参数配置


7.HDFS shell操作


8.HDFS Java API编程


9.HDFS读写数据流程


10.hadoop新特性


11.HDFS日志收集实战案例


猜你喜欢

转载自blog.csdn.net/fulq1234/article/details/79914053