| 1 | {{{ |
| 2 | #!html |
| 3 | <div style="text-align: center;"><big |
| 4 | style="font-weight: bold;"><big><big>實作一: Hadoop 0.20 單機安裝</big></big></big></div> |
| 5 | }}} |
| 6 | [[PageOutline]] |
| 7 | |
| 8 | == 前言 == |
| 9 | |
| 10 | * 本實作基於 Ubuntu 8.04(含)以上版本,其中Ubuntu 10.04(含)以上安裝Java的方法有異動,請到該步驟時注意一下。 |
| 11 | * 本頁面的部分指令,是針對不熟悉 Linux 文字編輯器的使用者所設計的'懶人'設定法,您也可以使用習慣使用的文字編輯器(如:vi,nano,joe等)進行修改。 |
| 12 | * '''黑底白字的部分為指令或console秀出的畫面''',請自行剪貼提示符號 "$"(代表一般使用者) 或 "#"(代表最高權限 root 管理者) 之後的指令。如: |
| 13 | {{{ |
| 14 | /home/DIR$ Copy_Command From To ... |
| 15 | }}} |
| 16 | 則複製''' Copy_Command From To ... ''' 這個指令,貼到你的console來執行。(/home/DIR 代表目前所在的目錄路徑) |
| 17 | * '''白底黑字的部分為文件內的內容''' ,如 |
| 18 | {{{ |
| 19 | #!sh |
| 20 | I am context. |
| 21 | }}} |
| 22 | 如果熟悉vi,nano,joe等編輯器可複製此區內容貼到文件內(雖然此頁面的指令都已經簡化過) |
| 23 | |
| 24 | * 登入資訊 |
| 25 | |
| 26 | || 使用者 || hadoop|| |
| 27 | || 群組 || hadoop || |
| 28 | || 密碼 || ****** || |
| 29 | * hadoop 身份擁有sudoer 的權限 |
| 30 | |
| 31 | == Hadoop Streaming with commands == |
| 32 | |
| 33 | {{{ |
| 34 | hadoop@lucid:~$ cd /opt/hadoop |
| 35 | hadoop@lucid:/opt/hadoop$ hadoop fs -rmr input output |
| 36 | hadoop@lucid:/opt/hadoop$ hadoop fs -put /etc/hadoop/conf input |
| 37 | hadoop@lucid:/opt/hadoop$ hadoop jar hadoop-streaming.jar -input input -output output -mapper /bin/cat -reducer /usr/bin/wc |
| 38 | }}} |
| 39 | |
| 40 | {{{ |
| 41 | hadoop@lucid:/opt/hadoop$ echo "sed -e \"s/ /\n/g\" | grep ." > streamingMapper.sh |
| 42 | hadoop@lucid:/opt/hadoop$ echo "uniq -c | awk '{print \$2 \"\t\" \$1}'" > streamingReducer.sh |
| 43 | hadoop@lucid:/opt/hadoop$ chmod a+x streamingMapper.sh |
| 44 | hadoop@lucid:/opt/hadoop$ chmod a+x streamingReducer.sh |
| 45 | hadoop@lucid:/opt/hadoop$ hadoop fs -rmr input output |
| 46 | hadoop@lucid:/opt/hadoop$ hadoop fs -put /etc/hadoop/conf input |
| 47 | hadoop@lucid:/opt/hadoop$ hadoop jar hadoop-streaming.jar -input input -output output -mapper streamingMapper.sh -reducer streamingReducer.sh -file streamingMapper.sh -file streamingReducer.sh |
| 48 | }}} |