210 | | bin/hadoop namenode -format |
211 | | bin/start-all |
212 | | }}} |
213 | | * 測試 |
214 | | {{{ |
215 | | mkdir input |
216 | | cp *.txt input/ |
217 | | bin/hadoop dfs -put input input |
218 | | bin/hadoop jar hadoop-*-examples.jar wordcount input ouput |
219 | | }}} |
220 | | |
221 | | * browse http://gm2.nchc.org.tw:50070 for DFS status |
222 | | |
| 208 | $ cd /opt/hadoop |
| 209 | $ bin/hadoop namenode -format |
| 210 | $ bin/start-all.sh |
| 211 | }}} |
| 212 | == 3.4 Hadoop 測試範例 == |
| 213 | * 運作WordCount以測試 |
| 214 | {{{ |
| 215 | $ mkdir input |
| 216 | $ cp *.txt input/ |
| 217 | $ bin/hadoop dfs -put input input |
| 218 | $ bin/hadoop jar hadoop-*-examples.jar wordcount input ouput |
| 219 | }}} |
| 220 | * 執行畫面: |
| 221 | {{{ |
| 222 | hadoop:/opt/hadoop# bin/hadoop jar hadoop-*-examples.jar wordcount input ouput |
| 223 | 09/02/26 06:16:34 INFO mapred.FileInputFormat: Total input paths to process : 4 |
| 224 | 09/02/26 06:16:34 INFO mapred.FileInputFormat: Total input paths to process : 4 |
| 225 | 09/02/26 06:16:35 INFO mapred.JobClient: Running job: job_200902260615_0001 |
| 226 | 09/02/26 06:16:36 INFO mapred.JobClient: map 0% reduce 0% |
| 227 | 09/02/26 06:16:39 INFO mapred.JobClient: map 80% reduce 0% |
| 228 | 09/02/26 06:16:40 INFO mapred.JobClient: map 100% reduce 0% |
| 229 | 09/02/26 06:16:50 INFO mapred.JobClient: Job complete: job_200902260615_0001 |
| 230 | 09/02/26 06:16:50 INFO mapred.JobClient: Counters: 16 |
| 231 | 09/02/26 06:16:50 INFO mapred.JobClient: File Systems |
| 232 | 09/02/26 06:16:50 INFO mapred.JobClient: HDFS bytes read=267854 |
| 233 | 09/02/26 06:16:50 INFO mapred.JobClient: HDFS bytes written=100895 |
| 234 | 09/02/26 06:16:50 INFO mapred.JobClient: Local bytes read=133897 |
| 235 | 09/02/26 06:16:50 INFO mapred.JobClient: Local bytes written=292260 |
| 236 | 09/02/26 06:16:50 INFO mapred.JobClient: Job Counters |
| 237 | 09/02/26 06:16:50 INFO mapred.JobClient: Launched reduce tasks=1 |
| 238 | 09/02/26 06:16:50 INFO mapred.JobClient: Rack-local map tasks=5 |
| 239 | 09/02/26 06:16:50 INFO mapred.JobClient: Launched map tasks=5 |
| 240 | 09/02/26 06:16:50 INFO mapred.JobClient: Map-Reduce Framework |
| 241 | 09/02/26 06:16:50 INFO mapred.JobClient: Reduce input groups=8123 |
| 242 | 09/02/26 06:16:50 INFO mapred.JobClient: Combine output records=17996 |
| 243 | 09/02/26 06:16:50 INFO mapred.JobClient: Map input records=6515 |
| 244 | 09/02/26 06:16:50 INFO mapred.JobClient: Reduce output records=8123 |
| 245 | 09/02/26 06:16:50 INFO mapred.JobClient: Map output bytes=385233 |
| 246 | 09/02/26 06:16:50 INFO mapred.JobClient: Map input bytes=265370 |
| 247 | 09/02/26 06:16:50 INFO mapred.JobClient: Combine input records=44786 |
| 248 | 09/02/26 06:16:50 INFO mapred.JobClient: Map output records=34913 |
| 249 | 09/02/26 06:16:50 INFO mapred.JobClient: Reduce input records=8123 |
| 250 | hadoop:/opt/hadoop# |
| 251 | }}} |
| 252 | |
| 253 | * http://gm2.nchc.org.tw:50030/ |
| 254 | * 網頁中可以看到node數為7則代表所有的節點都有加入 |
| 255 | * http://gm2.nchc.org.tw:50075/browseDirectory.jsp?dir=%2Fuser%2Froot&namenodeInfoPort=50070 |
| 256 | * 可以看到輸出結果 |
| 257 | |
| 258 | == 3.5 停止hadoop == |
| 259 | {{{ |
| 260 | $ bin/stop-all.sh |
| 261 | }}} |
| 262 | == 3.6 重新建立 hadoop == |
| 263 | {{{ |
| 264 | $ bin/stop-all.sh |
| 265 | $ dsh -a rm -rf /root/hadoop/* /tmp/hadoop-root* |
| 266 | $ bin/hadoop namenode -format |
| 267 | $ bin/start-all.sh |
| 268 | }}} |