|   | 1 | [[PageOutline]] | 
                  
                          |   | 2 |  | 
                  
                          |   | 3 | ◢ <[wiki:NTUT160220/Lab3 實作三]> | <[wiki:NTUT160220 回課程大綱]> ▲ | <[wiki:NTUT160220/Lab5 實作五]> ◣ | 
                  
                          |   | 4 |  | 
                  
                          |   | 5 | = 實作四 Lab 4 = | 
                  
                          |   | 6 |  | 
                  
                          |   | 7 | {{{ | 
                  
                          |   | 8 | #!html | 
                  
                          |   | 9 | <div style="text-align: center;"><big style="font-weight: bold;"><big>HDFS 叢集環境操作練習<br/>HDFS full distributed mode in practice</big></big></div> | 
                  
                          |   | 10 | }}} | 
                  
                          |   | 11 |  | 
                  
                          |   | 12 | {{{ | 
                  
                          |   | 13 | #!text | 
                  
                          |   | 14 | 以下練習,請連線至 hdp01.3du.me 操作。底下的 userXX 等於您的用戶名稱。 | 
                  
                          |   | 15 | 以下練習,請連線至 hdp02.3du.me 操作。底下的 userXX 等於您的用戶名稱。 | 
                  
                          |   | 16 | 以下練習,請連線至 hdp03.3du.me 操作。底下的 userXX 等於您的用戶名稱。 | 
                  
                          |   | 17 | 以下練習,請連線至 hdp04.3du.me 操作。底下的 userXX 等於您的用戶名稱。 | 
                  
                          |   | 18 | }}} | 
                  
                          |   | 19 |  | 
                  
                          |   | 20 | == 產生目錄 == | 
                  
                          |   | 21 |  | 
                  
                          |   | 22 | {{{ | 
                  
                          |   | 23 | user0@hdp:~$ hadoop fs -ls                                                     | 
                  
                          |   | 24 | user0@hdp:~$ hadoop fs -mkdir tmp                                              | 
                  
                          |   | 25 | user0@hdp:~$ hadoop fs -ls                                                     | 
                  
                          |   | 26 | Found 1 items                                                                  | 
                  
                          |   | 27 | drwxr-xr-x   - user0 supergroup          0 2014-03-23 02:04 /user/user0/tmp    | 
                  
                          |   | 28 | }}} | 
                  
                          |   | 29 |  | 
                  
                          |   | 30 | == 產生一個 100 MB 的檔案 == | 
                  
                          |   | 31 |  | 
                  
                          |   | 32 | {{{ | 
                  
                          |   | 33 | user0@hdp:~$ dd if=/dev/zero of=100mb.img bs=1M count=100                      | 
                  
                          |   | 34 | 100+0 records in                                                               | 
                  
                          |   | 35 | 100+0 records out                                                              | 
                  
                          |   | 36 | 104857600 bytes (105 MB) copied, 0.0589096 s, 1.8 GB/s                         | 
                  
                          |   | 37 | user0@hdp:~$ hadoop fs -put 100mb.img test.img                                 | 
                  
                          |   | 38 | user0@hdp:~$ hadoop fs -ls                                                     | 
                  
                          |   | 39 | Found 2 items                                                                  | 
                  
                          |   | 40 | -rw-r--r--   1 user0 supergroup  104857600 2014-03-23 02:08 /user/user0/test.img | 
                  
                          |   | 41 | drwxr-xr-x   - user0 supergroup          0 2014-03-23 02:04 /user/user0/tmp | 
                  
                          |   | 42 | }}} | 
                  
                          |   | 43 |  | 
                  
                          |   | 44 | == 觀察 block 分佈情形 == | 
                  
                          |   | 45 |  | 
                  
                          |   | 46 | {{{ | 
                  
                          |   | 47 | user0@hdp:~$ hadoop fsck /user/$USER/test.img -files -blocks -locations        | 
                  
                          |   | 48 | FSCK started by user0 from /10.240.1.123 for path /user/$USER/test.img at Sun  | 
                  
                          |   | 49 | Mar 23 02:11:08 UTC 2014                                                       | 
                  
                          |   | 50 | /user/user0/test.img 104857600 bytes, 2 block(s):  OK                          | 
                  
                          |   | 51 | 0. blk_-4422576463029178583_1044 len=67108864 repl=1 [10.240.1.123:50010]      | 
                  
                          |   | 52 | 1. blk_7793285600029540175_1044 len=37748736 repl=1 [10.240.1.123:50010]       | 
                  
                          |   | 53 |                                                                                | 
                  
                          |   | 54 | Status: HEALTHY                                                                | 
                  
                          |   | 55 |  Total size:    104857600 B                                                    | 
                  
                          |   | 56 |  Total dirs:    0                                                              | 
                  
                          |   | 57 |  Total files:   1                                                              | 
                  
                          |   | 58 |  Total blocks (validated):      2 (avg. block size 52428800 B)                 | 
                  
                          |   | 59 |  Minimally replicated blocks:   2 (100.0 %)                                    | 
                  
                          |   | 60 |  Over-replicated blocks:        0 (0.0 %)                                      | 
                  
                          |   | 61 |  Under-replicated blocks:       0 (0.0 %)                                      | 
                  
                          |   | 62 |  Mis-replicated blocks:         0 (0.0 %)                                      | 
                  
                          |   | 63 |  Default replication factor:    1                                              | 
                  
                          |   | 64 |  Average block replication:     1.0                                            | 
                  
                          |   | 65 |  Corrupt blocks:                0                                              | 
                  
                          |   | 66 |  Missing replicas:              0 (0.0 %)                                      | 
                  
                          |   | 67 |  Number of data-nodes:          9                                              | 
                  
                          |   | 68 |  Number of racks:               1                                              | 
                  
                          |   | 69 | FSCK ended at Sun Mar 23 02:11:08 UTC 2014 in 9 milliseconds                   | 
                  
                          |   | 70 |                                                                                | 
                  
                          |   | 71 |                                                                                | 
                  
                          |   | 72 | The filesystem under path '/user/$USER/test.img' is HEALTHY                    | 
                  
                          |   | 73 | }}} | 
                  
                          |   | 74 |  | 
                  
                          |   | 75 | == 修改副本個數 == | 
                  
                          |   | 76 |  | 
                  
                          |   | 77 | {{{ | 
                  
                          |   | 78 | user0@hdp:~$ hadoop fs -setrep 2 /user/$USER/test.img                          | 
                  
                          |   | 79 | Replication 2 set: hdfs://hdp:9000/user/$USER/test.img | 
                  
                          |   | 80 | user0@hdp:~$ hadoop fsck /user/$USER/test.img -files -blocks -locations        | 
                  
                          |   | 81 | FSCK started by user0 from /10.240.1.123 for path /user/$USER/test.img at Sun  | 
                  
                          |   | 82 | Mar 23 02:45:11 UTC 2014                                                       | 
                  
                          |   | 83 | /user/$USER/test.img 104857600 bytes, 2 block(s):  OK                          | 
                  
                          |   | 84 | 0. blk_-4422576463029178583_1044 len=67108864 repl=2 [10.240.1.123:50010, 10.2 | 
                  
                          |   | 85 | 40.174.73:50010]                                                               | 
                  
                          |   | 86 | 1. blk_7793285600029540175_1044 len=37748736 repl=2 [10.240.1.123:50010, 10.24 | 
                  
                          |   | 87 | 0.116.151:50010]                                                               | 
                  
                          |   | 88 |                                                                                | 
                  
                          |   | 89 | Status: HEALTHY                                                                | 
                  
                          |   | 90 |  Total size:    104857600 B                                                    | 
                  
                          |   | 91 |  Total dirs:    0                                                              | 
                  
                          |   | 92 |  Total files:   1                                                              | 
                  
                          |   | 93 |  Total blocks (validated):      2 (avg. block size 52428800 B)                 | 
                  
                          |   | 94 |  Minimally replicated blocks:   2 (100.0 %)                                    | 
                  
                          |   | 95 |  Over-replicated blocks:        0 (0.0 %)                                      | 
                  
                          |   | 96 |  Under-replicated blocks:       0 (0.0 %)                                      | 
                  
                          |   | 97 |  Mis-replicated blocks:         0 (0.0 %)                                      | 
                  
                          |   | 98 |  Default replication factor:    1                                              | 
                  
                          |   | 99 |  Average block replication:     2.0                                            | 
                  
                          |   | 100 |  Corrupt blocks:                0                                              | 
                  
                          |   | 101 |  Missing replicas:              0 (0.0 %)                                      | 
                  
                          |   | 102 |  Number of data-nodes:          9                                              | 
                  
                          |   | 103 |  Number of racks:               1                                              | 
                  
                          |   | 104 | FSCK ended at Sun Mar 23 02:45:11 UTC 2014 in 0 milliseconds                   | 
                  
                          |   | 105 |                                                                                | 
                  
                          |   | 106 |                                                                                | 
                  
                          |   | 107 | The filesystem under path '/user/$USER/test.img' is HEALTHY                    | 
                  
                          |   | 108 | }}} |