Install oozie 4.3.0

Install oozie 4.3.0

wget http://www-us.apache.org/dist/hadoop/common/hadoop-2.7.3/hadoop-2.7.3.tar.gz

tar -xvf hadoop-2.7.3.tar.gz

cd hadoop-2.7.3/
vim etc/hadoop/core-site.xml

fs.defaultFS
hdfs://localhost:9000

vim etc/hadoop/hdfs-site.xml

dfs.replication
1

dfs.namenode.name.dir
file:///home/your_user_name/data/hadoop/

sudo apt-get install openssh-server
ssh-keygen -t rsa -P ” -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
chmod 0600 ~/.ssh/authorized_keys

vim etc/hadoop/hadoop-env.sh
export JAVA_HOME=/opt/jdk

bin/hdfs namenode -forma
sbin/start-dfs.sh

wget http://www-eu.apache.org/dist/oozie/4.3.0/oozie-4.3.0.tar.gz

tar -xvf oozie-4.3.0.tar.gz

cd oozie-4.3.0

./bin/mkdistro.sh -P hadoop-2 -DskipTests

cp -R distro/target/oozie-4.3.0-distro/oozie-4.3.0/ ../oozie

cd ../oozie

mkdir libext
cd libext
wget http://extjs.com/deploy/ext-2.2.zip
cd ..

cp $HADOOP_HOME/share/hadoop/**/*.jar libext/
cp $HADOOP_HOME/share/hadoop/common/*.jar libext/
cp $HADOOP_HOME/share/hadoop/common/lib/*.jar libext/
cp $HADOOP_HOME/share/hadoop/hdfs/lib/*.jar libext/
cp $HADOOP_HOME/share/hadoop/hdfs/*.jar libext/
cp $HADOOP_HOME/share/hadoop/mapreduce/*.jar libext/
cp $HADOOP_HOME/share/hadoop/mapreduce/lib/*.jar libext/
cp $HADOOP_HOME/share/hadoop/yarn/lib/*.jar libext/
cp $HADOOP_HOME/share/hadoop/yarn/*.jar libext/

./bin/oozie-setup.sh prepare-war

vim $HADOOP_HOME/etc/hadoop/core-site.xml

hadoop.proxyuser.your_user_name.hosts
*

hadoop.proxyuser.your_user_name.groups
*

$HADOOP_HOME/sbin/stop-dfs.sh
$HADOOP_HOME/sbin/start-dfs.sh

./bin/oozie-setup.sh sharelib create -fs hdfs://localhost:9000

./bin/ooziedb.sh create -sqlfile oozie.sql -run

vim conf/oozie-site.xml

oozie.service.WorkflowAppService.system.libpath
/user/your_user_name/share/lib/

oozie.service.HadoopAccessorService.hadoop.configurations
*=$HAOOP_HOME/etc/hadoop/

./bin/oozied.sh start

tar -xvf oozie-examples.tar.gz

vim examples/apps/map-reduce/job.properties
nameNode=hdfs://localhost:9000
jobTracker=localhost:10020
oozie.use.system.libpath=true

hadoop fs -put examples hdfs://localhost:9000/user/your_username/examples

$HADOOP_HOME/sbin/mr-jobhistory-daemon.sh –config $HADOOP_CONF_DIR start historyserver

jps

./bin/oozie job -oozie http://localhost:11000/oozie -config examples/apps/map-reduce/job.properties -run

./bin/oozie job -oozie http://localhost:11000/oozie -info 0000000-170408113318091-oozie-fars-W
./bin/oozie job -oozie http://localhost:11000/oozie -log 0000000-170408113318091-oozie-fars-W

WrodCount MapReduce with Scalding

git clone https://github.com/scalding-io/ProgrammingWithScalding

cd ProgrammingWithScalding/chapter2/

mvn clean install

hadoop fs -mkdir -p /data/input

hadoop fs -mkdir -p /data/output

echo “This is a happy day. A day to remember” > /tmp/input.txt

hadoop fs -put /tmp/input.txt /data/input

hadoop jar /root/repo/ProgrammingWithScalding/chapter2/target/chapter2-0-jar-with-dependencies.jar com.twitter.scalding.Tool WordCountJob –local –input /data/input/input.txt –output /data/output/output.txt

cat /data/output/output.txt
a 2
day 1
day. 1
happy 1
is 1
remember 1
this 1
to 1

Run Wordcount Mapreduce Example with YARN

// download hadoop-2.6.3.tar.gz
tar -xvf ~/Downloads/hadoop-2.6.3.tar.gz -C ~/opt/
cd ~/opt/hadoop-2.6.3
ssh-keygen
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys

mkdir -p /disk1/hdfs/name
mkdir -p /remote/hdfs/name
mkdir -p /disk1/hdfs/data
mkdir -p /disk2/hdfs/data
mkdir -p /disk1/hdfs/namesecondary
mkdir -p /disk2/hdfs/namesecondary
mkdir -p /disk1/nm-local-dir
mkdir -p /disk2/nm-local-dir

vim etc/hadoop/core-site.xml

<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost/</value>
</property>
</configuration>

vim etc/hadoop/hdfs-site.xml
<configuration>
<property>
<name>dfs.namenode.name.dir</name>
<value>/disk1/hdfs/name,/remote/hdfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/disk1/hdfs/data,/disk2/hdfs/data</value>
</property>
<property> <name>dfs.namenode.checkpoint.dir</name>
<value>/disk1/hdfs/namesecondary,/disk2/hdfs/namesecondary</value>
</property>
</configuration>

vim etc/hadoop/yarn-site.xml

<configuration>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>localhost</value>
</property>
<property>
<name>yarn.nodemanager.local-dirs</name>
<value>/disk1/nm-local-dir,/disk2/nm-local-dir</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
<property>
<name>yarn.nodemanager.resource.memory-mb</name>
<value>16384</value>
</property>
<property>
<name>yarn.nodemanager.resource.cpu-vcores</name>
<value>16</value>
</property>
<property>
<name>yarn.scheduler.capacity.maximum-am-resource-percent</name>
<value>100</value>
</property>

<property>
<name>yarn.scheduler.minimum-allocation-mb</name>
<value>1228</value>
</property>
<property>
<name>yarn.scheduler.maximum-allocation-mb</name>
<value>9830</value>
</property>
<property>
<name>yarn.nodemanager.resource.memory-mb</name>
<value>9830</value>
</property>

</configuration>

cp etc/hadoop/mapred-site.xml.template etc/hadoop/mapred-site.xml

vim etc/hadoop/mapred-site.xml

<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>

<property>
<name>yarn.app.mapreduce.am.resource.mb</name>
<value>1228</value>
</property>
<property>
<name>yarn.app.mapreduce.am.command-opts</name>
<value>-Xmx983m</value>
</property>
<property>
<name>mapreduce.map.memory.mb</name>
<value>1228</value>
</property>
<property>
<name>mapreduce.reduce.memory.mb</name>
<value>1228</value>
</property>
<property>
<name>mapreduce.map.java.opts</name>
<value>-Xmx983m</value>
</property>
<property>
<name>mapreduce.reduce.java.opts</name>
<value>-Xmx983m</value>
</property>

</configuration>

vim etc/hadoop/hadoop-env.sh

export JAVA_HOME=/opt/jdk

./bin/hdfs namenode -format mycluster
./sbin/start-dfs.sh
./sbin/start-yarn.sh
./bin/hadoop dfs -mkdir -p hdfs://localhost/wc/in
echo “Hello world, Hello” > /tmp/input.txt
./bin/hadoop dfs -copyFromLocal /tmp/inout.txt hdfs://localhost/wc/in
./bin/hadoop jar ./share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.3.jar wordcount hdfs://localhost/wc/in hdfs://localhost/wc/out

Unit Test for WrodCount MapReduce


import java.io.IOException;
import java.util.Arrays;

import org.apache.hadoop.io.*;
import org.apache.hadoop.mrunit.mapreduce.MapDriver;
import org.apache.hadoop.mrunit.mapreduce.ReduceDriver;
import org.junit.*;

public class WordCountTest {

@Test
public void mapperTest() throws IOException, InterruptedException {
Text value = new Text("Hello");
new MapDriver().withMapper(new TokenizerMapper())
.withInput(new IntWritable(), value).withOutput(new Text("Hello"), new IntWritable(1)).runTest();
}

@Test
public void reducerTest() throws IOException, InterruptedException {
new ReduceDriver().withReducer(new IntSumReducer())
.withInput(new Text("Hello"), Arrays.asList(new IntWritable(1), new IntWritable(1)))
.withOutput(new Text("Hello"), new IntWritable(2)).runTest();
}
}

Hcatalog + Pig


$DERBY_HOME/bin/startNetworkServer

$HADOOP_HOME/sbin$ ./start-all.sh

$HIVE_HOME/bin/hiveserver2

$HIVE_HOME/bin/hive --service metastore

$HADOOP_HOME/bin/hadoop fs -mkdir hdfs://localhost/hcatalog-example

$HADOOP_HOME/bin/hadoop fs -put /tmp/test-dataset.csv hdfs://localhost/hcatalog-example

$HADOOP_HOME/bin/hadoop fs -cat hdfs://localhost/hcatalog-example/test-dataset.csv | head -n 4

playerID,yearID,gameNum,gameID,teamID,lgID,GP,startingPos
aaronha01,1955,0,NLS195507120,ML1,NL,1,
aaronha01,1956,0,ALS195607100,ML1,NL,1,
aaronha01,1957,0,NLS195707090,ML1,NL,1,9

./hcat -e "CREATE TABLE default.gamedataset (playerID STRING,yearID INT,gameNum INT ,gameID STRING ,teamID STRING ,lgID STRING ,GP INT,startingPosts INT) PARTITIONED BY (country STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY ',';"

./hcat -e "alter table default.gamedataset add partition (country='DE') location '/hcatalog-example/'"

vim $PIG_HOME/conf/pig.properties

pig.load.default.statements=/opt/pig-0.15.0/.pigbootup

vim $PIG_HOME/.pigbootup

REGISTER /opt/apache-hive-1.2.1-bin/hcatalog/share/hcatalog/hcatalog-core-1.2.1.jar;
REGISTER /opt/apache-hive-1.2.1-bin/lib/hive-exec-1.2.1.jar;
REGISTER /opt/apache-hive-1.2.1-bin/lib/hive-metastore-1.2.1.jar;

vim $HOME/.bashrc

export PIG_OPTS=-Dhive.metastore.uris=thrift://localhost:9083
export PIG_CLASSPATH=$HCAT_HOME/share/hcatalog/*:$HIVE_HOME/lib/*

$PIG_HOME/bin/pig -useHCatalog

A = load 'default.gamedataset' using org.apache.hive.hcatalog.pig.HCatLoader();
dump A;

Install Apache Hive


tar -xvf db-derby-10.11.1.1-bin.tar.gz
tar -xvf apache-hive-1.2.1-bin.tar.gz
vim ~/.bashrc

export HADOOP_HOME=/opt/hadoop-2.6.2
export DERBY_HOME=/opt/db-derby-10.11.1.1-bin
export PATH=$PATH:$DERBY_HOME/bin
export CLASSPATH=$CLASSPATH:$DERBY_HOME/lib/derby.jar:$DERBY_HOME/lib/derbytools.jar
export HIVE_HOME=/opt/apache-hive-1.2.1-bin

mkdir $DERBY_HOME/data
cp $HIVE_HOME/conf/hive-default.xml.template $HIVE_HOME/conf/hive-site.xml
vim $HIVE_HOME/conf/hive-site.xml

< configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:derby://localhost:1527/metastore_db;create=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
</configuration>

vim $HIVE_HOME/conf/jpox.properties

javax.jdo.PersistenceManagerFactoryClass =
org.jpox.PersistenceManagerFactoryImpl
org.jpox.autoCreateSchema = false
org.jpox.validateTables = false
org.jpox.validateColumns = false
org.jpox.validateConstraints = false
org.jpox.storeManagerType = rdbms
org.jpox.autoCreateSchema = true
org.jpox.autoStartMechanismMode = checked
org.jpox.transactionIsolation = read_committed
javax.jdo.option.DetachAllOnCommit = true
javax.jdo.option.NontransactionalRead = true
javax.jdo.option.ConnectionDriverName = org.apache.derby.jdbc.ClientDriver
javax.jdo.option.ConnectionURL = jdbc:derby://localhost:1527/metastore_db;create = true
javax.jdo.option.ConnectionUserName = APP
javax.jdo.option.ConnectionPassword = mine

$DERBY_HOME/bin/startNetworkServer

$HADOOP_HOME/sbin$ ./start-all.sh

$HADOOP_HOME/bin/hadoop fs -mkdir /tmp
$HADOOP_HOME/bin/hadoop fs -mkdir /user/hive/warehouse
$HADOOP_HOME/bin/hadoop fs -chmod g+w /tmp
$HADOOP_HOME/bin/hadoop fs -chmod g+w /user/hive/warehouse

cp $DERBY_HOME/lib/derbyclient.jar $HIVE_HOME/lib/

$HIVE_HOME/bin/hiveserver2

$HIVE_HOME/bin/hive --service metastore

$HIVE_HOME/bin$ ./beeline
Beeline version 1.2.1 by Apache Hive
beeline: !connect jdbc:hive2://localhost:10000/default "hive" ""
Connecting to jdbc:hive2://localhost:10000/default
Connected to: Apache Hive (version 1.2.1)
Driver: Hive JDBC (version 1.2.1)
Transaction isolation: TRANSACTION_REPEATABLE_READ
0: jdbc:hive2://localhost:10000/default:

Install Hadoop Cluster with Docker


name@host:/#wget https://raw.github.com/zettio/weave/master/weave
name@host:/#sudo mv weave /usr/local/bin/
name@host:/#sudo chmod +x /usr/local/bin/weave
name@host:/#weave launch
name@host:/#eval $(weave env)
name@host:/#docker run --name=hnode1 --hostname=hnode1.weave.local -it ubuntu /bin/bash
name@host:/#eval $(weave env)
name@host:/#docker run --name=hnode2 --hostname=hnode2.weave.local -it ubuntu /bin/bash

root@hnode1:~#passwd
Enter new UNIX password:root
root@hnode1:~#sudo apt-get update
root@hnode1:~#apt-get install ssh-server vim rsync
root@hnode1:~#sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
root@hnode1:~#/etc/init.d/ssh start
root@hnode1:~#ssh-keygen

root@hnode2:~#passwd
Enter new UNIX password:root
root@hnode2:~#sudo apt-get update
root@hnode2:~#apt-get install ssh-server vim rsync
root@hnode2:~#sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
root@hnode2:~#/etc/init.d/ssh start
root@hnode2:~#ssh-keygen

root@hnode1:/opt# cat /root/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
root@hnode1:/opt# chmod 700 ~/.ssh
root@hnode1:/opt# chmod 600 ~/.ssh/authorized_keys
root@hnode1:~#scp /root/.ssh/id_rsa.pub root@hnode2:/tmp

root@hnode2:~#scp /root/.ssh/id_rsa.pub root@hnode1:/tmp
root@hnode1:~#cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys

root@hnode2:/opt# cat /root/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
root@hnode2:~#cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys
root@hnode2:/opt# cat /root/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
root@hnode2:~#chmod 700 ~/.ssh
root@hnode2:~#chmod 600 ~/.ssh/authorized_keys

root@hnode1:/# wget http://apache.openmirror.de/hadoop/common/hadoop-2.6.2/hadoop-2.6.2.tar.gz
root@hnode1:/#tar -xvf hadoop-2.6.2.tar.gz
root@hnode1:/#mv hadoop-2.6.2 /opt/

root@hnode1:/# vim /opt/hadoop-2.6.2/etc/hadoop/core-site.xml

<property>
<name>fs.defaultFS</name>
<value>hdfs://hnode1.weave.local/</value>
</property>

root@hnode1:/# vim /opt/hadoop-2.6.2/etc/hadoop/hdfs-site.xml

<property>
<name>dfs.namenode.name.dir</name>
<value>/disk1/hdfs/name,/disk1/hdfs/name,/remote/hdfs/name</value>
</property>

root@hnode1:/# vim /opt/hadoop-2.6.2/etc/hadoop/yarn-site.xml

<property>
<name>yarn.resourcemanager.hostname</name>
<value>node1.weave.local</value>
</property>
<property>
<name>yarn.nodemanager.local-dirs</name>
<value>/disk1/nm-local-dir,/disk2/nm-local-dir</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce.shuffle</value>
</property>
<property>
<name>yarn.nodemanager.resource.memory-mb</name>
<value>16384</value>
</property>
<property>
<name>yarn.nodemanager.resource.cpu-vcores</name>
<value>16</value>
</property>

root@hnode1:/# mkdir -p /disk1/hdfs/name /remote/hdfs/name /disk1/nm-local-dir /disk2/nm-local-dir

root@hnode2:/# wget http://apache.openmirror.de/hadoop/common/hadoop-2.6.2/hadoop-2.6.2.tar.gz
root@hnode2:/#tar -xvf hadoop-2.6.2.tar.gz
root@hnode2:/#mv hadoop-2.6.2 /opt/

root@hnode2:/# vim /opt/hadoop-2.6.2/etc/hadoop/core-site.xml

<property>
<name>fs.defaultFS</name>
<value>hdfs://hnode1.weave.local/</value>
</property>

root@hnode2:/# vim /opt/hadoop-2.6.2/etc/hadoop/hdfs-site.xml

<property>
<name>dfs.datanode.data.dir</name>
<value>/disk1/hdfs/data,/disk2/hdfs/data</value></property>

root@hnode2:/# mkdir -p /disk1/hdfs/data /disk2/hdfs/data

name@host:/#HN1_IP=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' hnode1)

name@host:/#HN2_IP=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' hnode2)

name@host:/#scp ~/Downloads/jdk-8u65-linux-x64.tar.gz root@$HN1_IP:/opt

name@host:/#scp ~/Downloads/jdk-8u65-linux-x64.tar.gz root@$HN2_IP:/opt

root@hnode1:/opt# tar -xvf jdk-8u65-linux-x64.tar.gz
root@hnode1:~# echo "JAVA_HOME=jdk1.8.0_65" >> /etc/environment
root@hnode1:~# echo "PATH=$JAVA_HOME/bin:$PATH" >> /etc/environment
root@hnode1:~#source /etc/environment
root@hnode1:~# export JAVA_HOME=jdk1.8.0_65

root@hnode2:/opt# tar -xvf jdk-8u65-linux-x64.tar.gz
root@hnode2:~# echo "JAVA_HOME=jdk1.8.0_65" >> /etc/environment
root@hnode2:~# echo "PATH=$JAVA_HOME/bin:$PATH" >> /etc/environment
root@hnode2:~#source /etc/environment
root@hnode2:~# export JAVA_HOME=jdk1.8.0_65

root@hnode1:/# /opt/hadoop-2.6.2/bin/hdfs namenode -format mycluster

root@hnode1:~# /opt/hadoop-2.6.2/sbin/start-dfs.sh
root@hnode2:~# /opt/hadoop-2.6.2/sbin/start-dfs.sh