| 1 | [[PageOutline]] |
| 2 | |
| 3 | ◢ <[wiki:III140503/Lab3 實作三]> | <[wiki:III140503 回課程大綱]> ▲ | <[wiki:III140503/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 | 以下練習,請連線至 https://lab.3du.me 操作。底下的 hXXXX 等於您的用戶名稱。 |
| 15 | }}} |
| 16 | |
| 17 | == 準備工作 == |
| 18 | |
| 19 | * 由於 Google Cloud Engine 的 ssh 有些限制,目前先以 https 瀏覽器的連線方式進行實作 |
| 20 | * 瀏覽器操作模式比較受限,目前已知 IE 會有問題,Firefox 會打不出 "-" 號,建議採用 Chrome 瀏覽器進行操作。 |
| 21 | * 下載 [http://www.google.com.tw/intl/zh-TW/chrome/browser/ Google Chrome] |
| 22 | * 連線至 https://lab.3du.me (使用期限: 2014/03/23 00:00 ~ 2014/03/30 23:00) |
| 23 | * 備援入口: https://lab2.3du.me , https://lab3.3du.me |
| 24 | * 保障您自己使用的權利,請先修改密碼: |
| 25 | {{{ |
| 26 | user0@hdp:~$ passwd |
| 27 | Changing password for user0. |
| 28 | (current) UNIX password: |
| 29 | Enter new UNIX password: |
| 30 | Retype new UNIX password: |
| 31 | }}} |
| 32 | |
| 33 | == 產生目錄 == |
| 34 | |
| 35 | {{{ |
| 36 | user0@hdp:~$ hadoop fs -ls |
| 37 | user0@hdp:~$ hadoop fs -mkdir tmp |
| 38 | user0@hdp:~$ hadoop fs -ls |
| 39 | Found 1 items |
| 40 | drwxr-xr-x - user0 supergroup 0 2014-03-23 02:04 /user/user0/tmp |
| 41 | }}} |
| 42 | |
| 43 | == 產生一個 100 MB 的檔案 == |
| 44 | |
| 45 | {{{ |
| 46 | user0@hdp:~$ dd if=/dev/zero of=100mb.img bs=1M count=100 |
| 47 | 100+0 records in |
| 48 | 100+0 records out |
| 49 | 104857600 bytes (105 MB) copied, 0.0589096 s, 1.8 GB/s |
| 50 | user0@hdp:~$ hadoop fs -put 100mb.img test.img |
| 51 | user0@hdp:~$ hadoop fs -ls |
| 52 | Found 2 items |
| 53 | -rw-r--r-- 1 user0 supergroup 104857600 2014-03-23 02:08 /user/user0/test.img |
| 54 | drwxr-xr-x - user0 supergroup 0 2014-03-23 02:04 /user/user0/tmp |
| 55 | }}} |
| 56 | |
| 57 | == 觀察 block 分佈情形 == |
| 58 | |
| 59 | {{{ |
| 60 | user0@hdp:~$ hadoop fsck /user/user0/test.img -files -blocks -locations |
| 61 | FSCK started by user0 from /10.240.1.123 for path /user/user0/test.img at Sun |
| 62 | Mar 23 02:11:08 UTC 2014 |
| 63 | /user/user0/test.img 104857600 bytes, 2 block(s): OK |
| 64 | 0. blk_-4422576463029178583_1044 len=67108864 repl=1 [10.240.1.123:50010] |
| 65 | 1. blk_7793285600029540175_1044 len=37748736 repl=1 [10.240.1.123:50010] |
| 66 | |
| 67 | Status: HEALTHY |
| 68 | Total size: 104857600 B |
| 69 | Total dirs: 0 |
| 70 | Total files: 1 |
| 71 | Total blocks (validated): 2 (avg. block size 52428800 B) |
| 72 | Minimally replicated blocks: 2 (100.0 %) |
| 73 | Over-replicated blocks: 0 (0.0 %) |
| 74 | Under-replicated blocks: 0 (0.0 %) |
| 75 | Mis-replicated blocks: 0 (0.0 %) |
| 76 | Default replication factor: 1 |
| 77 | Average block replication: 1.0 |
| 78 | Corrupt blocks: 0 |
| 79 | Missing replicas: 0 (0.0 %) |
| 80 | Number of data-nodes: 9 |
| 81 | Number of racks: 1 |
| 82 | FSCK ended at Sun Mar 23 02:11:08 UTC 2014 in 9 milliseconds |
| 83 | |
| 84 | |
| 85 | The filesystem under path '/user/user0/test.img' is HEALTHY |
| 86 | }}} |
| 87 | |
| 88 | == 修改副本個數 == |
| 89 | |
| 90 | {{{ |
| 91 | user0@hdp:~$ hadoop fs -setrep 2 /user/user0/test.img |
| 92 | Replication 2 set: hdfs://hdp:9000/user/user0/test.img |
| 93 | user0@hdp:~$ hadoop fsck /user/user0/test.img -files -blocks -locations |
| 94 | FSCK started by user0 from /10.240.1.123 for path /user/user0/test.img at Sun |
| 95 | Mar 23 02:45:11 UTC 2014 |
| 96 | /user/user0/test.img 104857600 bytes, 2 block(s): OK |
| 97 | 0. blk_-4422576463029178583_1044 len=67108864 repl=2 [10.240.1.123:50010, 10.2 |
| 98 | 40.174.73:50010] |
| 99 | 1. blk_7793285600029540175_1044 len=37748736 repl=2 [10.240.1.123:50010, 10.24 |
| 100 | 0.116.151:50010] |
| 101 | |
| 102 | Status: HEALTHY |
| 103 | Total size: 104857600 B |
| 104 | Total dirs: 0 |
| 105 | Total files: 1 |
| 106 | Total blocks (validated): 2 (avg. block size 52428800 B) |
| 107 | Minimally replicated blocks: 2 (100.0 %) |
| 108 | Over-replicated blocks: 0 (0.0 %) |
| 109 | Under-replicated blocks: 0 (0.0 %) |
| 110 | Mis-replicated blocks: 0 (0.0 %) |
| 111 | Default replication factor: 1 |
| 112 | Average block replication: 2.0 |
| 113 | Corrupt blocks: 0 |
| 114 | Missing replicas: 0 (0.0 %) |
| 115 | Number of data-nodes: 9 |
| 116 | Number of racks: 1 |
| 117 | FSCK ended at Sun Mar 23 02:45:11 UTC 2014 in 0 milliseconds |
| 118 | |
| 119 | |
| 120 | The filesystem under path '/user/user0/test.img' is HEALTHY |
| 121 | }}} |