Hadoop has a number of built-in mechanisms that can facilitate ingress and egress operations, to name a few:
- Embedded NameNode HTTP server
- WebHDFS and Hadoop interfaces
- Hbase built-in API, be specifically the org.apache.hadoop.hbase.mapreduce.TableInputFormat and org.apache.hadoop.hbase.mapreduce.TableOutputFormat
- Hadoop fs utility
- Oozie workflow can also be leveraged to move data in/out of HDFS periodically
- Log collector such as Flume, scribe, Chukwa...
- Sqoop to import/export data from/to HDFS and relational databases
The first three are low-level utilities while the rest are high-level. These low-level mechanisms don't provide complete systems to manage the entire ingress and egress process while the hig-level ones do. For ingress here I mean move data into HDFS from external filesystem, database, hbase etc.; for egress, I mean move data from external system into Hadoop HDFS.
But in this blog post, what I most interested in is a third-party script which could be used to move data in/out of HDFS from external filesystem. It's called hdfs-file-splurper which is hosted on GitHub. It's distributed under Apache license, so you can get a copy of it source code via this link.
With HDFS file slurper open source project, you can copy files of any format in/out of HDFS, but with log collector such as Flume, Chukwa or Scribe, you can only copy text file format. The HDFS file slurper was developed by Alex Holmes, who is also the author of Hadoop in Practice. It's an awesome book by the way. Here is brief demonstration of this useful project.
-
Case 1, you want to move files in any format from external filesystem to HDFS, say, from the localhost directory /tmp/slurper/in to the HDFS directory /incoming/:
shell$ cat conf/examples/basic.conf DATASOURCE_NAME = test SRC_DIR = file:/tmp/slurper/in WORK_DIR = file:/tmp/slurper/work COMPLETE_DIR = file:/tmp/slurper/complete ERROR_DIR = file:/tmp/slurper/error DEST_STAGING_DIR = hdfs:/incoming/stage DEST_DIR = hdfs:/incoming
Run the Slurper in foreground mode in a console:shell$ bin/slurper.sh \ --config-file /path/to/slurper/conf/examples/basic.conf
In another console create an empty file and watch the Slurper do its stuff:shell$ echo "blocks of text" > /tmp/slurper/in/test.txt
-
Case 2, you want to move files of any format from HDFS to local filesystem.
shell$ cat conf/exmaples/basic.conf SRC_DIR=hdfs:/tmp/slurper/in WORK_DIR=hdfs:/tmp/slurper/work COMPLETE_DIR=hdfs:/tmp/slurper/complete ERROR_DIR=hdfs:/tmp/slurper/error DEST_STAGING_DIR=file:/tmp/slurper/stage DEST_DIR=file:/tmp/slurper/dest
Run Hadoop job to write output into the source directory, then see the Slurper do its job.
Important features of HDFS file slurper:
- After a successful file copy you can either remove the source file, or have it moved into another directory.
- Destination files can be compressed as part of the write codec with any compression codec which extends org.apache.hadoop.io.compress.CompressionCodec.
- Capability to write "done" file after completion of copy
- Verify destination file post-copy with CRC32 checksum comparison with source
- Ignores hidden files (filenames that start with ".")
- Customizable destination via a script which can be called for every source file. Or alternatively let the utility know a single destination directory
- Customizable pre-processing of file prior to transfer via script and all files are copied into that location.
- A daemon mode which is compatible with inittab respawn
- Multi-threaded data transfer
For more information of this project, please visit its homepage on GitHub and get a copy of its source code.
相关推荐
所以需要重新编译Container-executor,这边提供重新编译好的,默认加载配置文件路径/etc/hadoop/container-executor.cfg 使用方法: 1 替换/$HADOOP_HOME/bin/下的container-executor 2 创建/etc/hadoop目录,并将...
经过多次反复试验,完全可用的hadoop配置,有0.19的版本,也有0.20的版本。并且有脚本可以在两个版本之间...vi hadoop/conf/core-site.xml <name>hadoop.tmp.dir</name> <value>/data/hadoop_tmp</value> 祝好运!
Hadoop常见问题及解决办法汇总 Hadoop是一个基于Apache的开源大数据处理框架,广泛应用于大数据处理、数据分析和机器学习等领域。然而,在使用Hadoop时,经常会遇到一些常见的问题,这些问题可能会导致Hadoop集群...
hadoop/etc/hadoop/6个文件 core-site.xml hadoop-env.sh hdfs-site.xml mapred-site.xml yarn-env.sh yarn-site.xml
### Hadoop单机配置详解 在大数据处理领域,Apache Hadoop是一个开源软件框架,用于分布式存储和处理大型数据集。本文将详细介绍如何在单机环境下配置Hadoop,使其能够运行基本的大数据处理任务。 #### 一、配置...
<value>/data/hadoop/data,/data/hadoop/data01,/data/hadoop/data02</value> </property> <name>dfs.permissions</name> <value>false</value> </property> <name>dfs.support.append</name> <value>...
1.安装 Hadoop-gpl-compression ...1.2 mv hadoop-gpl-...bin/hadoop jar /usr/local/hadoop-1.0.2/lib/hadoop-lzo-0.4.15.jar com.hadoop.compression.lzo.LzoIndexer /home/hadoop/project_hadoop/aa.html.lzo
hadoop安装与配置 hadoop安装与配置 Hadoop的安装与配置可以分成几个主要步骤: 1. 安装Java 2. 下载Hadoop 3. 配置Hadoop ...编辑/usr/local/hadoop/etc/hadoop/hadoop-env.sh,设置JAVA_HOME: export JAVA_H
在Hadoop生态系统中,`FileSystem API`是核心组件之一,它提供了一套接口,使得开发者可以方便地进行文件系统的操作,如读取、写入、移动和删除文件。本篇文章将详细讲解如何利用`FileSystem API`执行Hadoop文件的...
<value>file:/home/hadoop/hadoop-2.7.7/tmp/dfs/data</value> </property> </configuration> ``` 启动HDFS After configuring the above files, format the HDFS file system using the following command: ``` ...
<value>file:/root/soft/hadoop/tmp/dfs/data</value> </property> ``` 4. **配置MapReduce与YARN**: - **创建mapred-site.xml**:如果不存在mapred-site.xml文件,则需要创建它。 - 使用命令`mv /root/soft/...
export HADOOP_HOME="/usr/local/hadoop/" export JAVA_HOME="/usr/local/hadoop/jdk1.6.0_24" export CLASSPATH="$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:${HADOOP_HOME}/lib/commons-logging-1.0.4.jar...
下载hadoop2.6.0的源码辛苦编译成的,网上没找到编译好现成的,费了几个小时用maven编译好的带源码的jar包,中间还得安装编译protoc,可以直接供eclipse使用。
用java的MapReduce写了个demo,用于计算文档单词出现个数
编辑`/opt/hadoop/etc/hadoop/hadoop-env.sh`文件,设置`HADOOP_HOME`和`JAVA_HOME`: ```bash export HADOOP_HOME=/opt/hadoop export JAVA_HOME=/usr/java/jdk1.8.0_281 ``` 然后,配置Hadoop的分布式文件系统...
mkdir /usr/hadoop/hadoop-2.7.3/hdfs/data mkdir /usr/hadoop/hadoop-2.7.3/hdfs/name mkdir /usr/hadoop/hadoop-2.7.3/hdfs/tmp ``` 5. **配置Hadoop** 配置Hadoop的主要文件包括`core-site.xml`,`hadoop-...
cp /opt/hadoopgpl/lib/hadoop-lzo-0.4.20-SNAPSHOT.jar $HADOOP_HOME/share/hadoop/common/ cp /opt/hadoopgpl/lib/hadoop-lzo-0.4.20-SNAPSHOT.jar $HBASE_HOME/lib/ 2.2.6. 拷贝本地库so文件到hadoop tar -cBf - ...