Install Hadoop on Docker

  • Get Ubuntu Docker

    – docker pull ubuntu

  • Start Container
docker run -i -p 22 -p 8000:80 -m /data:/data -t <ubuntu> /bin/bash
  • Install Jdk
    sudo add-apt-repository ppa:openjdk-r/ppa  
    sudo apt-get update   
    sudo apt-get install openjdk-7-jre
  • .bashrc
    export JAVA_HOME=/usr/lib/jvm/...
    export CLASSPATH=$JAVA_HOME/lib/*:.
    export PATH=$PATH:$JAVA_HOME/bin
    
  • HADOOP 1.2.1 install

    download hadoop and unpack

    root@4aa2cda88fcc:/home/kim# wget http://apache.mirror.cdnetworks.com/hadoop/common/hadoop-1.2.1/hadoop-1.2.1.tar.gz
    root@4aa2cda88fcc:/home/kim# mv ./hadoop-1.2.1.tar.gz /home/user
    root@4aa2cda88fcc:/home/kim# tar xvzf hadoop-1.2.1.tar.gz
  • SET Configuration

    set configuration on ~/.bashrc

export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
export CLASSPATH=$JAVA_HOME/lib/*:.
export PATH=$PATH:$JAVA_HOME/bin
export HADOOP_HOME=/home/kim/hadoop-1.2.1
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
  • set HADOOP conf
vi  /home/hadoop-1.2.1/conf/hadoop-env.sh
export JAVA_HOME=/usr/lib/jvm/java-7-oracle
vi mapred-site.xml

<configuration>
 <property>
  <name>mapred.job.tracker</name>
  <value>localhost:9001</value>
 </property>
</configuration>
vi hdfs-site.xml


<configuration>
 <property>
  <name>dfs.replication</name>
  <value>1</value>
 </property>
</configuration>
vi core-site.xml


<configuration>
 <property>
  <name>fs.default.name</name>
  <value>hdfs://4aa2cda88fcc:9000</value>
 </property>
 <property>
  <name>hadoop.tmp.dir</name>
  <value>/home/kim/temp</value>
 </property>
</configuration>
  • SET SSH
# apt-get install openssh-server
# ssh-keygen -t dsa -P "" -f ~/.ssh/id_dsa
# cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
# vi /etc/ssh/sshd_config 
# ==> PermitRootLogin yes
service ssh restart
# ssh localhost
  • Format namenode
hadoop namenode -format
  •  start & stop Shell script
start-all.sh  (start-dfs.sh + start-mapred.sh) 

# check java apllication is running 
jps 

stop-all.sh
  • search hadoop files
hadoop fs -ls /
  • upload local file to hadoop
hadoop fs -copyFromLocal README.txt /
  • Execute word count
hadoop jar hadoop-examples-1.2.1.jar wordcount /README.txt /output_wordcount

working on find way to use “docker exec -ti containername sh"

Leave a Reply

Your email address will not be published. Required fields are marked *