Git Product home page Git Product logo

hadoop's Introduction


Anagram Sorter (Python + Hadoop)

Sharif University Of Technology

Green Computing Final Project Spring 2017


Requirements

Install Hadoop

  1. Install Java
    • sudo apt-get update
    • sudo apt-get install default-jdk
  2. Add User
    • sudo addgroup hadoop
    • sudo adduser --ingroup hadoop username
    • sudo adduser username sudo
  3. Install And Config SSH
    • sudo apt-get install ssh
    • su username
    • ssh-keygen -t rsa -P ""
    • cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
  4. Install Hadoop
  5. Setup Configuration Files
    • update-alternatives --config java
    • nano ~/.bashrc and append this items
      • export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
      • export HADOOP_INSTALL=/usr/local/hadoop
      • export PATH=$PATH:$HADOOP_INSTALL/bin
      • export PATH=$PATH:$HADOOP_INSTALL/sbin
      • export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
      • export HADOOP_COMMON_HOME=$HADOOP_INSTALL
      • export HADOOP_HDFS_HOME=$HADOOP_INSTALL
      • export YARN_HOME=$HADOOP_INSTALL
      • export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
      • export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib" and save file
    • source ~/.bashrc
    • nano /usr/local/hadoop/etc/hadoop/hadoop-env.sh append this line
      • export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
    • sudo mkdir -p /app/hadoop/tmp
    • sudo chown username:hadoop /app/hadoop/tmp
    • nano /usr/local/hadoop/etc/hadoop/core-site.xml enter the following in between the tag
      •   	<property>
          	<name>hadoop.tmp.dir</name>
          	<value>/app/hadoop/tmp</value>
          	<description>A base for other temporary directories.</description>
          	</property>
        
          	<property>
          	<name>fs.default.name</name>
          	<value>hdfs://localhost:54310</value>
          	<description>The name of the default file system.  A URI whose
          	scheme and authority determine the FileSystem implementation.  The
          	uri's scheme determines the config property (fs.SCHEME.impl) naming
          	the FileSystem implementation class.  The uri's authority is used to
          	determine the host, port, etc. for a filesystem.</description>
          	</property>
          	</configuration> ```
        
    • cp /usr/local/hadoop/etc/hadoop/mapred-site.xml.template /usr/local/hadoop/etc/hadoop/mapred-site.xml
    • nano /usr/local/hadoop/etc/hadoop/mapred-site.xml enter the following in between the tag
      •   <property>
          <name>mapred.job.tracker</name>
          <value>localhost:54311</value>
          <description>The host and port that the MapReduce job tracker runs
          at.  If "local", then jobs are run in-process as a single map
          and reduce task.
          </description>
          </property>
          </configuration> ```
        
    • sudo mkdir -p /usr/local/hadoop_store/hdfs/namenode
    • sudo mkdir -p /usr/local/hadoop_store/hdfs/datanode
    • sudo chown -R username:hadoop /usr/local/hadoop_store
    • nano /usr/local/hadoop/etc/hadoop/hdfs-site.xml enter the following in between the tag
      •   <property>
          <name>dfs.replication</name>
          <value>1</value>
          <description>Default block replication.
          The actual number of replications can be specified when the file is created.
          The default is used if replication is not specified in create time.
          </description>
          </property>
          <property>
          <name>dfs.namenode.name.dir</name>
          <value>file:/usr/local/hadoop_store/hdfs/namenode</value>
          </property>
          <property>
          <name>dfs.datanode.data.dir</name>
          <value>file:/usr/local/hadoop_store/hdfs/datanode</value>
          </property>
          </configuration>```
        
  6. Start Hadoop

Clone Repo

  • cd /home/username
  • git clone https://github.com/sepandhaghighi/hadoop
  • chmod -R 777 /home/username/hadoop

HDFS Commands

  1. Add input to filesystem --> hadoop fs -put inputfile inputfile
  2. Read output file --> hadoop fs -cat /output/part-00000
  3. Copy output file --> hadoop fs -get /output/part-00000 /home/username/hadoop/output.txt
  4. Remove output folder --> hadoop fs -rmr /output/

Run Map/Reduce

hadoop jar /usr/local/hadoop/share/hadoop/tools/lib/hadoop-streaming-2.8.0.jar -input input.txt -mapper /home/hduser/hadoop/mapper.py -reducer /home/hduser/hadoop/reducer.py -output /output

Samples & Screenshots

Download Run Full Video 43MB ( This video recorded by simplescreenrecorder )

Input.txt and output.txt in data folder

Input file

Output file

Screenshot 1

Screenshot 2

Screenshot 3

hadoop's People

Contributors

sepandhaghighi avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.