From 2298f2d76b2cafd84c8f7421ae792336d6f2f37a Mon Sep 17 00:00:00 2001 From: Chris Douglas Date: Thu, 7 Dec 2017 17:41:00 -0800 Subject: [PATCH] HDFS-12874. Documentation for provided storage. Contributed by Virajith Jalaparti --- .../src/main/resources/hdfs-default.xml | 2 +- .../src/site/markdown/HdfsProvidedStorage.md | 247 ++++++++++++++++++ 2 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/HdfsProvidedStorage.md diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml b/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml index 3dc583c9e34..7b5ccbcd918 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/resources/hdfs-default.xml @@ -4643,7 +4643,7 @@ The class that is used to specify the input format of the blocks on provided storages. The default is - org.apache.hadoop.hdfs.server.common.TextFileRegionAliasMap which uses + org.apache.hadoop.hdfs.server.common.blockaliasmap.impl.TextFileRegionAliasMap which uses file regions to describe blocks. The file regions are specified as a delimited text file. Each file region is a 6-tuple containing the block id, remote file path, offset into file, length of block, the diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/HdfsProvidedStorage.md b/hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/HdfsProvidedStorage.md new file mode 100644 index 00000000000..7455044ed55 --- /dev/null +++ b/hadoop-hdfs-project/hadoop-hdfs/src/site/markdown/HdfsProvidedStorage.md @@ -0,0 +1,247 @@ + + +HDFS Provided Storage +===================== + +Provided storage allows data *stored outside HDFS* to be mapped to and addressed +from HDFS. It builds on [heterogeneous storage](./ArchivalStorage.html) by +introducing a new storage type, `PROVIDED`, to the set of media in a datanode. +Clients accessing data in +`PROVIDED` storages can cache replicas in local media, enforce HDFS invariants +(e.g., security, quotas), and address more data than the cluster could persist +in the storage attached to DataNodes. This architecture is particularly useful +in scenarios where HDFS clusters are ephemeral (e.g., cloud scenarios), and/or +require to read data that lives in other storage systems (e.g., blob stores). + +Provided storage is an experimental feature in HDFS. + + + +Introduction +------------ + +As of this writing, support for mounting external storage as `PROVIDED` blocks +is limited to creating a *read-only image* of a remote namespace that implements the +`org.apache.hadoop.fs.FileSystem` interface, and starting a NameNode +to serve the image. Specifically, reads from a snapshot of a remote namespace are +supported. Adding a remote namespace to an existing/running namenode, refreshing the +remote snapshot, unmounting, and writes are not available in this release. One +can use [ViewFs](./ViewFs.html) and [RBF](HDFSRouterFederation.html) to +integrate namespaces with `PROVIDED` storage into an existing deployment. + +Creating HDFS Clusters with `PROVIDED` Storage +---------------------------------------------- + +One can create snapshots of the remote namespace using the `fs2img` tool. Given +a path to a remote `FileSystem`, the tool creates an _image_ mirroring the +namespace and an _alias map_ that maps blockIDs in the generated image to a +`FileRegion` in the remote filesystem. A `FileRegion` contains sufficient information to +address a fixed sequence of bytes in the remote `FileSystem` (e.g., file, offset, length) +and a nonce to verify that the region is unchanged since the image was generated. + +After the NameNode image and alias map are created, the NameNode and DataNodes +must be configured to consistently reference this address space. When a DataNode +registers with an attached, `PROVIDED` storage, the NameNode considers all the +external blocks to be addressable through that DataNode, and may begin to direct +clients to it. Symmetrically, the DataNode must be able to map every block in +the `PROVIDED` storage to remote data. + +Deployment details vary depending on the configured alias map implementation. + +### `PROVIDED` Configuration + +Each NameNode supports one alias map. When `PROVIDED` storage is enabled, +the storage ID configured on the NameNode and DataNodes must match. +All other details are internal to the alias map implementation. + +The configuration to enable `PROVIDED` storage is as follows. +The configuration options available for the alias map implementations are +available below. + +```xml + + + + dfs.namenode.provided.enabled + true + Enabled provided storage on the Namenode + + + + dfs.datanode.data.dir + [DISK]/local/path/to/blocks/, [PROVIDED]remoteFS://remoteFS-authority/path/to/data/ + + + + dfs.provided.storage.id + DS-PROVIDED + The storage ID used for provided storages in the cluster. + + + + dfs.provided.aliasmap.class + org.apache.hadoop.hdfs.server.common.blockaliasmap.impl.TextFileRegionAliasMap + + + +``` + +### fs2img tool + +The `fs2img` tool "walks" over a remote namespace by recursively enumerating +children of a remote URI to produce an FSImage. Some attributes can be +controlled by plugins, such as owner/group mappings from the remote filesystem +to HDFS and the mapping of files to HDFS blocks. + +The various options available in running the tool are: + +| Option | Property | Default | Description | +|:------------------------|:--------------------------- |:----------------- |:---- | +| `-o`, `--outdir` | dfs.namenode.name.dir | file://${hadoop.tmp.dir}/dfs/name | Output directory | +| `-b`, `--blockclass` | dfs.provided.aliasmap.class | NullBlocksMap | Block output class | +| `-u`, `--ugiclass` | hdfs.image.writer.ugi.class | SingleUGIResolver | UGI resolver class | +| `-i`, `--blockidclass` | hdfs.image.writer.blockresolver.class | FixedBlockResolver | Block resolver class | +| `-c`, `--cachedirs` | hdfs.image.writer.cache.entries | 100 | Max active dirents | +| `-cid`, `--clusterID` | | | Cluster ID | +| `-bpid`, `--blockPoolID`| | | Block pool ID | + +#### Examples + +Assign all files to be owned by "rmarathe", write to gzip compressed text: +``` +hadoop org.apache.hadoop.hdfs.server.namenode.FileSystemImage \ + -Dhdfs.image.writer.ugi.single.user=rmarathe \ + -Ddfs.provided.aliasmap.text.codec=gzip \ + -Ddfs.provided.aliasmap.text.write.dir=file:///tmp/ + -b org.apache.hadoop.hdfs.server.common.blockaliasmap.impl.TextFileRegionAliasMap \ + -u org.apache.hadoop.hdfs.server.namenode.SingleUGIResolver \ + -o file:///tmp/name \ + hdfs://afreast/projects/ydau/onan +``` + +Assign ownership based on a custom `UGIResolver`, in LevelDB: +``` +hadoop org.apache.hadoop.hdfs.server.namenode.FileSystemImage \ + -Ddfs.provided.aliasmap.leveldb.path=file:///path/to/leveldb/map/dingos.db \ + -b org.apache.hadoop.hdfs.server.common.blockaliasmap.impl.LevelDBFileRegionAliasMap \ + -o file:///tmp/name \ + -u CustomResolver \ + hdfs://enfield/projects/ywqmd/incandenza +``` + + +Alias Map Implementations +------------------------- + +The alias map implementation to use is configured using the `dfs.provided.aliasmap.class` parameter. +Currently, the following two types of alias maps are supported. + +### InMemoryAliasMap + +This is a LevelDB-based alias map that runs as a separate server in Namenode. +The alias map itself can be created using the `fs2img` tool using the option +`-Ddfs.provided.aliasmap.leveldb.path=file:///path/to/leveldb/map/dingos.db -o org.apache.hadoop.hdfs.server.common.blockaliasmap.impl.LevelDBFileRegionAliasMap` +as in the example above. + +Datanodes contact this alias map using the `org.apache.hadoop.hdfs.server.aliasmap.InMemoryAliasMapProtocol` protocol. + +#### Configuration + + +```xml + + + dfs.provided.aliasmap.inmemory.batch-size + 500 + + The batch size when iterating over the database backing the aliasmap + + + + + dfs.provided.aliasmap.inmemory.dnrpc-address + namenode:rpc-port + + The address where the aliasmap server will be running + + + + + dfs.provided.aliasmap.inmemory.leveldb.dir + file:///path/to/leveldb/map/dingos.db + + The directory where the leveldb files will be kept + + + + + dfs.provided.aliasmap.inmemory.enabled + true + Enable the inmemory alias map on the NameNode. Defaults to false. + + + + dfs.provided.aliasmap.class + org.apache.hadoop.hdfs.server.common.blockaliasmap.impl.InMemoryLevelDBAliasMapClient + + +``` + +### TextFileRegionAliasMap + +This alias map implementation stores the mapping from `blockID`s to `FileRegion`s +in a delimited text file. This format is useful for test environments, +particularly single-node. + +#### Configuration +```xml + + + dfs.provided.aliasmap.text.delimiter + , + + The delimiter used when the alias map is specified as + a text file. + + + + + dfs.provided.aliasmap.text.read.file + file:///path/to/aliasmap/blocks_blocPoolID.csv + + The path specifying the alias map as a text file, + specified as a URI. + + + + + dfs.provided.aliasmap.text.codec + + + The codec used to de-compress the alias map. Default value is empty. + + + + + dfs.provided.aliasmap.text.write.dir + file:///path/to/aliasmap/ + + The path to which the alias map should be written as a text + file, specified as a URI. + + + +``` +