Changes between Version 4 and Version 5 of YMU110509/Lab9


Ignore:
Timestamp:
Jun 20, 2011, 2:38:05 PM (13 years ago)
Author:
jazz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • YMU110509/Lab9

    v4 v5  
    1717~$ gunzip test_long.fa.gz
    1818~$ for ((i=1;i<100;i++)); do hadoop fs -put test_long.fa sample-$i.fa; done
    19 ~$ for ((i=1;i<20;i++)); do echo /user/h998/sample-$i.fa; done > sample-01.txt
    20 ~$ for ((i=20;i<40;i++)); do echo /user/h998/sample-$i.fa; done > sample-02.txt
    21 ~$ for ((i=40;i<60;i++)); do echo /user/h998/sample-$i.fa; done > sample-03.txt
    22 ~$ for ((i=60;i<80;i++)); do echo /user/h998/sample-$i.fa; done > sample-04.txt
    23 ~$ for ((i=80;i<100;i++)); do echo /user/h998/sample-$i.fa; done > sample-05.txt
     19~$ for ((i=1;i<20;i++)); do echo /user/$(whoami)/sample-$i.fa; done > sample-01.txt
     20~$ for ((i=20;i<40;i++)); do echo /user/$(whoami)/sample-$i.fa; done > sample-02.txt
     21~$ for ((i=40;i<60;i++)); do echo /user/$(whoami)/sample-$i.fa; done > sample-03.txt
     22~$ for ((i=60;i<80;i++)); do echo /user/$(whoami)/sample-$i.fa; done > sample-04.txt
     23~$ for ((i=80;i<100;i++)); do echo /user/$(whoami)/sample-$i.fa; done > sample-05.txt
    2424~$ hadoop fs -mkdir lab9_input
    2525~$ hadoop fs -put sample-0* lab9_input
     26}}}
     27 * 檢查輸入檔案
     28{{{
     29~$ hadoop fs -ls
     30~$ hadoop fs -ls lab9_input
    2631}}}
    2732
     
    3136{{{
    3237#!sh
     38#!/bin/bash
    3339
     40id="h998"
     41mkdir -p /tmp/$id
     42host=`hostname`
     43pwd=`pwd`
     44uid=`whoami`
     45
     46while read line; do
     47  input=$line
     48  filename=`basename $input`
     49  echo "$uid@$host:$pwd> hadoop fs -get $input /tmp/$id/$filename"
     50  echo "$uid@$host:$pwd> velveth output-$filename 17 -fasta -short /tmp/$id/$filename"
     51  echo "$uid@$host:$pwd> hadoop fs -put output-$filename ."
     52done
     53rm -rf /tmp/$id
     54}}}
     55 * 接著,讓我們在本地端先驗證一下 testmapper.sh 的運作
     56{{{
     57~$ head -n 10 sample-01.txt > sample-00.txt
     58~$ cat > testmapper.sh << EOF
     59#!/bin/bash
     60
     61id="h998"
     62mkdir -p /tmp/\$id
     63host=\`hostname\`
     64pwd=\`pwd\`
     65uid=\`whoami\`
     66
     67while read line; do
     68  input=\$line
     69  filename=\`basename \$input\`
     70  echo "\$uid@$host:\$pwd> hadoop fs -get \$input /tmp/\$id/\$filename"
     71  echo "\$uid@$host:\$pwd> velveth output-\$filename 17 -fasta -short /tmp/\$id/\$filename"
     72  echo "\$uid@$host:\$pwd> hadoop fs -put output-\$filename ."
     73done
     74rm -rf /tmp/\$id
     75EOF
     76~$ chmod a+x testmapper.sh
     77~$ cat sample-00.txt | ./testmapper.sh
     78h998@hadoop:/home/h998> hadoop fs -get /user/h998/sample-1.fa /tmp/h998/sample-1.fa
     79h998@hadoop:/home/h998> velveth output-sample-1.fa 17 -fasta -short /tmp/h998/sample-1.fa
     80h998@hadoop:/home/h998> hadoop fs -put output-sample-1.fa .
     81h998@hadoop:/home/h998> hadoop fs -get /user/h998/sample-2.fa /tmp/h998/sample-2.fa
     82}}}
     83 * 讓我們用 Hadoop Streaming 的方式來執行 testmapper.sh
     84{{{
     85~$ hadoop jar hadoop-streaming.jar -input lab9_input -output lab9_out1 -mapper testmapper.sh -file testmapper.sh
     86}}}
     87 * 觀察 lab9_out1 的結果,看與本機執行有何不同呢?
     88{{{
     89~$ hadoop fs -cat /user/$(whoami)/lab9_out1/part-00000 | head
     90hadoop@hadoop104:/var/lib/hadoop/cache/hadoop/mapred/local/taskTracker/jobcache/job_201106041247_1820/attempt_201106041247_1820_m_000002_0/work> hadoop fs -get /user/h998/sample-60.fa /tmp/h998/sample-60.fa 
     91hadoop@hadoop104:/var/lib/hadoop/cache/hadoop/mapred/local/taskTracker/jobcache/job_201106041247_1820/attempt_201106041247_1820_m_000002_0/work> hadoop fs -get /user/h998/sample-61.fa /tmp/h998/sample-61.fa 
     92hadoop@hadoop104:/var/lib/hadoop/cache/hadoop/mapred/local/taskTracker/jobcache/job_201106041247_1820/attempt_201106041247_1820_m_000002_0/work> hadoop fs -get /user/h998/sample-62.fa /tmp/h998/sample-62.fa 
    3493}}}
    3594