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

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s