<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1014087953899153880</id><updated>2026-07-25T11:15:28.404-07:00</updated><category term="search engine for apache documentation of hadoop"/><title type='text'>Hadoop Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>83</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-7884048386740402507</id><published>2016-01-17T09:46:00.002-08:00</published><updated>2016-01-17T09:48:48.517-08:00</updated><title type='text'>How to speed up count distinct queries in Hive</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Have you ever wondered why a count distinct query on a high cardinality column in Hive is slow. &lt;br /&gt;
&lt;br /&gt;
Lets say we have a table that contains list of all products&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Table:&lt;/b&gt; Products&lt;br /&gt;
&lt;b&gt;Columns:&lt;/b&gt;&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;product_id (this column and product_id together are unique)&lt;/li&gt;
&lt;li&gt;product_name&lt;/li&gt;
&lt;li&gt;price&lt;/li&gt;
&lt;li&gt;&amp;nbsp;available_in_country (this column and product_id together are unique)&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
Let&#39;s say this table contains 1 billion rows and around 200 million unique product_id&#39;s.&lt;br /&gt;
&lt;br /&gt;
You need to find distinct number of products in the table.&lt;br /&gt;
Most people will write query like&lt;br /&gt;
&lt;i&gt;select count(distinct product_id) from products&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
This query will start a map reduce job with just 1 reducer and the reducer will take a long time to finish. This is because all 1 billion rows will go to just one reducer and the reducer will have go through 1 billion rows and maintain distinct id&#39;s in memory.&lt;br /&gt;
&lt;br /&gt;
Instead you should write query like&lt;br /&gt;
&lt;i&gt;select count(*) from (select distinct product_id from products)T&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
This query will very run very fast because the sub query will use multiple reducers. The outer query will then just have to count the number of row and that is normally done in map with reducer just summing up the values of the map and hence it will be really fast.&amp;nbsp;&lt;i&gt; &lt;/i&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/7884048386740402507/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2016/01/how-to-speed-up-count-distinct-queries.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/7884048386740402507'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/7884048386740402507'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2016/01/how-to-speed-up-count-distinct-queries.html' title='How to speed up count distinct queries in Hive'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-6269338557442518257</id><published>2016-01-14T16:29:00.002-08:00</published><updated>2016-01-14T16:29:21.910-08:00</updated><title type='text'>How to do UNION ALL in hive</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Suppose you have two table&amp;nbsp;&lt;div&gt;
&lt;b&gt;Boys&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
- Name&lt;/div&gt;
&lt;div&gt;
- Age&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Girls&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
- Name&lt;/div&gt;
&lt;div&gt;
- Age&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now lets say we want to a query that returns all &lt;i&gt;Boys&lt;/i&gt; and &lt;i&gt;Girls&lt;/i&gt;. Most of us who come from Oracle/SqlServer/MySql etc world will write following query&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;select name, age from Boys&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;union all&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;i&gt;select name, age from Girls&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This query will throw an error in Hive and it will look like UNION ALL does not works in Hive. UNION ALL does works in Hive, the only trick is to enclose the UNION ALL tables in a subquery, i.e. write the above as&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;i&gt;select name, age from (&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;select name, age from Boys&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;union all&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;select name, age from Girls&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;) BoysAndGirls&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/6269338557442518257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2016/01/how-to-do-union-all-in-hive.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/6269338557442518257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/6269338557442518257'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2016/01/how-to-do-union-all-in-hive.html' title='How to do UNION ALL in hive'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-4398194905042201914</id><published>2012-04-24T22:43:00.003-07:00</published><updated>2012-04-25T15:14:56.893-07:00</updated><title type='text'>Hadoop Example: Using a custom Java class as Key and Group Comparator</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;color: #cc0000;&quot;&gt;
&lt;b&gt;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;br /&gt;: FILE: MyKey.java : CUSTOM KEY CLASS&lt;br /&gt;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;i&gt;package com.amandoon.HadoopExample;&lt;br /&gt;import org.apache.hadoop.io.WritableComparable;&lt;br /&gt;import org.apache.hadoop.io.WritableComparator;&lt;br /&gt;import java.io.DataInput;&lt;br /&gt;import java.io.DataOutput;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;&lt;br /&gt;public class MyKey implements WritableComparable&amp;lt;MyKey&amp;gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; String timestamp = null;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; String vrid = null;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public MyKey() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void set(String timestamp, String vrid) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.timestamp = timestamp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.vrid = vrid;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ///////////////////////////////////////////// Implement Writable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void write(DataOutput daout) throws IOException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; daout.writeUTF(vrid);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; daout.writeUTF(timestamp);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ///////////////////////////////////////////// Implement Writable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void readFields(DataInput dain) throws IOException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; vrid = dain.readUTF();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; timestamp = dain.readUTF();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //////////////////////////////////////////// Implement Comparable&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int compareTo(MyKey ob) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int cmp = this.vrid.compareTo(ob.vrid);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (cmp != 0) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return cmp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return this.timestamp.compareTo(ob.timestamp);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public boolean equals(Object ob) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (ob == null || this.getClass() != ob.getClass()) return false;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyKey k = (MyKey) ob;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (k.timestamp != null &amp;amp;&amp;amp; this.timestamp != null &amp;amp;&amp;amp; !k.timestamp.equals(this.timestamp)) return false;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (k.vrid != null &amp;amp;&amp;amp; this.vrid != null &amp;amp;&amp;amp; !k.vrid.equals(this.vrid)) return false;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int hashCode() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int result = vrid != null ? vrid.hashCode() : 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 31 * result;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public String toString() {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return vrid + &quot;\u0002&quot; + timestamp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/i&gt;&lt;br /&gt;
&lt;div style=&quot;color: #cc0000;&quot;&gt;
&lt;b&gt;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;br /&gt;: FILE: MyGroupComparator.java : CUSTOM KEY CLASS GROUP COMPARATOR&lt;br /&gt;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;/b&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;i&gt;package com.amandoon.HadoopExample;&lt;br /&gt;import org.apache.hadoop.io.WritableComparable;&lt;br /&gt;import org.apache.hadoop.io.WritableComparator;&lt;br /&gt;&lt;br /&gt;class MyGroupComparator extends WritableComparator {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected MyGroupComparator(){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; super(MyKey.class,true);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int compare(WritableComparable w1, WritableComparable w2){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyKey k1 = (MyKey) w1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyKey k2 = (MyKey) w2;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return k1.vrid.compareTo(k2.vrid);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #cc0000;&quot;&gt;
&lt;b&gt;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;br /&gt;: FILE: MyMapper.java : MAPPER CLASS&lt;br /&gt;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;/b&gt;&lt;/div&gt;
&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;i&gt;package com.amandoon.HadoopExample;&lt;br /&gt;import org.apache.hadoop.io.LongWritable;&lt;br /&gt;import org.apache.hadoop.io.Text;&lt;br /&gt;import org.apache.hadoop.mapreduce.Mapper;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;&lt;br /&gt;public class MyMapper extends Mapper&amp;lt;LongWritable, Text, MyKey, Text&amp;gt; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private MyKey ok = new MyKey();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private Text ov = new Text();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void map(LongWritable key, Text value, Context context)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throws IOException, InterruptedException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String[] valarr = value.toString().split(&quot;\u0002&quot;, -1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (valarr.length &amp;gt; 3) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ok.set(valarr[0], valarr[1]);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; context.write(ok, new Text(valarr[2]));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; context.getCounter(&quot;AMAN&#39;S COUNTERS&quot;,&quot;!!! Bad Array !!!&quot;).increment(1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/i&gt;&lt;br /&gt;
&lt;div style=&quot;color: #cc0000;&quot;&gt;
&lt;b&gt;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;br /&gt;: FILE: MyReducer.java : REDUCER CLASS&lt;br /&gt;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;/b&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;i&gt;package com.amandoon.HadoopExample;&lt;br /&gt;import org.apache.hadoop.io.Text;&lt;br /&gt;import org.apache.hadoop.mapreduce.Reducer;&lt;br /&gt;import java.io.IOException;&lt;br /&gt;&lt;br /&gt;public class MyReducer extends Reducer&amp;lt;MyKey, Text, MyKey, Text&amp;gt; {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private MyKey ok = new MyKey();&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void reduce(MyKey key, Iterable&amp;lt;Text&amp;gt; values, Context context)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; throws IOException, InterruptedException {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (Text value : values) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; context.write(key, value);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #cc0000;&quot;&gt;
&lt;b&gt;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;br /&gt;: FILE: MyMr.java : RUN JOB&lt;br /&gt;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::&lt;/b&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;/div&gt;
&lt;i&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;package com.amandoon.HadoopExample;&lt;/span&gt;&lt;br /&gt;import org.apache.hadoop.conf.Configuration;&lt;br /&gt;import org.apache.hadoop.conf.Configured;&lt;br /&gt;import org.apache.hadoop.mapreduce.Job;&lt;br /&gt;import org.apache.hadoop.util.Tool;&lt;br /&gt;import org.apache.hadoop.util.ToolRunner;&lt;br /&gt;import org.kohsuke.args4j.CmdLineParser; import org.kohsuke.args4j.Option;&lt;br /&gt;&lt;br /&gt;public class MyMr extends Configured implements Tool {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Option(name = &quot;--input&quot;, required = true)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; String inputdir;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Option(name = &quot;--output&quot;, required = true)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; String outputdir;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Option(name = &quot;--reducers&quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int reducers;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int run(String[] arg) throws Exception {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Configuration conf = super.getConf();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.set(&quot;mapred.input.dir&quot;, inputdir);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.set(&quot;mapred.output.dir&quot;, outputdir);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.setBoolean(&quot;mapred.mapper.new-api&quot;, true);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.setBoolean(&quot;mapred.reducer.new-api&quot;, true);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.set(&quot;mapreduce.map.class&quot;, &quot;com.amandoon.HadoopExample.MyMapper&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.set(&quot;mapreduce.reduce.class&quot;, &quot;com.amandoon.HadoopExample.MyReducer&quot;);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.set(&quot;mapreduce.inputformat.class&quot;, &quot;org.apache.hadoop.mapreduce.lib.input.TextInputFormat&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.set(&quot;mapreduce.outputformat.class&quot;, &quot;org.apache.hadoop.mapreduce.lib.output.TextOutputFormat&quot;);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.setInt(&quot;mapred.reduce.tasks&quot;, reducers);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.setBoolean(&quot;mapred.map.tasks.speculative.execution&quot;, false);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.setBoolean(&quot;mapred.reduce.tasks.speculative.execution&quot;, false);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.set(&quot;mapred.output.key.class&quot;, &quot;com.amandoon.HadoopExample.MyKey&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.set(&quot;mapred.output.value.class&quot;, &quot;org.apache.hadoop.io.Text&quot;);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.set(&quot;mapred.job.name&quot;, &quot;CustomKey&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conf.set(&quot;mapred.output.value.groupfn.class&quot;, &quot;com.amandoon.HadoopExample.MyGroupComparator&quot;);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Job job = new Job(conf);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; job.setJarByClass(com.amandoon.HadoopExample.MyMr.class);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; job.waitForCompletion(true);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args) throws Exception {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyMr fc = new MyMr();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new CmdLineParser(fc).parseArgument(args);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ToolRunner.run(fc, args);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/i&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/4398194905042201914/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2012/04/hadoop-example-using-custom-java-class.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/4398194905042201914'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/4398194905042201914'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2012/04/hadoop-example-using-custom-java-class.html' title='Hadoop Example: Using a custom Java class as Key and Group Comparator'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-853927299258888205</id><published>2012-04-24T22:43:00.001-07:00</published><updated>2012-04-24T22:45:58.996-07:00</updated><title type='text'>Which hadoop property needs to be set to change the key GroupComparator</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you have a custom key GroupComparator defined for your MR job then you can set it in your hadoop config file as &lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;&amp;lt;property&amp;gt;&lt;br /&gt;&amp;lt;name&amp;gt;mapred.output.value.groupfn.class&amp;lt;/name&amp;gt;&lt;br /&gt;&amp;lt;value&amp;gt;com.amandoon.CustomKey.MyGroupComparator&amp;lt;/value&amp;gt;&lt;br /&gt;&amp;lt;/property&amp;gt; &lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
OR you can set it for a job using the Job object&lt;br /&gt;
&lt;em&gt;jobObject.setGroupingComparatorClass(MyGroupComparator.class)&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
See hadoop example that uses Custom Key GroupComparator&lt;br /&gt;
&lt;a href=&quot;http://hadoop-blog.blogspot.com/2012/04/hadoop-example-using-custom-java-class.html&quot;&gt;http://hadoop-blog.blogspot.com/2012/04/hadoop-example-using-custom-java-class.html&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/853927299258888205/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2012/04/which-hadoop-property-needs-to-be-set.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/853927299258888205'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/853927299258888205'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2012/04/which-hadoop-property-needs-to-be-set.html' title='Which hadoop property needs to be set to change the key GroupComparator'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-1839795134794257474</id><published>2012-04-24T22:34:00.003-07:00</published><updated>2012-04-24T22:34:40.920-07:00</updated><title type='text'>Tips &amp; techniques to write data intensive text processing task in Hadoop</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Stumbled upon a good book by Jimmy Lin and Chris Dyer (University of Maryland, College Park). The book discusses various techniques used to write data intensive alogorithms using Hadoop Map Reduce. &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://docs.google.com/viewer?a=v&amp;amp;pid=sites&amp;amp;srcid=ZGVmYXVsdGRvbWFpbnxoYWRvb3BhbmRoaXZlfGd4OjZjNmEzMzlhMzlhNjdkMWQ&amp;amp;pli=1&quot;&gt;https://docs.google.com/viewer?a=v&amp;amp;pid=sites&amp;amp;srcid=ZGVmYXVsdGRvbWFpbnxoYWRvb3BhbmRoaXZlfGd4OjZjNmEzMzlhMzlhNjdkMWQ&amp;amp;pli=1&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Got a fairly good starting point on how to approach graph algorithms using Map Reduce. &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/1839795134794257474/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2012/04/tips-techniques-to-write-data-intensive.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/1839795134794257474'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/1839795134794257474'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2012/04/tips-techniques-to-write-data-intensive.html' title='Tips &amp; techniques to write data intensive text processing task in Hadoop'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-386042509709065277</id><published>2012-01-25T23:35:00.000-08:00</published><updated>2012-04-24T22:26:47.374-07:00</updated><title type='text'>How to compress the interim output of Mappers and final output of a Map Reduce Jon in Hadoop</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I was testing different ways to improve performance of hadoop jobs and was testing how compression helps. &lt;br /&gt;
&lt;br /&gt;
There are 2 places where you can configure a hadoop job to use compression &lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1. Compress the intermediate output of the mapper&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
To do this &lt;strong&gt;for all&amp;nbsp;jobs&lt;/strong&gt; you can set it in&amp;nbsp;&lt;strong&gt;mapred-site.xml &lt;/strong&gt;by adding the following properties&lt;br /&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;xml keyword&quot;&gt;property&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;xml spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;xml keyword&quot;&gt;name&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt; mapreduce.map.output.compress &amp;lt;/&lt;/code&gt;&lt;code class=&quot;xml keyword&quot;&gt;name&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt;&amp;nbsp; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;xml spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;xml keyword&quot;&gt;value&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt;true&amp;lt;/&lt;/code&gt;&lt;code class=&quot;xml keyword&quot;&gt;value&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt;&amp;nbsp; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;/&lt;/code&gt;&lt;code class=&quot;xml keyword&quot;&gt;property&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;xml keyword&quot;&gt;property&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;xml spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;xml keyword&quot;&gt;name&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt;mapreduce.map.output.compress.codec&amp;lt;/&lt;/code&gt;&lt;code class=&quot;xml keyword&quot;&gt;name&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;xml spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;xml keyword&quot;&gt;value&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt;org.apache.hadoop.io.compress.GzipCodec&amp;lt;/&lt;/code&gt;&lt;code class=&quot;xml keyword&quot;&gt;value&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt; &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
&lt;code class=&quot;xml plain&quot;&gt;&amp;lt;/&lt;/code&gt;&lt;code class=&quot;xml keyword&quot;&gt;property&lt;/code&gt;&lt;code class=&quot;xml plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;br /&gt;
I am compressing using GzipCodec but you have the option to use any of the following &lt;br /&gt;
- GzipCodec&lt;br /&gt;
- DeflateCodec&lt;br /&gt;
- BZip2Codec&lt;br /&gt;
- SnappyCodec&lt;br /&gt;
Each of these have their strengths and weaknesses, choose what you can live with. Also not that due to some licensing differences, LZO does not ships with Hadoop. You can install it separately and use it if you&#39;d like. &lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;For just your job&lt;/strong&gt; you can set it in the Configuration object&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;, Courier, monospace; font-size: x-small;&quot;&gt;Configuration conf = new Configuration();&lt;br /&gt;conf.setBoolean(&quot;mapreduce.map.output.compress&quot;, true);&lt;br /&gt;conf.set(&quot;mapreduce.map.output.compress.codec&quot;,&quot;org.apache.hadoop.io.compress.GzipCodec&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;span style=&quot;color: #990000;&quot;&gt;2. Compress the final output of the job &lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
To save the final output in gzip, run your M/R job with following code &lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;java plain&quot;&gt;job.setOutputFormatClass(TextOutputFormat.&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;class&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;java plain&quot;&gt;TextOutputFormat.setCompressOutput(job, &lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;true&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;); &lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;java plain&quot;&gt;TextOutputFormat.setOutputCompressorClass(job, GzipCodec.&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;class&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;); &lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/386042509709065277/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2012/01/how-to-compress-interim-output-of.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/386042509709065277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/386042509709065277'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2012/01/how-to-compress-interim-output-of.html' title='How to compress the interim output of Mappers and final output of a Map Reduce Jon in Hadoop'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-2161857833202199234</id><published>2011-12-09T14:39:00.001-08:00</published><updated>2011-12-09T14:44:39.063-08:00</updated><title type='text'>Hadoop Cluster size deployed by CBS Interactive</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Following are some details of the Hadoop Production Infrastructure deployed at CBS Interactive as of now&lt;br /&gt;
- Total Nodes: 80&lt;br /&gt;
- Total Disk Capacity: 1 PB&lt;br /&gt;
- ETL apps were written using Hadoop Streaming (Phython)&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/2161857833202199234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2011/12/hadoop-cluster-size-deployed-by-cbs.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/2161857833202199234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/2161857833202199234'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2011/12/hadoop-cluster-size-deployed-by-cbs.html' title='Hadoop Cluster size deployed by CBS Interactive'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-2294138059153747328</id><published>2011-03-18T11:07:00.000-07:00</published><updated>2011-03-18T11:07:43.195-07:00</updated><title type='text'>How, in hive, to create a column name that is same as a reserved keyword used by Hive</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;If you run the follwoing command in hive, it will fail because &lt;strong&gt;sort&lt;/strong&gt; is a reserved keyword in hive&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;CREATE EXTERNAL TABLE aaaabc ( sort STRING&amp;nbsp; ) &lt;/em&gt;&lt;br /&gt;
&lt;em&gt;ROW FORMAT DELIMITED &lt;/em&gt;&lt;br /&gt;
&lt;em&gt;FIELDS TERMINATED BY &#39;\002&#39; &lt;/em&gt;&lt;br /&gt;
&lt;em&gt;LINES TERMINATED BY &#39;\n&#39;;&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;FAILED: Parse Error: line 1:31 mismatched input &#39;sort&#39; expecting Identifier in column specification&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;To ovecome this, run the command by putting &lt;strong&gt;sort &lt;/strong&gt;in backticks, i.e. &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;&lt;em&gt;&lt;span style=&quot;color: black;&quot;&gt;CREATE EXTERNAL TABLE aaaabc ( `sort` STRING&amp;nbsp; ) &lt;/span&gt;&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;&lt;span style=&quot;color: black;&quot;&gt;ROW FORMAT DELIMITED &lt;/span&gt;&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;&lt;span style=&quot;color: black;&quot;&gt;FIELDS TERMINATED BY &#39;\002&#39; &lt;/span&gt;&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;&lt;span style=&quot;color: black;&quot;&gt;LINES TERMINATED BY &#39;\n&#39;;&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/2294138059153747328/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2011/03/how-in-hive-to-create-column-name-that.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/2294138059153747328'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/2294138059153747328'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2011/03/how-in-hive-to-create-column-name-that.html' title='How, in hive, to create a column name that is same as a reserved keyword used by Hive'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-2082572754750264421</id><published>2011-01-26T12:05:00.000-08:00</published><updated>2011-01-26T12:07:26.262-08:00</updated><title type='text'>Hive Error: FAILED: Parse Error: line 54:4 mismatched input  expecting Identifier in column specification</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;strong&gt;PROBLEM&lt;/strong&gt;&lt;br /&gt;
I was trying to create an external table in hive using the following command &lt;br /&gt;
&lt;em&gt;CREATE EXTERNAL TABLE tetl_fact_r&lt;br /&gt;
(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;custid STRING,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;value STRING,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ph STRING,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; email STRING,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; sort STRING,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;address STRING,&lt;br /&gt;
) &lt;br /&gt;
ROW FORMAT DELIMITED &lt;br /&gt;
FIELDS TERMINATED BY &#39;\002&#39; &lt;br /&gt;
LINES TERMINATED BY &#39;\n&#39; &lt;/em&gt;&lt;br /&gt;
&lt;em&gt;STORED AS TEXTFILE&lt;br /&gt;
&amp;nbsp;LOCATION &#39;/user/hadoop-blog/abc.text&#39;;&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
and got the following error &lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: red;&quot;&gt;FAILED: Parse Error: line &amp;lt;linenum&amp;gt;:4 mismatched input&amp;nbsp;&lt;em&gt;&amp;lt;column name&amp;gt;&lt;/em&gt; expecting Identifier in column specification&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;strong&gt;REASON&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
From &lt;a href=&quot;https://issues.cloudera.org/browse/SQOOP-37&quot;&gt;https://issues.cloudera.org/browse/SQOOP-37&lt;/a&gt;, I found that this is happening because column name &lt;strong&gt;&lt;em&gt;sort&lt;/em&gt;&lt;/strong&gt; is a reserved keyword in hive. &lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;SOLUTION&lt;/strong&gt;&lt;br /&gt;
To be honest, I din&#39;t spend much time finding the solution, instead I just renamed my field and it worked after that. Hence the new query looked like &lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;em&gt;CREATE EXTERNAL TABLE tetl_fact_r&lt;br /&gt;
(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;custid STRING,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;value STRING,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ph STRING,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; email STRING,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; sorttype STRING,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;address STRING,&lt;br /&gt;
) &lt;/em&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
If any of you figure out a way to make this query work without renaming the column then please leave a comment. It will be much appreciated. &lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/2082572754750264421/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2011/01/hive-error-failed-parse-error-line-544.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/2082572754750264421'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/2082572754750264421'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2011/01/hive-error-failed-parse-error-line-544.html' title='Hive Error: FAILED: Parse Error: line 54:4 mismatched input &lt;column name&gt; expecting Identifier in column specification'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-1828745558328880931</id><published>2010-12-25T18:43:00.000-08:00</published><updated>2010-12-25T18:45:05.230-08:00</updated><title type='text'>How to dynamically assign reducers to a Hadoop Job in runtime</title><content type='html'>&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;When we were working on setting our production jobs we came to&amp;nbsp;a point where we needed a way to dynamically assign reducers to a Hadoop Job in runtime. Following is what we have implemented as of today.&amp;nbsp; If you are reading the blog and have a better idea to share then please leave a comment. &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;strong&gt;PROBLEM STATEMENT&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;We have a lot of cases where same produciton job&amp;nbsp;works on different sizes of data sets, i.e. for an hour the job can process from 35GB to 400Gb data. We wanted to change the number of reducers depending on the data sets, in runtime, and also we did not want a job to hog all reducers because the grid was shared between jobs from different teams. All jobs were equally important. &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;strong&gt;SOLUTION&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This is something that hadoop MR framework cannot do for you. We found that hive came up with a solution by providing a property that limits the maximum number of bytes that will be processed by one reducer hence if this property is set to 1GB and data size is 1.2 GB data then 2 reducers will be assigned to the job in runtime; if data size 10 GB data then 10 reducers will be assigned to the job in runtime. &lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;This works great for hive because it is designed to work agnostic of the dataset. Also a big job in hive can still take all the reducers in the grid. Since we knew our data very well and also did not want a single job to take all reducers hence we decided to implement our own solution that solved our problem. &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The solution is very simple. We asked all the job owners to run their jobs in the sandbox on a fixed set of data and provide us either of the following &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;1.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Required: &lt;/b&gt;Input size of the data in Mb&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;2.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Required: &lt;/b&gt;Output size of the data in Mb&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;3.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Required: &lt;/b&gt;Is the reducer calculation CPU bound or I/O bound&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo1; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;4.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Optional: &lt;/b&gt;A decimal number, the &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;multiplier&lt;/i&gt;&lt;/b&gt;, &lt;span style=&quot;mso-spacerun: yes;&quot;&gt;&amp;nbsp;&lt;/span&gt;to fine tune the number of reducers (if not provided then 1 will be used) &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0in 0in 0pt 0.5in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0in 0in 0pt 0.5in;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;OR&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0in 0in 0pt 0.5in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo2; text-indent: -0.25in;&quot;&gt;&lt;span style=&quot;mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;&quot;&gt;&lt;span style=&quot;mso-list: Ignore;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;1.&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;&lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;Required:&lt;/b&gt; Provide fixed number of reducers (they have to be less than &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;TotalReducersOnTheGrid/2&lt;/i&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin: 0in 0in 10pt 0.5in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;For &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;CPU bound&lt;/b&gt; jobs, total number of reducers were calculated as&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Total Reducers = &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;Minimum((InputSizeOfDataInMb/128Mb) * multiplier, TotalReducersOnTheGrid/2)&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;i.e. total number of reducers should be equal to either the Input data size divided by the HDFS block size multiplied by the multiplier or half the total number of reducers available in the grid, whichever is smaller. &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;For &lt;b style=&quot;mso-bidi-font-weight: normal;&quot;&gt;I/O bound&lt;/b&gt; jobs the total number of reducers were calculated using the following formula &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;Total Reducers = &lt;i style=&quot;mso-bidi-font-style: normal;&quot;&gt;Minimum((OutputDataSize/InputDataSize) * (InputSizeOfDataInMb/128Mb) * multiplier, TotalReducersOnTheGrid/2)&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;The concept of multiplier was introduced to optimize the jobs when the generic formula was not enough to optimize the number of reducers for the job. We found that some jobs always required an exact number of reducers regardless of the size of data set hence we also provided the job owners a way to specify that.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;span style=&quot;font-family: Calibri;&quot;&gt;This pretty much solved most of our problems. &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin: 0in 0in 10pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/1828745558328880931/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/how-to-dynamically-assign-reducers-to.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/1828745558328880931'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/1828745558328880931'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/how-to-dynamically-assign-reducers-to.html' title='How to dynamically assign reducers to a Hadoop Job in runtime'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-4576424066727599807</id><published>2010-12-17T11:13:00.000-08:00</published><updated>2010-12-17T11:13:40.647-08:00</updated><title type='text'>Hadoop cluster at Ebay</title><content type='html'>I am always curious to know how other companies are installing Hadoop clusters. How are they using its ecosystem. Since Hadoop is still relatively new, there are no best practices. Every company is implementing what they think is the best infrastructure for the Hadoop Cluster.&lt;br /&gt;
&lt;br /&gt;
At Hadoop NYC 2010 conference, ebay showcased there implementation of Hadoop production cluster. Following are some tidbits on ebay&#39;s implementation of Hadoop.&lt;br /&gt;
&lt;br /&gt;
- JobTracker, Namenode, Zookeeper, HBase Master are all enterprise nodes running in Sun 64 bit architecture. They are running red hat linux with 72GB Ram and 4TB disks.&lt;br /&gt;
- There are 4000 datanodes, each running cent OS with 48 GB RAM and 10TB space&lt;br /&gt;
- Ganglia and Nagios are used for monitoring and alerting. Ebay is also building a custom solution to augment them.&lt;br /&gt;
- ETL is done using mostly Java Map Reduce programs&lt;br /&gt;
- Pig is used to build data pipelines&lt;br /&gt;
- Hive is used for AdHoc queries&lt;br /&gt;
- Mahout is used for Data Mining&lt;br /&gt;
&lt;br /&gt;
They are toying with the idea of using Oozie to manage work flows but haven&#39;t decided to use it yet.&lt;br /&gt;
&lt;br /&gt;
It looks like they are doing all the right things.</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/4576424066727599807/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/hadoop-cluster-at-ebay.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/4576424066727599807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/4576424066727599807'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/hadoop-cluster-at-ebay.html' title='Hadoop cluster at Ebay'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-8631237176006574936</id><published>2010-12-10T15:06:00.000-08:00</published><updated>2010-12-10T15:06:04.706-08:00</updated><title type='text'>ERROR: hdfs.DFSClient: Exception in createBlockOutputStream java.io.IOException: Bad connect ack with firstBadLink</title><content type='html'>While running a job once I got the following exception&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;10/12/10 21:09:05 INFO hdfs.DFSClient: Exception in createBlockOutputStream java.io.IOException: Bad connect ack with firstBadLink &lt;b&gt;10.1.73.148&lt;/b&gt;:50010&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;10/12/10 21:09:05 INFO hdfs.DFSClient: Abandoning block blk_3623545154924652323_87440&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;10/12/10 21:09:11 INFO hdfs.DFSClient: Exception in createBlockOutputStream java.net.ConnectException: Connection refused&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;10/12/10 21:09:11 INFO hdfs.DFSClient: Abandoning block blk_-4726571439643867938_87441\&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;b&gt;REASON&lt;/b&gt;&lt;br /&gt;
The error contains the IP address (10.1.73.148) of the tasktracker/datanode machine for which the exception is thrown. The exception is thrown because the datanode daemon is not running on that machine; you can check this by logging into this machine, lets use 10.1.73.148 in the example, and running command&lt;br /&gt;
&lt;i&gt;ps -eaf | grep &quot;DataNode&quot; | grep -v &quot;grep&quot;&lt;/i&gt;&lt;br /&gt;
If no lines are returned then this means that datanode daemon is not running on&amp;nbsp;10.1.73.148.&lt;br /&gt;
&lt;br /&gt;
What happened is that machine&amp;nbsp;10.1.73.148&amp;nbsp;contain a data block that is required for the job that you are trying to run. If this block is replicated on other machines and those machines are running datanode daemons then this is not a problem, Hadoop will get the data block from some other machine and continue the job but if for any reason the data block is not available on any other node then your job will fail.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;RESOLUTION&lt;/b&gt;&lt;br /&gt;
Logon to&amp;nbsp;10.1.73.148 and run the following command&lt;br /&gt;
&lt;i&gt;hadoop-daemon.sh start datanode&lt;/i&gt;&lt;br /&gt;
The above command should start the datanode daemon on&amp;nbsp;10.1.73.148. You can double check this my running command&lt;br /&gt;
&lt;i&gt;ps -eaf | grep &quot;DataNode&quot; | grep -v &quot;grep&quot;&lt;/i&gt;&lt;br /&gt;
It should return 1 line&lt;br /&gt;
&lt;br /&gt;
Thats it. Try running the job again. It should not throw exception anymore</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/8631237176006574936/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/error-hdfsdfsclient-exception-in.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/8631237176006574936'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/8631237176006574936'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/error-hdfsdfsclient-exception-in.html' title='ERROR: hdfs.DFSClient: Exception in createBlockOutputStream java.io.IOException: Bad connect ack with firstBadLink'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-5532109202924684168</id><published>2010-12-10T12:34:00.000-08:00</published><updated>2010-12-10T12:34:15.691-08:00</updated><title type='text'>How to see table definition (extended) in Hive</title><content type='html'>To see table definition in Hive, run command &lt;br /&gt;
&lt;code&gt;describe table name;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
To see more detailed information about the table, run command&lt;br /&gt;
&lt;code&gt;describe extended [tablename];&lt;code&gt;&lt;/code&gt;&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/5532109202924684168/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/how-to-see-table-definition-extended-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/5532109202924684168'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/5532109202924684168'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/how-to-see-table-definition-extended-in.html' title='How to see table definition (extended) in Hive'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-6501535625517879401</id><published>2010-12-09T17:32:00.000-08:00</published><updated>2010-12-10T12:47:43.031-08:00</updated><title type='text'>ERROR: java.lang.IllegalArgumentException: Name cannot be have a &#39;&#39; char</title><content type='html'>&lt;b&gt;ERROR&lt;/b&gt;&lt;br /&gt;
Sometimes your Hadoop MapReduce job can fail with the following exception&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;java.lang.IllegalArgumentException: Name cannot be have a &#39;&#39; char&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;at org.apache.hadoop.mapreduce.lib.output.MultipleOutputs.checkTokenName(MultipleOutputs.java:149)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;at org.apache.hadoop.mapreduce.lib.output.MultipleOutputs.checkNamedOutputName(MultipleOutputs.java:175)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;at org.apache.hadoop.mapreduce.lib.output.MultipleOutputs.write(MultipleOutputs.java:352)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;at org.apache.hadoop.mapreduce.lib.output.MultipleOutputs.write(MultipleOutputs.java:337)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;at learnhadoop.MosMapper.map(MosMapper.java:38)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;at learnhadoop.MosMapper.map(MosMapper.java:14)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:583)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;at org.apache.hadoop.mapred.MapTask.run(MapTask.java:305)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;at org.apache.hadoop.mapred.Child.main(Child.java:170)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;REASON&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
This happens when you use MultipleOutputs class in your Hadoop Job and try to name the output file with non-alphanumeric characters (like : or - etc.)&lt;br /&gt;
i.e. &amp;lt;M&lt;i&gt;ultipleOutput Object&amp;gt;.write(KEY,VALUE,&quot;Fruit::Mango&quot;)&lt;/i&gt; will throw this error because you are using colons in the output file name&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;RESOLUTION&lt;/b&gt;&lt;br /&gt;
Try to use only alphanumeric characters in the output filename and if you absolutely have to use some kind of delimiter, stick with dot (.)&lt;br /&gt;
i.e.&amp;nbsp;&amp;lt;M&lt;i&gt;ultipleOutput Object&amp;gt;.write(KEY,VALUE,&quot;Fruit..Mango&quot;)&lt;/i&gt;&amp;nbsp;&amp;nbsp;will &lt;b&gt;not&lt;/b&gt;&amp;nbsp;throw this error</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/6501535625517879401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/error-javalangillegalargumentexception.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/6501535625517879401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/6501535625517879401'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/error-javalangillegalargumentexception.html' title='ERROR: java.lang.IllegalArgumentException: Name cannot be have a &#39;&#39; char'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-2666942796232218469</id><published>2010-12-09T17:08:00.000-08:00</published><updated>2010-12-09T17:15:14.145-08:00</updated><title type='text'>MultipleOutputs performance issues</title><content type='html'>MultipleOutputs class in Hadoop API provides a very neat way of separating disparate data but it comes with a performance hit.&lt;br /&gt;
&lt;br /&gt;
I found that some of my production jobs slowed down after I refactored by code to use MultipleOutputs class. I did some benchmarking to ensure that its not the cluster but MultipleOutputs class that slowed my processes down.&lt;br /&gt;
&lt;br /&gt;
I setup a small cluster with just 6 machines and some data&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;1 machine running JobTracker&lt;/li&gt;
&lt;li&gt;1 machine running Namenode&lt;/li&gt;
&lt;li&gt;4 machines running Datanodes and tasktracker&lt;/li&gt;
&lt;li&gt;Input data 8Gb&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;All machines were of same size and nothing else was running on them during benchmarking.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;b&gt;Test 1&lt;/b&gt;: Mapper without MultipleOutputs&lt;/div&gt;&lt;div&gt;I created a mapper that&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Reads a file line by line&lt;/li&gt;
&lt;li&gt;Creates output file name on the fly by taking first 3 characters of the hash of the input line. This information was not used to write output (because we are not using MultipleOutputs yet). &amp;nbsp;&lt;/li&gt;
&lt;li&gt;Write the output key as input line and outputValue as NullWritable&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;I ran it 5 times and the median runtime was 4m 40s.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;b&gt;Test 2&lt;/b&gt;: MultipleOutputs Mapper&lt;/div&gt;&lt;div&gt;Then I modified the above mapper to use the output file name and write data out using MultipleOutputs. I ran this 5 times and the median runtimes was 5m 48s.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Based on this benchmark I found that&amp;nbsp;MultipleOutputs&amp;nbsp;slows down a job by almost 20%.&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div&gt;This happens because more small files are created when you use MultipleOutputs class.&lt;/div&gt;&lt;div&gt;Say you have 50 mappers then assuming that you don&#39;t have skewed data, &lt;b&gt;Test1 &lt;/b&gt;will&amp;nbsp;always&amp;nbsp;generate exactly 50 files but Test2 will generate somewhere between 50 to 1000 files (50Mappers x 20TotalPartitionsPossible) and this causes a performance hit in I/O. In my benchmark, 199 output files were generated for &lt;b&gt;Test1 &lt;/b&gt;and 4569 output files were generated for &lt;b&gt;Test2.&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/2666942796232218469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/multipleoutputs-performance-issues.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/2666942796232218469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/2666942796232218469'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/multipleoutputs-performance-issues.html' title='MultipleOutputs performance issues'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-5610899969404808526</id><published>2010-12-08T19:50:00.000-08:00</published><updated>2010-12-08T23:23:49.079-08:00</updated><title type='text'>Extended FileUtil class for Hadoop</title><content type='html'>&lt;/BlogItemTitle&gt;&lt;br /&gt;
&lt;/Blogger&gt;&lt;br /&gt;
While writing production jobs in Hadoop I identified following tasks that were required for some MapReduce jobs but were not readily available in Hadoop 0.20 API&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Get size of a file or directory in HDFS&lt;/li&gt;
&lt;ul&gt;&lt;li&gt;We require this to dynamically change the number of reducers used for a job by looking at the amount of input data that the job will process&lt;/li&gt;
&lt;/ul&gt;&lt;li&gt;Recursively remove all zero byte files from a directory in HDFS.&amp;nbsp;&lt;/li&gt;
&lt;ul&gt;&lt;li&gt;This happens a lot when you use MultipleOutput class in reducer (impact is less when used in Mapper). A lot of times the reducer does not gets any record for which a MutipleOutput file needs to be created hence it creates a 0 byte files. These files have no use, its best to remove them after the job is finished.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;&lt;li&gt;Recursively get all subdirectories of a directories&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Recursively get all files within a directory and its sub directories&lt;/li&gt;
&lt;ul&gt;&lt;li&gt;By default, as of now, when Hadoop job is run, it only processes the immediate files under the input directory, any files in the subdirectories of the input path are not processed hence if you want your job to process all files under the subdirectories also then its better to create a comma delimited list of all files within the input path and submit it to the job. &amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;&lt;/ol&gt;&lt;br /&gt;
All the above tasks were implemented in the ExtendedFileUtil class. Source code can be found at&lt;br /&gt;
&lt;a href=&quot;https://sites.google.com/site/hadoopandhive/home/ExtendedFileUtil.java?attredirects=0&amp;amp;d=1&quot;&gt;https://sites.google.com/site/hadoopandhive/home/ExtendedFileUtil.java?attredirects=0&amp;amp;d=1&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The wrapper class on link&amp;nbsp;&lt;a href=&quot;http://hadoop-blog.blogspot.com/2010/12/java-templatesstubs-for-mapper-reducer.html&quot;&gt;http://hadoop-blog.blogspot.com/2010/12/java-templatesstubs-for-mapper-reducer.html&lt;/a&gt;&amp;nbsp;contains an example of how to use ExtendedFileUtil class</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/5610899969404808526/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/extended-fileutil-class-for-hadoop.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/5610899969404808526'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/5610899969404808526'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/extended-fileutil-class-for-hadoop.html' title='Extended FileUtil class for Hadoop'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-3400935646541121205</id><published>2010-12-08T19:46:00.000-08:00</published><updated>2010-12-08T19:49:40.370-08:00</updated><title type='text'>How to combine small files in Hadoop</title><content type='html'>Currently Hadoop is not built to work with a lot of small files. The following are the architectural limitations of hadoop that causes this problem&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;In HDFS, all file metadata is stored in memory of the Namenode (which is most often a single big powerful machine). This means &quot;more files=more memory&quot;. There is a limitation on the amount of memory you can add to a machine and that limits the amount of files that can be stored in Hadoop.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Namenode is used heavily for all jobs that run on Hadoop. More data in the memory can slow down Namenode and might end of slowing down the job execution time (it might be insignificant for long jobs though)&lt;/li&gt;
&lt;li&gt;There is a setup time required by Hadoop to run a mapper. By default, Hadoop will start minimum 1 mapper for every file in the input directory. Till Hadoop 0.20, hadoop does not lets us choose the number of mappers you want to run hence if your file is small, say 100K, then more time is wasted in Hadoop setup than actually processing the data.&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;There are couple different solutions to solve this problem&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;Keep an eye on all data that is entered into HDFS &amp;nbsp;from other data sources. Try to optimize the processes, that push data to HDFS, to create files of size 128Mb (block size of HDFS).&amp;nbsp;&lt;/li&gt;
&lt;li&gt;If you have map reduce pipeline where output of a map reduce job become input of the next map reduce job then try to use reducers wisely in your jobs. If suppose your job uses 100 reducers and outputs files of size 10 MB each, and if the reducer computations are not CPU bound, then try to run the same job with less reducers (7-10). &lt;b&gt;Remember &lt;/b&gt;- Hadoop creates one file for every reducer run even if reducer did not output any data.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;If all else fails then try to combine small files into bigger files. Media6degrees has come up with a faily good solution to combine small files  in Hadoop. You can use their jar straight out. See here for more details&amp;nbsp;&lt;a href=&quot;http://www.jointhegrid.com/hadoop_filecrush/index.jsp&quot; rel=&quot;nofollow&quot;&gt;http://www.jointhegrid.com/hadoop_filecrush/index.jsp&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/3400935646541121205/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/how-to-combine-small-files-in-hadoop.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/3400935646541121205'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/3400935646541121205'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/how-to-combine-small-files-in-hadoop.html' title='How to combine small files in Hadoop'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-8141527413604591754</id><published>2010-12-08T19:45:00.000-08:00</published><updated>2010-12-08T19:45:44.962-08:00</updated><title type='text'>Java templates/stubs for Mapper Reducer and Wrapper classes</title><content type='html'>A lot of times I want to test a concept in Hadoop that requires me to quickly create a small job and run it. Every job contains minimum 3 components&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Mapper Class&lt;/li&gt;
&lt;li&gt;Reducer Class&lt;/li&gt;
&lt;li&gt;Wrapper Class&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;The following are the templates I use to generate empty templates, just replace variable &amp;nbsp;&lt;i&gt;&amp;lt;YOUNAME&amp;gt;&lt;/i&gt;&amp;nbsp;with your class name&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;-----------------------------------------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;MAPPER&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;-----------------------------------------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;i&gt;import org.apache.hadoop.conf.Configuration;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;import org.apache.hadoop.mapreduce.Mapper;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;import org.apache.hadoop.io.LongWritable;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;import org.apache.hadoop.io.Text;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;import java.io.IOException;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;/* In case you are using Multiple outputs */&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;//import org.apache.hadoop.io.NullWritable;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;//import org.apache.hadoop.mapreduce.lib.output.MultipleOutputs;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;public class &amp;lt;YOUNAME&amp;gt;Mapper extends Mapper&amp;lt;LongWritable, Text, Text, Text&amp;gt; {&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private Configuration conf;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private Text outputKey = new Text();&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private Text outputValue = new Text();&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private String line = null;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;/* In case you are using Multiple outputs */&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;//private NullWritable outputValue = NullWritable.get();&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;//private MultipleOutputs&amp;lt;Text, Text&amp;gt; contextMulti = null;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;@Override&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public void setup(Mapper.Context context) {&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.conf = context.getConfiguration();&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* In case you are using Multiple outputs */&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//contextMulti = new MultipleOutputs&amp;lt;Text, Text&amp;gt;(context);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;@Override&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public void map(LongWritable key, Text values, Context context)&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;throws IOException, InterruptedException {&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;@Override&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public void cleanup (Mapper.Context context)throws IOException, InterruptedException {&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* In case you are using Multiple outputs */&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//contextMulti.close();&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;}&lt;/i&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;-----------------------------------------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;REDUCER&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black; font-weight: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;-----------------------------------------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;i&gt;import org.apache.hadoop.conf.Configuration;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;import org.apache.hadoop.io.Text;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;import org.apache.hadoop.mapreduce.Reducer;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;import java.io.IOException;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;/* In case you are using Multiple outputs */&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;//import org.apache.hadoop.io.NullWritable;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;//import org.apache.hadoop.mapreduce.lib.output.MultipleOutputs;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;public class &amp;lt;YOUNAME&amp;gt;Reducer extends Reducer&amp;lt;Text, Text, Text, Text&amp;gt; {&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private Configuration conf;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private Text outputKey = new Text();&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private Text outputValue = new Text();&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private String line = null;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;/* In case you are using Multiple outputs */&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;//private NullWritable outputValue = NullWritable.get();&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;//private MultipleOutputs&amp;lt;Text, Text&amp;gt; contextMulti = null;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;@Override&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public void setup(Reducer.Context context) {&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.conf = context.getConfiguration();&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* In case you are using Multiple outputs */&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//contextMulti = new MultipleOutputs&amp;lt;Text, Text&amp;gt;(context);&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;@Override&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public void reduce(Text key, Iterable&amp;lt;Text&amp;gt; values, Context context)&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;throws IOException, InterruptedException {&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;@Override&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public void cleanup(Reducer.Context context) {&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/* In case you are using Multiple outputs */&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//contextMulti.close();&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;}&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font-weight: bold;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;-----------------------------------------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-weight: bold;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;WRAPPER&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;This class uses following 2 classes&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;a href=&quot;https://sites.google.com/site/hadoopandhive/home/ExtendedFileUtil.java?attredirects=0&amp;amp;d=1&quot;&gt;https://sites.google.com/site/hadoopandhive/home/ExtendedFileUtil.java?attredirects=0&amp;amp;d=1&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;a href=&quot;https://sites.google.com/site/hadoopandhive/home/StringUtil.java?attredirects=0&amp;amp;d=1&quot;&gt;https://sites.google.com/site/hadoopandhive/home/StringUtil.java?attredirects=0&amp;amp;d=1&lt;/a&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red; font-weight: bold;&quot;&gt;-----------------------------------------------------------------------------------------------------------------------------------&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;i&gt;&lt;/i&gt;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;div style=&quot;display: inline !important;&quot;&gt;&lt;i&gt;&lt;i&gt;import StringUtil;&lt;/i&gt;&lt;/i&gt;&lt;/div&gt;&lt;br /&gt;
&lt;i&gt;import ExtendedFileUtil;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;import org.apache.hadoop.conf.Configuration;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;import org.apache.hadoop.conf.Configured;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;import org.apache.hadoop.fs.Path;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;import org.apache.hadoop.io.NullWritable;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;import org.apache.hadoop.io.Text;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;import org.apache.hadoop.mapreduce.Job;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;import org.apache.hadoop.util.Tool;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;import org.apache.hadoop.util.ToolRunner;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;import java.io.IOException;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;import java.text.ParseException;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;public class &amp;lt;YOUNAME&amp;gt; extends Configured implements Tool, Constants {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private Configuration conf = null;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private Job job = null;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private String inputDirList = null;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private String outputDir = null;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private String[] filesToProcess = null;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private int totalReducers = 0;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private int jobRes = 0;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private ExtendedFileUtil fileUtil = new ExtendedFileUtil();&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public static void main(String[] args) throws Exception {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;YOUNAME&amp;gt; ob = new &amp;lt;YOUNAME&amp;gt;();&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;int jobRes = ToolRunner.run(ob, args); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;public int run(String[] args)&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;throws ClassNotFoundException, IOException, InterruptedException, ParseException {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;jobRes = readCmdArgs(args);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (jobRes == 0) {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;jobRes = readConfig();&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (jobRes == 0) {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;jobRes = runMrJob();&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return jobRes;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private int readCmdArgs(String[] args) {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (args.length == 2) {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;inputDirList = args[0];&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;outputDir = args[1];&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;} else {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;printUsage();&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.exit(1);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 0;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private int readConfig() throws IOException, InterruptedException, ClassNotFoundException {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;conf = new Configuration();&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//conf.set(&quot;SET_NEW_CONFIG_NAME&quot;, SET_NEW_CONFIG_VALUE);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;job = new Job(conf);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if ((job.getJar() == null) || (job.getJar() == &quot;&quot;)) {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;job.setJarByClass(&amp;lt;YOUNAME&amp;gt;.class);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 0;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private int runMrJob()&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;throws IOException, InterruptedException, ClassNotFoundException {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;filesToProcess = fileUtil.getFilesOnly(inputDirList, true);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;job.setJobName(&quot;&amp;lt;YOUNAME&amp;gt;&quot;);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TextInputFormat.addInputPaths(job, StringUtil.arrayToString(filesToProcess, &quot;,&quot;));&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TextOutputFormat.setOutputPath(job, new Path(outputDir));&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println(&quot;Input Dir: &quot; + inputDirList);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println(&quot;Output Dir: &quot; + outputDir);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;job.setMapperClass(&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;i&gt;&amp;lt;YOUNAME&amp;gt;&lt;/i&gt;&lt;/span&gt;Mapper.class);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;job.setMapOutputKeyClass(Text.class);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;job.setMapOutputValueClass(Text.class);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;job.setReducerClass(&amp;lt;YOUNAME&amp;gt;Reducer.class);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;job.setOutputKeyClass(Text.class);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;job.setOutputValueClass(Text.class);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;totalReducers = Math.round((fileUtil.size(inputDirList) / 134217728) * 0.1F);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;totalReducers = Math.max(totalReducers, 1);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;job.setNumReduceTasks(&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;i&gt;totalReducers&amp;nbsp;&lt;/i&gt;&lt;/span&gt;);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;deleteOutputDirectory(outputDir);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;jobRes = job.waitForCompletion(true) ? 0 : 1;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;deleteLogsDirectory();&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fileUtil.removeAllZeroByteFiles(outputDir);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 0;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private int deleteOutputDirectory(String outputDir) throws IOException {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fileUtil.removeHdfsPath(new Path(outputDir).toString());&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 0;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private int printUsage() {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println(&quot;USAGE: &amp;lt;YOUNAME&amp;gt; &amp;lt;inputDirList&amp;gt; &amp;lt;outputDir&amp;gt;&quot;);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 0;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;private int deleteLogsDirectory()&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;throws IOException {&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Path outputLogPath = new Path(new Path(outputDir).toString() + &quot;/&quot; + &quot;_logs&quot;);&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;fileUtil.removeHdfsPath(outputLogPath.toString());&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return 0;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;}&lt;/i&gt;&lt;br /&gt;
&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/8141527413604591754/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/java-templatesstubs-for-mapper-reducer.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/8141527413604591754'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/8141527413604591754'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/java-templatesstubs-for-mapper-reducer.html' title='Java templates/stubs for Mapper Reducer and Wrapper classes'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-5297843441897074698</id><published>2010-12-08T12:45:00.000-08:00</published><updated>2010-12-08T12:45:04.357-08:00</updated><title type='text'>How configure Secondary namenode on a separate machine</title><content type='html'>If you have installed cloudera&#39;s hadoop distribution (CDH2) then you must have noticed that running command &lt;i&gt;start-dfs.sh&lt;/i&gt; starts an instance of SecondaryNameNode process on all the datanodes. This is happening due to the way SecondaryNameNode startup is defined in file &lt;b&gt;&lt;i&gt;bin/start-dfs.sh.&amp;nbsp;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Scenario 1 : If you want to run your SecondaryNameNode on some other server (say sn.jeka.com) instead of the datanodes then do the following&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;i&gt;&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;1. Logon to JobTracker (I am going to JobTracker because I have set variable HADOOP_MASTER in file &lt;b&gt;&lt;i&gt;${HADOOP_HOME}/conf/hadoop-env.sh&lt;/i&gt;&lt;/b&gt; to point to the JobTracker hence any changes made there will be synched to your cluster)&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Create a new file &lt;b&gt;&lt;i&gt;${HADOOP_HOME}/conf/secondarynamenode&lt;/i&gt;&lt;/b&gt; and add following line&lt;br /&gt;
&lt;i&gt;sn.jeka.com&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;In file &lt;b&gt;&lt;i&gt;${HADOOP_HOME}/bin/start-dfs.sh&lt;/i&gt;&lt;/b&gt;, replace line&lt;br /&gt;
&lt;i&gt; &quot;$bin&quot;/hadoop-daemons.sh --config $HADOOP_CONF_DIR --hosts masters start secondarynamenode&lt;/i&gt;&lt;br /&gt;
with&lt;br /&gt;
&lt;i&gt; ssh $(cat $HADOOP_CONF_DIR/secondarynamenode) &quot;${bin}/hadoop-daemon.sh --config $HADOOP_CONF_DIR --hosts secondarynamenode start secondarynamenode;exit&quot;&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;&lt;/i&gt;In file &lt;b&gt;&lt;i&gt;${HADOOP_HOME}/bin/stop-dfs.sh&lt;/i&gt;&lt;/b&gt;, replace line&lt;br /&gt;
&lt;i&gt; &quot;$bin&quot;/hadoop-daemons.sh --config $HADOOP_CONF_DIR --hosts masters stop secondarynamenode&lt;/i&gt;&lt;br /&gt;
with&lt;br /&gt;
&lt;i&gt; ssh $(cat $HADOOP_CONF_DIR/secondarynamenode) &quot;${bin}/hadoop-daemon.sh --config $HADOOP_CONF_DIR --hosts secondarynamenode stop secondarynamenode;exit&quot;&lt;/i&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;2.&amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Logon to Namenode and execute the following commands&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;i&gt;${HADOOP_HOME}/bin/stop-dfs.sh; ${HADOOP_HOME}/bin/start-dfs.sh; ${HADOOP_HOME}/bin/stop-dfs.sh; ${HADOOP_HOME}/bin/start-dfs.sh&lt;/i&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;You have to start and stop twice because in the first start, the code will be synched from JobTracker&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Thats! it. You secondary name node process will now start on the designated server, i.e. sn.jeka.com and not on the datanodes.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Scenario 2 : If you want to run your SecondaryNameNode on the NameNode (say nn.jeka.com) itself then do the following&amp;nbsp;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;font-style: italic; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;Follow same steps as Scenario 1 except that replace all intances of &lt;/span&gt;sn.jeka.com&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt; to &lt;/span&gt;nn.jeka.com&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;font-style: italic; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Scenario 3 : If you do not want to run secondary name node at all then do the following&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Follow same steps as Scenario 1 except that instead of replacing lines, delete them.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;font-style: italic; font-weight: bold;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/5297843441897074698/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/secondarynamenode-process-is-starting.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/5297843441897074698'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/5297843441897074698'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/secondarynamenode-process-is-starting.html' title='How configure Secondary namenode on a separate machine'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-1067788187345422574</id><published>2010-12-07T17:25:00.000-08:00</published><updated>2010-12-07T17:26:25.601-08:00</updated><title type='text'>How to control a Hadoop job using the web interfaces provided by the Job Tracker and Name Node</title><content type='html'>&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Hadoop provides a great way to manage your jobs and operating on HDFS using the web interface by setting the property&amp;nbsp;&lt;i&gt;webinterface.private.actions &lt;/i&gt;to true in file&amp;nbsp;&lt;i style=&quot;font-weight: bold;&quot;&gt;src/core/core-default.xml.&amp;nbsp;&lt;/i&gt;&lt;br /&gt;
&lt;i style=&quot;font-weight: bold;&quot;&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
When set to true,&amp;nbsp;the web interfaces of JobTracker and NameNode may contain &amp;nbsp;actions, such as kill job, delete file, etc., that should &amp;nbsp;not be exposed to public.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;display: inline !important; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;display: inline !important; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;b&gt;Note: Enable this option only if the web interfaces for JobTracker and Name node&amp;nbsp;&lt;/b&gt;&lt;b&gt;are reachable by those who have the right authorizations.&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;i&gt;&amp;lt;property&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;name&amp;gt;webinterface.private.actions&amp;lt;/name&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;value&amp;gt;false&amp;lt;/value&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;lt;/property&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/1067788187345422574/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/how-to-control-hadoop-job-using-web.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/1067788187345422574'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/1067788187345422574'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/how-to-control-hadoop-job-using-web.html' title='How to control a Hadoop job using the web interfaces provided by the Job Tracker and Name Node'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-6806158201519506063</id><published>2010-12-07T11:27:00.000-08:00</published><updated>2010-12-07T17:33:27.744-08:00</updated><title type='text'>How to limit access to Job Tracker and Name node in Hadoop.</title><content type='html'>&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Hadoop provides properties that can be used to create an include or exclude list of hosts that are allowed to access Job Tracker and Name node.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Property to to create an include list of hosts for JobTracker in file &lt;i&gt;mapred-site.xml&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;i&gt;&amp;lt;property&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;name&amp;gt;mapred.hosts&amp;lt;/name&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;value&amp;gt;&amp;lt;/value&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;description&amp;gt;Names a file that contains the list of nodes that may&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;connect to the jobtracker. &amp;nbsp;If the value is empty, all hosts are&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;permitted.&amp;lt;/description&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;lt;/property&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;b&gt;Property to to create an exclude list of hosts for JobTracker&lt;/b&gt;&lt;b&gt;&amp;nbsp;in file&amp;nbsp;&lt;i&gt;mapred-site.xml&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;lt;property&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;name&amp;gt;mapred.hosts.exclude&amp;lt;/name&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;value&amp;gt;&amp;lt;/value&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;description&amp;gt;Names a file that contains the list of hosts that&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;should be excluded by the jobtracker. &amp;nbsp;If the value is empty, no&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;hosts are excluded.&amp;lt;/description&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;lt;/property&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;b&gt;Property to to create an include list of hosts for NameNode in file &lt;i&gt;hdfs-site.xml&lt;/i&gt;&lt;/b&gt;&lt;br /&gt;
&lt;i&gt;&amp;lt;property&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;name&amp;gt;dfs.hosts&amp;lt;/name&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;value&amp;gt;&amp;lt;/value&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;description&amp;gt;Names a file that contains a list of hosts that are&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;permitted to connect to the namenode. The full pathname of the file&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;must be specified. &amp;nbsp;If the value is empty, all hosts are&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;permitted.&amp;lt;/description&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;lt;/property&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;b&gt;Property to to create an exclude list of hosts for NameNode&amp;nbsp;&lt;/b&gt;&lt;b&gt;in file&amp;nbsp;&lt;i&gt;hdfs-site.xml&lt;/i&gt;&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;lt;property&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;name&amp;gt;dfs.hosts.exclude&amp;lt;/name&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;value&amp;gt;&amp;lt;/value&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;lt;description&amp;gt;Names a file that contains a list of hosts that are&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;not permitted to connect to the namenode. &amp;nbsp;The full pathname of the&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;file must be specified. &amp;nbsp;If the value is empty, no hosts are&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;excluded.&amp;lt;/description&amp;gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;i&gt;&amp;lt;/property&amp;gt;&lt;/i&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/6806158201519506063/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/how-to-limit-access-to-job-tracker-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/6806158201519506063'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/6806158201519506063'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/how-to-limit-access-to-job-tracker-and.html' title='How to limit access to Job Tracker and Name node in Hadoop.'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-8483551385948998949</id><published>2010-12-07T11:11:00.000-08:00</published><updated>2010-12-07T11:11:47.767-08:00</updated><title type='text'>Hadoop distcp error: java.lang.NumberFormatException: For input string: &quot;&quot;</title><content type='html'>&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;Hadoop provide&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;i&gt;distcp&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;command to copy data between clusters.&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;ERROR&lt;/b&gt;&lt;br /&gt;
When running this command I got the following error&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;java.lang.NumberFormatException: For input string: &quot;&quot;&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at java.lang.Integer.parseInt(Integer.java:470)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at java.lang.Integer.parseInt(Integer.java:499)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.net.NetUtils.createSocketAddr(NetUtils.java:149)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.hdfs.server.namenode.NameNode.getAddress(NameNode.java:164)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:81)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:1448)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.fs.FileSystem.access$300(FileSystem.java:67)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:1476)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1464)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:197)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.fs.Path.getFileSystem(Path.java:175)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.tools.DistCp.setup(DistCp.java:997)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.tools.DistCp.copy(DistCp.java:650)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.tools.DistCp.run(DistCp.java:857)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;at org.apache.hadoop.tools.DistCp.main(DistCp.java:884)&lt;/span&gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;REASON&lt;/b&gt;&lt;br /&gt;
This error normally happens when the port number in source or destination hdfs URI is missing.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Example&lt;/b&gt;: Execution of the following command will give this error&lt;br /&gt;
&lt;i&gt;hadoop distcp hdfs://hadoop1.jeka.com:9000/user/hadoop/jeka hdfs://hadoop2.jeka.com&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;:&lt;/span&gt;&lt;/b&gt;/user/hadoop/jeka&lt;/i&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;It happened because port in the destination URL&amp;nbsp;&lt;i&gt;/hdfs://hadoop2.jeka.com&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;:&lt;/span&gt;&lt;/b&gt;/user/hadoop/jeka &lt;/i&gt;is missing but the colon that separates&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;b&gt;RESOLUTION&lt;/b&gt;&lt;/div&gt;&lt;div&gt;Add port number 9000 after the colon, i.e. the destination URI will look like&amp;nbsp;&lt;i&gt;hdfs://hadoop2.jeka.com&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #38761d;&quot;&gt;:9000&lt;/span&gt;&lt;/b&gt;/user/hadoop/jeka&lt;/i&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;or remove the colon, distcp by default looks for port 9000, hence the destination URI will look like&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;i&gt;hdfs://hadoop2.jeka.com/user/hadoop/jeka&lt;/i&gt;&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/8483551385948998949/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/hadoop-distcp-error-javalangnumberforma.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/8483551385948998949'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/8483551385948998949'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/hadoop-distcp-error-javalangnumberforma.html' title='Hadoop distcp error: java.lang.NumberFormatException: For input string: &quot;&quot;'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-46065008762668174</id><published>2010-12-02T22:22:00.000-08:00</published><updated>2010-12-02T22:22:01.446-08:00</updated><title type='text'>How to check if network is the bottleneck in your hadoop cluster</title><content type='html'>We had an issue with our hadoop cluster that after a network upgrade the jobs on the cluster started running very slowly. We knew it had to do something with the network upgrade.&lt;br /&gt;
&lt;br /&gt;
On further investigation we found that all the mapper in the jobs are running fine, all the performance degradation happened on reducers. This pretty much proved the point that network is the bottleneck because most mappers jobs were rack-local (and it requires very limited to almost no use of network) but the reducer phase uses network heavily for sorting and shuffling of data before it can apply the reduce function.</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/46065008762668174/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/how-to-check-if-network-is-bottleneck.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/46065008762668174'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/46065008762668174'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/how-to-check-if-network-is-bottleneck.html' title='How to check if network is the bottleneck in your hadoop cluster'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-7845708493709612564</id><published>2010-12-01T13:56:00.000-08:00</published><updated>2010-12-02T13:02:01.877-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="search engine for apache documentation of hadoop"/><title type='text'>Search engine for Hadoop content, you might find it better than google</title><content type='html'>There is an excellent site to get help online for Hadoop, after the Apache wiki.&amp;nbsp;The website&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt; &lt;a href=&quot;http://search-hadoop.com/&quot;&gt;http://search-hadoop.com&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&amp;nbsp;lets you search Hadoop and all its subprojects &amp;nbsp;like Pig, Hive, Hbase HDFS etc.&lt;br /&gt;
&lt;br /&gt;
The website aggregates, indexes, and makes searchable all content repositories for all Apache Hadoop Top Level Project (TLP) sub-projects. It indexes data from&lt;br /&gt;
- User lists&lt;br /&gt;
- Dev Lists&lt;br /&gt;
- Apache Hadoop Jira&lt;br /&gt;
- Apache Wiki&lt;br /&gt;
- Hadoop source code&lt;br /&gt;
&lt;br /&gt;
Its a very good website. I compared some search results on this site with google and bing results and found that, for hadoop , its easier to get answers on this site then from google or bing. The search results are very well laid. See it to believe it.</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/7845708493709612564/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/search-engine-for-hadoop-content-you.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/7845708493709612564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/7845708493709612564'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/search-engine-for-hadoop-content-you.html' title='Search engine for Hadoop content, you might find it better than google'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1014087953899153880.post-2696422906693166613</id><published>2010-12-01T11:47:00.000-08:00</published><updated>2010-12-01T12:40:39.069-08:00</updated><title type='text'>Error in starting Datanode - ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: java.io.IOException: Incompatible namespaceIDs in</title><content type='html'>While playing around with Hadoop setup I found that after I did something, the datanodes will not start when I run script &lt;i&gt;bin/start-dfs.sh&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Following were the steps I followed to troubleshoot and fix the issue&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;TO FIND THE PROBLEM&lt;/b&gt;&lt;br /&gt;
&lt;ol&gt;&lt;li&gt;Login to any one of the datanodes that is not starting up (say t1.mydomain.com)&lt;/li&gt;
&lt;li&gt;Get the value of variable&amp;nbsp;&lt;i&gt;HADOOP_LOG_DIR &lt;/i&gt;in file &lt;i&gt;conf/hadoop-env.sh. &lt;/i&gt;Say the value is /home/jeka/runtime_hadoop_data/logs&lt;/li&gt;
&lt;li&gt;Look into datanode log file&amp;nbsp;&lt;i&gt;/home/jeka/runtime_hadoop_data/logs/hadoop-jeka-datanode-t1.mydomain.com.log. &lt;/i&gt;Following error was logged&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt; 2010-12-01 18:57:39,115 ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: java.io.IOException: Incompatible namespaceIDs in /home/jeka/runtime_hdfs/datanode: namenode namespaceID = 1509057607; datanode namespaceID = 1781994419&lt;br /&gt;
at org.apache.hadoop.hdfs.server.datanode.DataStorage.doTransition(DataStorage.java:233)&lt;br /&gt;
at org.apache.hadoop.hdfs.server.datanode.DataStorage.recoverTransitionRead(DataStorage.java:148)&lt;br /&gt;
at org.apache.hadoop.hdfs.server.datanode.DataNode.startDataNode(DataNode.java:298)&lt;br /&gt;
at org.apache.hadoop.hdfs.server.datanode.DataNode.&lt;/span&gt;&lt;/i&gt;&lt;init&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;(DataNode.java:216)&lt;br /&gt;
at org.apache.hadoop.hdfs.server.datanode.DataNode.makeInstance(DataNode.java:1283)&lt;br /&gt;
at org.apache.hadoop.hdfs.server.datanode.DataNode.instantiateDataNode(DataNode.java:1238)&lt;br /&gt;
at org.apache.hadoop.hdfs.server.datanode.DataNode.createDataNode(DataNode.java:1246)&lt;br /&gt;
at org.apache.hadoop.hdfs.server.datanode.DataNode.main(DataNode.java:1368)&lt;/span&gt;&lt;/i&gt;&lt;/init&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;REASON&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;This issue happened right after I reformatted the namenode (and did not reformat datanodes). Everytime Namenode is formatted, Hadoop creates a unique namespaceID and places it in a file in the Namenode but since I did not formatted the datanodes hence datanodes still had the old namespaceID and hence the problem.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;SOLUTION&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
The solution is to copy the new namespaceID from Namenode to Datanodes. Following are the steps&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Logon to the namenode (say nn.mydomain.com)&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Stop DFS by running command &lt;i&gt;bin&lt;/i&gt;/&lt;i&gt;stop-dfs.sh&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;Find the values of property &lt;i&gt;dfs.name.dir &lt;/i&gt;and &lt;i&gt;dfs.data.dir.&lt;/i&gt;&amp;nbsp;This can be found in file&amp;nbsp;&lt;i&gt;conf/hdfs-site.xml&lt;/i&gt;. If missing then look for it in file&amp;nbsp;&lt;i&gt;src/hdfs/hdfs-default.xml&lt;/i&gt;. Say the value of these properties are&amp;nbsp;&lt;i&gt;/home/jeka/runtime_hdfs/namenode &lt;/i&gt;and&amp;nbsp;&lt;i&gt;/home/jeka/runtime_hdfs/datanode &lt;/i&gt;respectively&lt;/li&gt;
&lt;li&gt;Note the value of field &lt;i&gt;namespaceID &lt;/i&gt;(this is the new Namenode namespaceID that we need to copy to all datanodes&lt;i&gt;)&amp;nbsp;&lt;/i&gt;in file &lt;i&gt;/home/jeka/runtime_hdfs/namenode/current/VERSION&lt;/i&gt;. &lt;br /&gt;
&lt;br /&gt;
In our case its&amp;nbsp;&lt;b&gt;1509057607&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
For your reference, following are all the contents of this file&lt;br /&gt;
&lt;i&gt; #Wed Dec 01 19:05:31 UTC 2010&lt;br /&gt;
namespaceID=1509057607&lt;br /&gt;
cTime=0&lt;br /&gt;
storageType=NAME_NODE&lt;br /&gt;
layoutVersion=-18&lt;/i&gt;&lt;/li&gt;
&lt;li&gt;Now copy the new&amp;nbsp;&lt;i&gt;namespaceID,&lt;/i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal; font-weight: bold;&quot;&gt;1509057607 &lt;/span&gt;in our case&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal; font-weight: bold;&quot;&gt;,&lt;/span&gt;&lt;i&gt;&amp;nbsp;&lt;/i&gt;to file&amp;nbsp;&lt;i&gt;/home/jeka/runtime_hdfs/datanode/current/VERSION &lt;/i&gt;on all datanodes by running the following command on shell prompt on Namenode&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt; for dn in $(cat ~/hadoop-0.20.2/conf/slaves);do ssh $dn &quot;cat /home/jeka/runtime_hdfs/datanode/current/VERSION | sed &#39;s/namespaceID=[0-9]*/namespaceID=1509057607/&#39; &amp;gt; /home/jeka/runtime_hdfs/datanode/current/VERSION.temp; mv /home/jeka/runtime_hdfs/datanode/current/VERSION.temp /home/jeka/runtime_hdfs/datanode/current/VERSION&quot;;done&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
This command will go to each and every datanode listed in file &lt;i&gt;conf/slaves&lt;/i&gt; and change the namespaceID of the datanode to 1509057607&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Start DFS&amp;nbsp;by running command&amp;nbsp;&lt;i&gt;bin&lt;/i&gt;/&lt;i&gt;start-dfs.sh. &lt;/i&gt;Thats it!,&lt;i&gt; &lt;/i&gt;all datanodes should be up and running now.&lt;/li&gt;
&lt;/ol&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://hadoop-blog.blogspot.com/feeds/2696422906693166613/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/error-is-starting-datanode-error.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/2696422906693166613'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1014087953899153880/posts/default/2696422906693166613'/><link rel='alternate' type='text/html' href='http://hadoop-blog.blogspot.com/2010/12/error-is-starting-datanode-error.html' title='Error in starting Datanode - ERROR org.apache.hadoop.hdfs.server.datanode.DataNode: java.io.IOException: Incompatible namespaceIDs in'/><author><name>Username</name><uri>http://www.blogger.com/profile/09504145675115315499</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>