<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muhammad Zaman on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Zaman on Medium]]></description>
        <link>https://medium.com/@zaman.nuces?source=rss-a964c8d29df6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*A28iwznL3XcbS0mdyRJ3Gw.jpeg</url>
            <title>Stories by Muhammad Zaman on Medium</title>
            <link>https://medium.com/@zaman.nuces?source=rss-a964c8d29df6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 13:02:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zaman.nuces/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Installation Apache Hive. Series-3 of 3]]></title>
            <link>https://medium.com/@zaman.nuces/installation-apache-hive-series-3-of-3-a32eb1cb2466?source=rss-a964c8d29df6------2</link>
            <guid isPermaLink="false">https://medium.com/p/a32eb1cb2466</guid>
            <category><![CDATA[apache-hive]]></category>
            <category><![CDATA[hive]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[apache]]></category>
            <dc:creator><![CDATA[Muhammad Zaman]]></dc:creator>
            <pubDate>Tue, 17 Apr 2018 12:17:41 GMT</pubDate>
            <atom:updated>2018-04-17T12:17:41.538Z</atom:updated>
            <content:encoded><![CDATA[<h4>Hive Installation, Testing, and Benchmarking</h4><h3>Prerequisite:</h3><p><a href="https://medium.com/@zaman.nuces/setting-up-fully-distributed-hadoop-cluster-series-2-of-3-27b9831c25ae">See Part-2 of Series</a> for following configurations</p><pre>1. Java<br>2. Hadoop cluster / standalone</pre><h4>Q. In case of Hadoop Cluster we only need to install Hive on All-nodes / Master-node?</h4><p><strong>Ans.</strong> We only have to install Hive on Master node. <a href="https://stackoverflow.com/questions/8456141/in-a-hadoop-cluster-should-hive-be-installed-on-all-nodes">Why we only need to install Hive on Master?</a></p><blockquote>Let&#39;s place a cherry &#39;Hive&#39; on top of the fully baked cake &#39;Hadoop&#39;.</blockquote><h3>Configure Hive (Only-Master-node)</h3><ol><li><strong>We need to install hive merely on master node.</strong></li></ol><pre>wget http://apache.claz.org/hive/stable/apache-hive-1.2.2-bin.tar.gz <br>tar -xzf apache-hive-1.2.2-bin.tar.gz  <br>sudo mkdir -p /usr/local/hive sudo mkdir /usr/local/hive </pre><pre>clear <br>sudo mv apache-hive-1.2.2-bin/* /usr/local/hive/ </pre><pre>ls /usr/local/hive <br>ls -l /usr/local/hive ##chown [owner][:[group]] file #hive:hive in below command is equivalent to username:usergroup<br> <br>sudo chown -R hive:hive /usr/local/hive </pre><p><strong>2. Check Java Processes (On-All Nodes)</strong></p><pre>jps</pre><p><strong>3. Set Environment Variable</strong></p><p>a. Open File</p><pre>sudo nano ~/.bashrc </pre><p>b. Add Following lines</p><p>##HIVE Vars export HIVE_HOME=&quot;/usr/local/hive&quot; PATH=$PATH:$HIVE_HOME/bin export PATH</p><pre>##HIVE Vars<br>export HIVE_HOME=&quot;/usr/local/hive&quot; <br>PATH=$PATH:$HIVE_HOME/bin <br>export PATH</pre><p>c. Source bash file and test</p><pre>source ~/.bashrc echo $HIVE_HOME</pre><h4>Edit Configurations</h4><pre>sudo nano /usr/local/hive/bin/hive-config.sh</pre><p><em>Write following line in it Above this line &quot;# Default to use 256MB&quot;</em></p><pre>export HADOOP_HOME=/usr/local/hadoop</pre><h4>Create data directory in hive hdfs</h4><pre>hdfs dfs -mkdir -p hdfs://master:9000/usr/hive/warehouse<br>hdfs dfs -chmod g+w hdfs://master:9000/usr/hive/warehouse</pre><h4>Upon some issue while loading data:</h4><p>Double the values in map-reduce configurations</p><pre>sudo nano $HADOOP_INSTALL/etc/mapred-site.xml <br># Change (256-&gt;512 and 412-&gt;824) </pre><h3>Congratulations Hive is installed now :)</h3><p>Run Hive (On Master-Node) by typing following command in terminal:</p><pre>hive</pre><h3>HiveQL</h3><p>Hive Query Language is high-level language more like SQL to get the results from big data. The categorical distribution is as below:</p><p><strong>DDL</strong></p><pre>CREATE DATABASE, CREATE TABLE, ALTER TABLE, SHOW TABLE, DESCRIBE</pre><p><strong>DML</strong></p><pre>LOAD TABLE, INSERT</pre><p><strong>Query</strong></p><pre>SELECT, GROUP BY, JOIN, MULTI TABLE INSERT</pre><p>Now, the first step is to load data into the database for this we have to go through following steps:</p><p><strong>a. Create Database</strong></p><pre>CREATE DATABASE testdb; </pre><p><strong>b. Start using testdb</strong></p><pre>USE testdb;</pre><p><strong>c. Create Schema</strong></p><p>In the stated case, our file with people data looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/0*fLHRUAH1cFFI8v3p." /><figcaption>People Data</figcaption></figure><p>Now we have to create table’s schema against the columns shown above so that we can insert data into the table afterwards.</p><pre>CREATE TABLE people ( name string,country string,city string,mobile_phone string,<br>salary int,age int,gender string,siblings int,marital_status string)<br>ROW FORMAT DELIMITED FIELDS TERMINATED BY &#39;,&#39;<br>tblproperties(“skip.header.line.count”=”1”) ;</pre><p><em>The line with tblproperties is used to skip the headers.</em></p><p><strong>d. Copy files to server</strong></p><p>From local machine copy data to server(master-node):</p><pre>scp -r /people_data hive@master:/home/hive/</pre><p><strong>e. Load Data from files</strong></p><pre>LOAD DATA LOCAL INPATH &#39;/home/hduser1/people_data/*.csv&#39; OVERWRITE INTO TABLE people;</pre><p><em>Note: sample file path goes here.</em> After this step the data will be loaded in the database table people.</p><p><strong>f. Create hive-site.xml</strong></p><p>This is not a mandatory step. You should skip this step. In case you have idea about configurations and it is required then you can create hive-site.xml by executing following command:</p><pre>sudo cp $HIVE_HOME/conf/hive-default.xml.template $HIVE_HOME/conf/hive-site.xml</pre><p>Once the data is loaded you can try out variant queries on top of that. The chart below states all the benchmarks along with there queries. You can try out all of them. I haven’t added the table instead added image so that you type them and know the details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*EMcVlESKJRRmZPtNydKG2A.png" /><figcaption>All queries list along with the benchmarks.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a32eb1cb2466" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting-up Fully Distributed Hadoop Cluster. Series-2 of 3]]></title>
            <link>https://medium.com/@zaman.nuces/setting-up-fully-distributed-hadoop-cluster-series-2-of-3-27b9831c25ae?source=rss-a964c8d29df6------2</link>
            <guid isPermaLink="false">https://medium.com/p/27b9831c25ae</guid>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[apache-hadoop]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[apache-hive]]></category>
            <category><![CDATA[configuration]]></category>
            <dc:creator><![CDATA[Muhammad Zaman]]></dc:creator>
            <pubDate>Tue, 17 Apr 2018 07:23:48 GMT</pubDate>
            <atom:updated>2018-04-17T12:19:02.918Z</atom:updated>
            <content:encoded><![CDATA[<h4>Underlying Cluster for Apache Hive, Apache Spark and Apache HBase</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/410/0*JKahDWVVeD0nXEZx." /><figcaption>Apache Hadoop (Distributed Computing)</figcaption></figure><h3>Apache Hadoop</h3><p>Apache Hadoop is a framework that allows distributed processing for large data sets across clusters of physical machines using simple programing models.</p><h4>Target Audience</h4><p>This blog is from the series of blogs which is mainly for Apache Hive but users who are looking for Hadoop configurations for setting up H-Base Spark on top of it can use this guide.</p><h4>Steps</h4><p>In this blog we are setting up a 4 nodes cluster in which there is 1 master node and there are 3 slave nodes. But user can also create n-nodes cluster too.</p><p>By following three basic steps one can create a fully distributed hadoop cluster:</p><ol><li><strong>Configuring Nodes</strong></li><li><strong>Java Installation</strong></li><li><strong>Password Free SSH</strong></li><li><strong>Hadoop Installation</strong></li></ol><p>In the end we will be <strong>Testing </strong>Hadoop Cluster. There will be in total <strong>18</strong> steps for step no. four stated above which includes Hadoop Installation and testing.</p><h3>Configuring Nodes</h3><p>In this step you will be editing host names of physical machines/nodes so that they can be access by there names. Reboot at the end is a necessary step.</p><h4>1. Editing host-name of all nodes</h4><p>Edit Host-names on all nodes ( the command below will open up the file in terminal and you have to type in host-names as given below)</p><pre>sudo nano /etc/hostname</pre><ul><li><strong>On Master-node write</strong> master</li><li><strong>On First slave-node write</strong> slave1</li><li><strong>On Second slave-node write</strong> slave2</li><li><strong>On Third slave-node write</strong> slave3</li></ul><h4>2. Adding hosts of all nodes</h4><p>Execute the following command and type the lines in the open file.</p><pre>sudo nano /etc/hosts</pre><p>Delete the line with <strong>127.0.1.1</strong> this is the machine IP instead write following lines on all nodes.</p><p><strong>On All Nodes:</strong></p><pre>192.168.0.211    master<br>192.168.0.212    slave1<br>192.168.0.213    slave2<br>192.168.0.214    slave3 </pre><p>Note: IP against each node stated above can be different.</p><h4>3. Reboot System</h4><p>Reboot all nodes by typing following command in terminal:</p><pre>sudo reboot </pre><h3>Java Installation</h3><p>Install Java <strong>on all nodes</strong> by typing the commands given below. We have to set the path once java is installaed.</p><pre>sudo add-apt-repository ppa:webupd8team/java<br>sudo apt-get update<br>sudo apt-get install oracle-java8-installer</pre><p><strong>Check path of Java Installation</strong></p><pre>echo $JAVA_HOME</pre><p>If it turned out to be ‘<em>/usr/lib/jvm/java-8-oracle’</em> environment variable is set aptly. Else set environment variable by following the steps listed below:</p><pre>whereis java <br>#/usr/lib/jvm/java-8-oracle<br>sudo nano ~/.bashrc<br>export HADOOP_INSTALL=/usr/local/hadoop<br>source ~/.bashrc</pre><h3>Create an SSH-password-free connection between all nodes</h3><p><strong>On Master</strong></p><pre>ssh-keygen -b 4096<br>ssh-copy-id -i $HOME/.ssh/id_rsa.pub hive@master</pre><p>Testing: Try accessing the master node from the same node, your entry will be password less</p><p><strong>Note</strong>: The ssh would be password-less i.e. it shouldn’t ask you for password.</p><pre>ssh master <br>exit</pre><p>Copy the public key to all other nodes that are slave nodes by typing below commands in master terminal:</p><pre>ssh-copy-id -i $HOME/.ssh/id_rsa.pub hive@slave1<br>ssh-copy-id -i $HOME/.ssh/id_rsa.pub hive@slave2    <br>ssh-copy-id -i $HOME/.ssh/id_rsa.pub hive@slave3</pre><h3>Hadoop Installation</h3><p>Do following configurations till point#11<strong> On Master-node</strong></p><h4>1. Get package of Hadoop 2.7.3 (Tested working fine with Hive)</h4><pre>wget <a href="https://archive.apache.org/dist/hadoop/core/hadoop-2.7.3/hadoop-2.7.3.tar.gz">https://archive.apache.org/dist/hadoop/core/hadoop-2.7.3/hadoop-2.7.3.tar.gz</a></pre><h4>2. Create directory for Hadoop</h4><pre>sudo mkdir /usr/local/hadoop</pre><h4>3. Untar hadoop file</h4><pre>tar -xzf hadoop-2.7.3.tar.gz</pre><h4>4. Move untared directory to Hadoop Folder</h4><pre>sudo mv hadoop-2.7.3/* /usr/local/hadoop/</pre><h4>5. Check ownership for Hadoop</h4><pre>ls -ltr /usr/local/hadoop/</pre><h4>6. Changing ownership of directory ( hive-&gt; username )</h4><pre>sudo chown -R hive:hive /usr/local/hadoop</pre><h4>7. Setting up environment variables</h4><p><strong><em>a. Open file</em></strong></p><pre>sudo nano ~/.bashrc </pre><p><strong><em>b. Add following content</em></strong></p><pre>################HADOOP VARIABLES########################################<br>export HADOOP_INSTALL=/usr/local/hadoop<br>export PATH=$PATH:$HADOOP_INSTALL/bin<br>export PATH=$PATH:$HADOOP_INSTALL/sbin<br>export HADOOP_MAPRED_HOME=$HADOOP_INSTALL<br>export HADOOP_COMMON_HOME=$HADOOP_INSTALL<br>export HADOOP_HDFS_HOME=$HADOOP_INSTALL<br>export YARN_HOME=$HADOOP_INSTALL<br>export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native<br>export HADOOP_OPTS=&quot;-Djava.library.path=$HADOOP_INSTALL/lib&quot;<br>#HADOOP VARIABLES END</pre><p><strong><em>c. Source the file and test</em></strong></p><pre>source ~/.bashrc<br>echo $JAVA_HOME <br>echo $HADOOP_INSTALL</pre><h4>8. Copy configurations from the hadoop_conf in home (<a href="https://drive.google.com/open?id=1_onAsVZ_2OwwsG4eDAsVKxFLxiws5z7R">All starter-configuration files are available here</a>)</h4><p><strong>There are two ways to edit those configurations</strong></p><blockquote><strong>a. First one is to simply copy configurations downloaded from the </strong><a href="https://drive.google.com/open?id=1_onAsVZ_2OwwsG4eDAsVKxFLxiws5z7R"><strong>link</strong></a></blockquote><pre>sudo cp hadoop_conf/* /usr/local/hadoop/etc/hadoop/ </pre><p><strong>b. Second one is to edit configurations one by one.</strong></p><p>I. Go to the Directory</p><pre>cd /usr/local/hadoop/etc/hadoop/</pre><p>II. Open <strong>Hadoop env</strong> file</p><pre>sudo nano hadoop-env.sh</pre><p>III. Change the <strong>export JAVA_HOME</strong> line to</p><pre>export JAVA_HOME=/usr/lib/jvm/java-8-oracle</pre><p>IV. Open <strong>yarn site</strong> file</p><pre>sudo nano yarn-site.xml</pre><p>V. Add following lines between the configuration tags:</p><pre>&lt;property&gt;<br>    &lt;name&gt;yarn.acl.enable&lt;/name&gt;<br>    &lt;value&gt;0&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>    &lt;name&gt;yarn.resourcemanager.hostname&lt;/name&gt;<br>    &lt;value&gt;master&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>    &lt;name&gt;yarn.nodemanager.aux-services&lt;/name&gt;<br>    &lt;value&gt;mapreduce_shuffle&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>    &lt;name&gt;yarn.nodemanager.resource.memory-mb&lt;/name&gt;<br>    &lt;value&gt;2826&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>    &lt;name&gt;yarn.scheduler.maximum-allocation-mb&lt;/name&gt;<br>    &lt;value&gt;2726&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>    &lt;name&gt;yarn.scheduler.minimum-allocation-mb&lt;/name&gt;<br>    &lt;value&gt;128&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>    &lt;name&gt;yarn.nodemanager.vmem-check-enabled&lt;/name&gt;<br>    &lt;value&gt;false&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>    &lt;name&gt;yarn.nodemanager.resource.cpu-vcores&lt;/name&gt;<br>    &lt;value&gt;2&lt;/value&gt;<br>&lt;/property&gt;</pre><p>VI. Open <strong>core site</strong> file</p><pre>sudo nano core-site.xml</pre><p>VII. Add following lines between the <strong>configuration</strong> tags:</p><pre>&lt;property&gt;<br>    &lt;name&gt;fs.default.name&lt;/name&gt;<br>    &lt;value&gt;hdfs://master:9000&lt;/value&gt;<br>&lt;/property&gt;</pre><p>VIII. Open <strong>hdfs site</strong> file</p><pre>sudo nano hdfs-site.xml</pre><p>IX. Add following lines between the configuration tags:</p><pre>&lt;property&gt;<br>    &lt;name&gt;dfs.replication&lt;/name&gt;<br>    &lt;value&gt;1&lt;/value&gt;<br>    &lt;description&gt;<br>        Default block replication.<br>        The actual number of replications can be specified when the file is created.<br>        The default is used if replication is not specified in create time.<br>    &lt;/description&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>    &lt;name&gt;dfs.namenode.name.dir&lt;/name&gt;<br>    &lt;value&gt;file:/usr/local/hadoop_store/hdfs/namenode&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>    &lt;name&gt;dfs.datanode.data.dir&lt;/name&gt;<br>    &lt;value&gt;file:/usr/local/hadoop_store/hdfs/datanode&lt;/value&gt;<br>&lt;/property&gt;</pre><p>X. Open <strong>map reduce site</strong> file</p><pre>sudo nano hdfs-site.xml</pre><p>XI. Add following lines between the <strong>configuration</strong> tags:</p><pre>&lt;property&gt;<br>    &lt;name&gt;mapreduce.framework.name&lt;/name&gt;<br>    &lt;value&gt;yarn&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>        &lt;name&gt;yarn.app.mapreduce.am.resource.mb&lt;/name&gt;<br>        &lt;value&gt;416&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>        &lt;name&gt;mapreduce.map.memory.mb&lt;/name&gt;<br>        &lt;value&gt;256&lt;/value&gt;<br>&lt;/property&gt;<br>&lt;property&gt;<br>        &lt;name&gt;mapreduce.reduce.memory.mb&lt;/name&gt;<br>        &lt;value&gt;256&lt;/value&gt;<br>&lt;/property&gt;</pre><h4>9. Check whether each file is apt (some material is written between the configuration tag)</h4><pre>cd hadoop_conf/<br>ls<br>cd /usr/local/hadoop/etc/hadoop/<br>sudo nano hadoop-env.sh <br>sudo nano yarn-site.xml <br>sudo nano core-site.xml <br>sudo nano hdfs-site.xml</pre><h4>10. Creating storage points for data-node and name-node</h4><blockquote><strong><em>a. Create Directories</em></strong></blockquote><blockquote>sudo mkdir -p /usr/local/hadoop_store/hdfs/namenode<br>sudo mkdir -p /usr/local/hadoop_store/hdfs/datanode</blockquote><blockquote><strong><em>b. Change ownership: (tell about user-name while ownership explicitly)</em></strong></blockquote><pre>##chown [owner][:[group]] file<br>#hive:hive in below command is equivalent to username:usergroup<br>sudo chown -R hive:hive /usr/local/hadoop_store/</pre><blockquote><strong><em>c. Check ownerships</em></strong></blockquote><pre>ls -ltr /usr/local/hadoop_store/<br>ls -ltr /usr/local/hadoop_store/hdfs/<br>clear</pre><h4>11. Copy hadoop to all slave nodes</h4><pre>scp hadoop-2.7.3.tar.gz hive@slave1:/home/hive/<br>scp hadoop-2.7.3.tar.gz hive@slave2:/home/hive/<br>scp hadoop-2.7.3.tar.gz hive@slave3:/home/hive/</pre><h3>On Slave Nodes</h3><h4>12. Now once the hadoop tar file is available on all slaves as result of action number-11 on master node.</h4><blockquote><strong><em>a. Create directory for Hadoop</em></strong></blockquote><pre>sudo mkdir /usr/local/hadoop</pre><blockquote><strong><em>b. Untar hadoop file</em></strong></blockquote><pre>tar -xzf hadoop-2.7.3.tar.gz</pre><blockquote><strong><em>c. Move untared directory to Hadoop Folder</em></strong></blockquote><pre>sudo mv hadoop-2.7.3/* /usr/local/hadoop/</pre><blockquote><strong><em>d. Check ownership for Hadoop</em></strong></blockquote><pre>ls -ltr /usr/local/hadoop/</pre><blockquote><strong><em>e. Changing ownership of directory ( hive-&gt; username )</em></strong></blockquote><pre>##chown [owner][:[group]] file<br>#hive:hive in is equivalent to username:usergroup<br>sudo chown -R hive:hive /usr/local/hadoop</pre><h4>13. Setting up environment variables</h4><blockquote><strong><em>a. Open file</em></strong></blockquote><pre>sudo nano ~/.bashrc</pre><blockquote><strong><em>b. Add following content</em></strong></blockquote><pre>################HADOOP VARIABLES########################################<br>export HADOOP_INSTALL=/usr/local/hadoop<br>export PATH=$PATH:$HADOOP_INSTALL/bin<br>export PATH=$PATH:$HADOOP_INSTALL/sbin<br>export HADOOP_MAPRED_HOME=$HADOOP_INSTALL<br>export HADOOP_COMMON_HOME=$HADOOP_INSTALL<br>export HADOOP_HDFS_HOME=$HADOOP_INSTALL<br>export YARN_HOME=$HADOOP_INSTALL<br>export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native<br>export HADOOP_OPTS=&quot;-Djava.library.path=$HADOOP_INSTALL/lib&quot;<br>#HADOOP VARIABLES END</pre><blockquote><strong><em>c. Source the file and test</em></strong></blockquote><pre>source ~/.bashrc<br>echo $JAVA_HOME <br>echo $HADOOP_INSTALL</pre><h4>14. Creating storage points for data-node and name-node</h4><blockquote><strong><em>a. Create Directories</em></strong></blockquote><pre>sudo mkdir -p /usr/local/hadoop_store/hdfs/namenode<br>sudo mkdir -p /usr/local/hadoop_store/hdfs/datanode</pre><blockquote><strong><em>b. Change ownership: (tell about user-name while ownership explicitly)</em></strong></blockquote><pre>##chown [owner][:[group]] file<br>#hive:hive in below command is equivalent to username:usergroup<br>sudo chown -R hive:hive /usr/local/hadoop_store/</pre><blockquote><strong><em>c. Check ownerships</em></strong></blockquote><pre>ls -ltr /usr/local/hadoop_store/<br>ls -ltr /usr/local/hadoop_store/hdfs/<br>clear</pre><h3>On Master-Node</h3><h4>15. Copy configurations on all slave nodes</h4><pre>scp /usr/local/hadoop/etc/hadoop/* hive@slave1:/usr/local/hadoop/etc/hadoop/<br>scp /usr/local/hadoop/etc/hadoop/* hive@slave2:/usr/local/hadoop/etc/hadoop/<br>scp /usr/local/hadoop/etc/hadoop/* hive@slave3:/usr/local/hadoop/etc/hadoop/</pre><h4>16. Create a slaves file and write all slaves names in it</h4><blockquote><strong><em>a. Open File</em></strong></blockquote><pre>sudo nano /usr/local/hadoop/etc/hadoop/slaves</pre><blockquote><strong><em>b. Add following lines to it</em></strong></blockquote><pre>slave1<br>slave2<br>slave3</pre><h3>:) Hurray Hadoop exhaustive configurations ended here.</h3><h3>17. Now it’s time to test HDFS (On-Master-Node)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/0*AUN_bphE8VUQxYT0.png" /><figcaption>HDFS Description</figcaption></figure><p>a. Format HDFS (Master-node-only)</p><pre>hdfs namenode -format</pre><p>b. Starting HDFS (Master-node-only)</p><pre>start-dfs.sh</pre><p>c. View Java Processes (Master-node-only)</p><pre>jps</pre><p>c.1. Check via Terminal (On-all-nodes)</p><blockquote><strong><em>On Master (Node manager)<br></em></strong><em>14848 Jps <br>14157 NameNode <br>14382 SecondaryNameNode</em></blockquote><blockquote><strong><em>On Slaves (Data node)<br></em></strong><em>29754 DataNode <br>29837 Jps</em></blockquote><blockquote><strong>Note:</strong> PID (Process ID) can be different.</blockquote><p>c.2. Check via Portal</p><blockquote>Since ‘192.168.0.211’ master’s IP <a href="http://192.168.0.211:50070/explorer.html#/">http://192.168.0.211:50070/explorer.html#/</a></blockquote><blockquote>Note all the datanodes are listed in this portal <a href="http://192.168.0.211:50070/dfshealth.html#tab-datanode">http://192.168.0.211:50070/dfshealth.html#tab-datanode</a></blockquote><p>d. Starting Resource Manager( Master-node-only)</p><pre>start-yarn.sh</pre><p>e. View Java Processes (On-all-nodes)</p><pre>jps</pre><p>e.1. Check via Terminal</p><blockquote><strong><em>On Master (Node manager)<br></em></strong><em>14934 ResourceManager <br>15277 Jps <br>14157 NameNode <br>14382 SecondaryNameNode</em></blockquote><blockquote><strong><em>On Slaves (Data node)<br></em></strong><em>30199 Jps <br>29754 DataNode <br>30091 NodeManager</em></blockquote><blockquote><strong>Note:</strong> PID (Process ID) can be different.</blockquote><p>e.2. Check via Portal</p><blockquote><a href="http://master_ip:8088/cluster">http://master_ip:8088/cluster</a> (Example in our case ‘192.168.0.211’ master’s IP So type <a href="http://192.168.0.211:8088/cluster">http://192.168.0.211:8088/cluster</a> in browser)</blockquote><blockquote>Note all the data-nodes are listed in this portal <a href="http://192.168.0.211:8088/cluster/nodes">http://192.168.0.211:8088/cluster/nodes</a></blockquote><p>f. Get Data to load in HDFS</p><pre>mkdir sample_data<br>cd sample_data/<br>wget -O alice.txt https://www.gutenberg.org/files/11/11-0.txt<br>cd ~</pre><p>g. Check HDFS-files list</p><pre>hdfs dfs -ls hdfs://master:9000/</pre><p>h. Load data in HDFS</p><pre>clear<br>hadoop fs -copyFromLocal sample_data/alice.txt hdfs://master:9000/</pre><p>i. Check HDFS-files list</p><pre>hdfs dfs -ls hdfs://master:9000/</pre><p>j. Clear terminal</p><pre>clear</pre><p>Note: If there is an issue in data-node that will be most probably due to mis-matching Cluster-ID. See logs and match the issue stated in: <a href="https://stackoverflow.com/questions/22316187/datanode-not-starts-correctly">datanode-not-starts-correctly</a></p><h3>18. HDFS (working fine) Now it’s time to test Yarn</h3><blockquote><strong><em>a. Run following command.</em></strong><em> (On-master-only)</em></blockquote><pre>yarn jar /usr/local/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount &quot;hdfs://master:9000/alice.txt&quot; hdfs://master:9000/output/</pre><blockquote>It will run some map-reduce jobs.<br><strong><em>b. Now check output in HDFS.</em></strong><em> (On-master-only)</em></blockquote><pre>hdfs dfs -ls hdfs://master:9000/output/<br>hdfs dfs -cat hdfs://master:9000/output/part-r-00000</pre><blockquote>You will get outputs as counts against each word<br><strong><em>c. Clear terminal</em></strong></blockquote><pre>clear </pre><h3>Congrats Hadoop is Working Fine now.</h3><p>Let’s place a cherry ‘<strong>Hive</strong>’ on top of the fully baked cake ‘<strong>Hadoop</strong>’ <a href="https://medium.com/@zaman.nuces/installation-apache-hive-series-3-of-3-a32eb1cb2466">Installing Hive on top of Hadoop Cluster</a></p><h3>References</h3><ul><li><a href="https://linode.com/docs/databases/hadoop/how-to-install-and-set-up-hadoop-cluster/">Cluster Guide</a></li><li><a href="https://www.digitalocean.com/community/tutorials/how-to-install-hadoop-in-stand-alone-mode-on-ubuntu-16-04#step-4-%E2%80%94-running-hadoop">Hadoop Standalone</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27b9831c25ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Hive (A Complete Journey) Series-1 of 3]]></title>
            <link>https://medium.com/@zaman.nuces/apache-hive-a-brief-introduction-series-1-of-3-54ec07753dd2?source=rss-a964c8d29df6------2</link>
            <guid isPermaLink="false">https://medium.com/p/54ec07753dd2</guid>
            <category><![CDATA[apache-hive]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[hive]]></category>
            <category><![CDATA[hadoop-cluster]]></category>
            <category><![CDATA[apache]]></category>
            <dc:creator><![CDATA[Muhammad Zaman]]></dc:creator>
            <pubDate>Mon, 16 Apr 2018 08:56:58 GMT</pubDate>
            <atom:updated>2018-04-17T07:29:25.283Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/377/0*7AwEi1HD0x_93PZD.png" /><figcaption>Apache Hive</figcaption></figure><h3>Apache Hive</h3><p>The Apache Hive ™ data warehouse software facilitates reading, writing, and managing large datasets residing in distributed storage using SQL (Standard Query Language).</p><h3>Where does Hive Fall in the Stack?</h3><p>From the figure below, we can see that Hive is more of an abstraction layer lying on top of YARN Map-Reduce 2. Moreover, note that Hive and Pig lie in same horizontal stack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/0*LvdCbMYKq7X0Uvm_.jpg" /></figure><h3>Architecture</h3><p>As we see that Hive is an abstraction on top of Hadoop Map-Reduce jobs. So the underlying structure is same i.e. Hive run on top of Hadoop.<br>So, Hive mainly consists of two components i.e. <strong>Hive</strong> and <strong>Hadoop.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/0*eASHU8Mtg2wLnmbK." /></figure><h4>Hadoop Components</h4><p>Hadoop Key components are <strong>Yarn </strong>and <strong>HDFS. </strong>Yarn is the resource manager, whereas HDFS is the distributed file system of Hadoop.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/0*KUGHx_sMuS2ipYy4.png" /></figure><p>The picture is showing how data is distributed in different nodes.</p><h4>Hive Components</h4><ul><li>External Interfaces- CLI, WebUI, JDBC, ODBC programming interfaces</li><li>Thrift Server — Cross Language service framework .</li><li>Metastore — Meta data about the Hive tables, partitions</li><li>Driver — Brain of Hive! Compiler, Optimizer and Execution engine</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/832/0*HI8XXdg45BvK5xYo." /></figure><h3>Hive Importance</h3><h4>Data Analysts with Hadoop (Uncomfortable)</h4><p>Mostly Data analysts feel uncomfortable while working on Hadoop due to the coding nature of Hadooop (Since for each analysis you have to write customize map-reduce jobs).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*SrAaAaXVq4-yVF-9." /></figure><h4>Limitations of Hadoop</h4><p>The biggest limitation of Hadoop is that one have to use M/R model (Map-Reduce Model). Other limitations are as stated below:<br>* Not Reusable<br>* Error prone<br>* Multiple stage of Map/Reduce functions for complex jobs. <br>*It’s just like asking a developer to write physical execution plan in the DB.</p><h3>Hive Data Model</h3><ul><li>Tables</li><li>Partitions</li><li>Buckets</li></ul><h4>Tables</h4><p>Analogous to relational tables. Each table has a corresponding directory in HDFS. Data serialized and stored as files within that directory.</p><h4>Partitions</h4><p>Each table can be broken into partitions. Partitions determine distribution of data within subdirectories. <br><strong>Example</strong></p><pre>CREATE_TABLE Sales (sale_id INT, amount FLOAT)<br>PARTITIONED BY (country STRING, year INT, month INT) </pre><p><em>So each partition will split out into different folders like:</em></p><pre>Sales/country=US/year=2012/month=12</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jr3r9gs9vrgWokm_." /></figure><h4>Buckets</h4><p>Data in each partition divided into buckets based on a hash function of the column. Each bucket is stored as a file in partition directory.<br><em>Example:</em><br>H(column) mod NumBuckets = bucket number</p><p>H(column) mod NumBuckets = bucket number</p><p>Comparison between Hive and Pig since they both fall in same horizontal block of the stack.</p><h4>Similarities</h4><p>Both High level Languages which work on top of map-reduce framework. Since, both use the underlying HDFS and map-reduce they both can coexist.</p><h4>Differences</h4><ol><li><strong>Language<br></strong>Pig — is a procedural ; (A = load ‘mydata’; dump A)<br>Hive — is Declarative (select * from A)</li><li><strong>Work Type<br></strong>Pig — more suited for ad hoc analysis (on demand analysis of click stream search logs)<br>Hive — a reporting tool (e.g. weekly BI reporting)</li><li><strong>Users<br></strong>Pig — Researchers, Programmers (build complex data pipelines, machine learning)<br>Hive — Business Analysts</li><li><strong>Integration<br></strong>Pig — Doesn’t have a thrift server(i.e no/limited cross language support)<br>Hive — Thrift Server</li><li><strong>User’s Need<br></strong>Pig — Better development environments, debuggers expected<br>Hive — Better integration with technologies expected(e.g JDBC, ODBC)</li></ol><h3>Hive Pros, Cons and Improvements</h3><ul><li>Boon for Data Analysts</li><li>Easy Learning curve</li><li>Completely transparent to underlying Map-Reduce</li><li>Partitions(speed!)</li><li>Flexibility to load data from localFS/HDFS into Hive Tables</li><li>Extending the SQL queries support(Updates, Deletes)</li><li>Better debug support in shell</li></ul><blockquote><strong>Where Hive is useful?<br></strong><em>Wherever Batch-processing is involved </em>like: Log processing, Text-Mining, Document-indexing, Customer Facing BI,and Predictive Modeling.</blockquote><blockquote><strong>Where ain’t useful?<br></strong>Wherever Online processing involved like: OLTP and Real-time Queries.</blockquote><p>Thank you for reading the introductory blog for Apache Hive. Now if you want to try it out. Let’s start with configuring Hadoop first. <br>Continue to <a href="https://medium.com/@zaman.nuces/setting-up-fully-distributed-hadoop-cluster-series-2-of-3-27b9831c25ae"><strong>Series Part 2 of 3</strong></a><strong>.</strong></p><h3>Configuration Setup</h3><ul><li>YARN, Zookeeper, HDFS, Hadoop, Hive <a href="https://medium.com/@zaman.nuces/setting-up-fully-distributed-hadoop-cluster-series-2-of-3-27b9831c25ae">Hadoop Blog Link</a></li><li><a href="https://hub.docker.com/r/mcapitanio/hive/">Docker Image</a></li><li>Distributed Setup (single node OR all) <a href="https://medium.com/@zaman.nuces/setting-up-fully-distributed-hadoop-cluster-series-2-of-3-27b9831c25ae">Hadoop Blog Link</a></li><li>Hive Installation <a href="https://medium.com/@zaman.nuces/setting-up-fully-distributed-hadoop-cluster-series-2-of-3-27b9831c25ae">Hive Installation Blog Link</a></li></ul><h3>References</h3><ul><li><a href="https://baondp.wordpress.com/2015/10/13/build-hadoophive-developmentlearning-environment-on-docker/">Hadoop Hive Docker</a></li><li><a href="https://linode.com/docs/databases/hadoop/how-to-install-and-set-up-hadoop-cluster/">Cluster Guide</a></li><li><a href="https://docs.treasuredata.com/articles/performance-tuning">Hive performance guide</a></li><li><a href="https://stackoverflow.com/questions/19311193/why-is-countdistinct-slower-than-group-by-in-hive">SQL tricks HiveQL</a></li><li><a href="https://docs.google.com/presentation/d/1MAOO176AR287OKFYWDbsBjFJOZWzGkxgqd1Zjtfmakk/edit?usp=sharing">Slides Hive Overview</a></li><li><a href="https://www.digitalocean.com/community/tutorials/how-to-install-hadoop-in-stand-alone-mode-on-ubuntu-16-04#step-4-%E2%80%94-running-hadoop">Hadoop Standalone</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54ec07753dd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>