Moving Large Amounts of Data from HDFS (Data Center) to Amazon S3 using S3DistCp

Sharing is caring!

<div dir&equals;"ltr" style&equals;"text-align&colon; left&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; left&semi;">A number of approaches are available for moving large amounts of data from your current storage to Amazon Simple Storage Service &lpar;Amazon S3&rpar; or from Amazon S3 to Amazon EMR and the Hadoop Distributed File System &lpar;HDFS&rpar;&period; When doing so&comma; however&comma; it is critical to use the available data bandwidth strategically&period; With the proper optimizations&comma; uploads of several terabytes a day may be possible&period; To achieve such high throughput&comma; you can upload data into AWS in parallel from multiple clients&comma; each using multithreading to provide concurrent uploads or employing multipart uploads for further parallelization&period;<&sol;p>&NewLine;<div style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><a href&equals;"http&colon;&sol;&sol;www&period;thecloudxperts&period;co&period;uk&sol;wp-content&sol;uploads&sol;2017&sol;05&sol;HBase&lowbar;AmazonS3&lowbar;1&period;gif" style&equals;"margin-left&colon; 1em&semi; margin-right&colon; 1em&semi;"><img border&equals;"0" data-original-height&equals;"564" data-original-width&equals;"800" height&equals;"225" src&equals;"http&colon;&sol;&sol;www&period;thecloudxperts&period;co&period;uk&sol;wp-content&sol;uploads&sol;2017&sol;05&sol;HBase&lowbar;AmazonS3&lowbar;1-300x212&period;gif" width&equals;"320" &sol;><&sol;a><&sol;div>&NewLine;<p>Two Important tools to move data—S3DistCp and DistCp—can help you move data stored on your local &lpar;data center&rpar; HDFS storage to Amazon S3&period;<&sol;p>&NewLine;<p><b>Using S3DistCp<&sol;b><br &sol;>S3DistCp is an extension of DistCp with optimizations to work with AWS&comma; particularly Amazon S3&period; By adding S3DistCp as a step in a job flow&comma; you can efficiently copy large amounts of data from Amazon S3 into HDFS where subsequent steps in your EMR clusters can process it&period; You can also use S3DistCp to copy data between Amazon S3 buckets or from HDFS to Amazon S3&period;<br &sol;>S3DistCp copies data using distributed map–reduce jobs&comma; which is similar to DistCp&period; S3DistCp runs mappers to compile a list of files to copy to the destination&period; Once mappers finish compiling a list of files&comma; the reducers perform the actual data copy&period; The main optimization that S3DistCp provides over DistCp is by having a reducer run multiple HTTP upload threads to upload the files in parallel&period;<&sol;p>&NewLine;<p><b>To copy data from your Hadoop cluster to Amazon S3 using S3DistCp<&sol;b><br &sol;>The following is an example of how to run S3DistCp on your own Hadoop installation to copy data from HDFS to Amazon S3&period;<br &sol;>Tested on Version<br &sol;>Apache Hadoop 1&period;0&period;3 distribution and Amazon EMR AMI 2&period;4&period;1&period;<&sol;p>&NewLine;<p><b>Using S3DistCp<&sol;b><br &sol;>1&period; Launch a small Amazon EMR cluster &lpar;a single node&rpar;&period;<br &sol;>elastic-mapreduce &&num;8211&semi;create &&num;8211&semi;alive &&num;8211&semi;instance-count 1 &&num;8211&semi;instance-type m1&period;small &&num;8211&semi;ami-version 2&period;4&period;1<&sol;p>&NewLine;<p>2&period; Copy the following jars from Amazon EMR’s master node &lpar;&sol;home&sol;Hadoop&sol;lib&rpar; to your local Hadoop master node under the &sol;lib directory of your Hadoop installation path &lpar;For example&colon; &sol;usr&sol;local&sol;hadoop&sol;lib&rpar;&period; Depending on your Hadoop installation&comma; you may or may not have these jars&period; The Apache Hadoop distribution does not contain these jars&period;<br &sol;>&sol;home&sol;hadoop&sol;lib&sol;emr-s3distcp-1&period;0&period;jar<br &sol;>&sol;home&sol;hadoop&sol;lib&sol;aws-java-sdk-1&period;3&period;26&period;jar<br &sol;>&sol;home&sol;hadoop&sol;lib&sol;guava-13&period;0&period;1&period;jar<br &sol;>&sol;home&sol;hadoop&sol;lib&sol;gson-2&period;1&period;jar<br &sol;>&sol;home&sol;hadoop&sol;lib&sol;EmrMetrics-1&period;0&period;jar<br &sol;>&sol;home&sol;hadoop&sol;lib&sol;protobuf-java-2&period;4&period;1&period;jar<br &sol;>&sol;home&sol;hadoop&sol;lib&sol;httpcore-4&period;1&period;jar<br &sol;>&sol;home&sol;hadoop&sol;lib&sol;httpclient-4&period;1&period;1&period;jar<&sol;p>&NewLine;<p>3&period; Edit the core-site&period;xml file to insert your AWS credentials&period; Then copy the core-site&period;xml config file to all of your Hadoop cluster nodes&period; After copying the file&comma; it is unnecessary to restart any services or daemons for the change to take effect&period;<property><&sol;property><name>fs&period;s3&period;awsSecretAccessKey<&sol;name><br &sol;><value>YOUR&lowbar;SECRETACCESSKEY<&sol;value><&sol;div>&NewLine;<property><&sol;property><name>fs&period;s3&period;awsAccessKeyId<&sol;name><br &sol;><value>YOUR&lowbar;ACCESSKEY<&sol;value><&sol;p>&NewLine;<property><&sol;property><name>fs&period;s3n&period;awsSecretAccessKey<&sol;name><br &sol;><value>YOUR&lowbar;SECRETACCESSKEY<&sol;value><&sol;p>&NewLine;<property><&sol;property><name>fs&period;s3n&period;awsAccessKeyId<&sol;name><br &sol;><value>YOUR&lowbar;ACCESSKEY<&sol;value><&sol;p>&NewLine;<p>4&period; Run s3distcp using the following example &lpar;modify HDFS&lowbar;PATH&comma; YOUR&lowbar;S3&lowbar;BUCKET and PATH&rpar;&colon; hadoop jar &sol;usr&sol;local&sol;hadoop&sol;lib&sol;emr-s3distcp-1&period;0&period;jar -libjars &sol;usr&sol;local&sol;hadoop&sol;lib&sol;gson-2&period;1&period;jar&comma;&sol;usr&sol;local&sol;hadoop&sol;lib&sol;guava-13&period;0&period;1&period;jar&comma;&sol;usr&sol;local&sol;hadoop&sol;lib&sol;aws-java-sdk-1&period;3&period;26&period;jar&comma;&sol;usr&sol;local&sol;hadoop&sol;lib&sol;emr-&nbsp&semi;s3distcp-1&period;0&period;jar&comma;&sol;usr&sol;local&sol;hadoop&sol;lib&sol;EmrMetrics-1&period;0&period;jar&comma;&sol;usr&sol;local&sol;hadoop&sol;lib&sol;protobuf-java-2&period;4&period;1&period;jar&comma;&sol;usr&sol;local&sol;hadoop&sol;lib&sol;httpcore-4&period;1&period;jar&comma;&sol;usr&sol;local&sol;hadoop&sol;lib&sol;httpclient-4&period;1&period;1&period;jar &&num;8211&semi;src HDFS&lowbar;PATH &&num;8211&semi;dest s3&colon;&sol;&sol;YOUR&lowbar;S3&lowbar;BUCKET&sol;PATH&sol; &&num;8211&semi;disableMultipartUpload<&sol;p>&NewLine;<p><b>Using DistCp<&sol;b><br &sol;>DistCp &lpar;distributed copy&rpar; is a tool used for large inter- or intra-cluster copying of data&period; It uses Amazon EMR to effect its distribution&comma; error handling&comma; and recovery&comma; as well as reporting&period; It expands a list of files and directories into input to map tasks&comma; each of which will copy a partition of the files specified in the source list&period;<&sol;p>&NewLine;<p>DistCp can copy data from HDFS to Amazon S3 in a distributed manner similar to S3DistCp&semi; however&comma; DistCp is not as fast&period; DistCp uses the following algorithm to compute the number of mappers required&colon;<br &sol;>min &lpar;total&lowbar;bytes &sol; bytes&period;per&period;map&comma; 20 &ast; num&lowbar;task&lowbar;trackers&rpar;<&sol;p>&NewLine;<p>If you are using DistCp and notice that the number of mappers used to copy your data is less than your cluster’s total mapper capacity&comma; you may want to increase the number of mappers that DistCp uses to copy files by specifying the -m number&lowbar;of&lowbar;mappers option&period;<&sol;p>&NewLine;<p>The following is an example of DistCp command copying &sol;data directory on HDFS to a given Amazon S3 bucket&colon;<br &sol;>hadoop distcp hdfs&colon;&sol;&sol;&sol;data&sol; s3n&colon;&sol;&sol;awsaccesskey&colon;awssecrectkey&commat;somebucket&sol;mydata&sol;<&sol;p>&NewLine;<p><&sol;div>&NewLine;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.