Changes between Version 5 and Version 6 of YMU110509/Lab9
- Timestamp:
- Jun 20, 2011, 2:52:34 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
YMU110509/Lab9
v5 v6 55 55 * 接著,讓我們在本地端先驗證一下 testmapper.sh 的運作 56 56 {{{ 57 ~$ head -n 10sample-01.txt > sample-00.txt57 ~$ head -n 2 sample-01.txt > sample-00.txt 58 58 ~$ cat > testmapper.sh << EOF 59 59 #!/bin/bash 60 60 61 id=" h998"61 id="`whoami`" 62 62 mkdir -p /tmp/\$id 63 63 host=\`hostname\` … … 68 68 input=\$line 69 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 ."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 ." 73 73 done 74 74 rm -rf /tmp/\$id … … 95 95 == 實作透過 Hadoop Streaming 執行 99 組 velvet 運算 == 96 96 97 * 撰寫 velvet_mapper.pl97 * 撰寫 mapper.sh 98 98 {{{ 99 #!perl 99 #!sh 100 #!/bin/bash 100 101 102 id="h998" 103 mkdir -p /tmp/$id 104 host=`hostname` 105 pwd=`pwd` 106 uid=`whoami` 107 108 while read line; do 109 input=$line 110 filename=`basename $input` 111 echo "$uid@$host> hadoop fs -get $input /tmp/$id/$filename" 112 hadoop fs -get $input /tmp/$id/$filename 113 echo "$uid@$host> velveth output-$filename 17 -fasta -short /tmp/$id/$filename" 114 velveth output-$filename 17 -fasta -short /tmp/$id/$filename 115 echo "$uid@$host> hadoop fs -put output-$filename /user/$id/." 116 hadoop fs -put output-$filename /user/$id/. 117 done 118 rm -rf /tmp/$id 101 119 }}} 120 * 於本機測試 mapper.sh 121 {{{ 122 ~$ cat > mapper.sh << EOF 123 #!/bin/bash 124 125 id="`whoami`" 126 mkdir -p /tmp/\$id 127 host=\`hostname\` 128 pwd=\`pwd\` 129 uid=\`whoami\` 130 131 while read line; do 132 input=\$line 133 filename=\`basename \$input\` 134 echo "\$uid@\$host> hadoop fs -get \$input /tmp/\$id/\$filename" 135 hadoop fs -get \$input /tmp/\$id/\$filename 136 echo "\$uid@\$host> velveth output-\$filename 17 -fasta -short /tmp/\$id/\$filename" 137 velveth output-\$filename 17 -fasta -short /tmp/\$id/\$filename 138 echo "\$uid@\$host> hadoop fs -put output-\$filename /user/\$id/." 139 hadoop fs -put output-\$filename /user/\$id/. 140 done 141 rm -rf /tmp/\$id 142 EOF 143 ~$ chmod a+x mapper.sh 144 ~$ cat sample-00.txt | ./mapper.sh 145 ~$ hadoop fs -rmr output-* 146 }}} 147 * 接著用 hadoop streaming 來執行 148 {{{ 149 ~$ hadoop jar hadoop-streaming.jar -input lab9_input -output lab9_out2 -mapper mapper.sh -file mapper.sh 150 }}}