| 1 | ◢ <[wiki:NTUOSS160412/Lab3 實作三]> | <[wiki:NTUOSS160412 回課程大綱]> ▲ | <[wiki:NTUOSS160412/Lab5 實作五]> ◣ |
| 2 | |
| 3 | = 實作四 Lab 4 = |
| 4 | |
| 5 | {{{ |
| 6 | #!html |
| 7 | <p style="text-align: center;"><big style="font-weight: bold;"><big>HDFS 基本指令操作練習<br/>HDFS in practice (full distributed mode)</big></big></p> |
| 8 | }}} |
| 9 | [[PageOutline]] |
| 10 | |
| 11 | == Content 1: HDFS Shell 基本操作 == |
| 12 | == Content 1: Basic HDFS Shell Commands == |
| 13 | |
| 14 | === 1.1 瀏覽你HDFS目錄 === |
| 15 | === 1.1 Browsing Your HDFS Folder === |
| 16 | |
| 17 | {{{ |
| 18 | ~$ hadoop fs -ls |
| 19 | }}} |
| 20 | |
| 21 | === 1.2 上傳資料到 HDFS 目錄 === |
| 22 | === 1.2 Upload Files or Folder to HDFS === |
| 23 | |
| 24 | * 上傳 Upload |
| 25 | |
| 26 | {{{ |
| 27 | ~$ hadoop fs -put ${HOME}/hadoop/conf toHDFS |
| 28 | }}} |
| 29 | |
| 30 | * 檢查 Check |
| 31 | |
| 32 | {{{ |
| 33 | ~$ hadoop fs -ls |
| 34 | }}} |
| 35 | |
| 36 | === 1.3 下載 HDFS 的資料到本地目錄 === |
| 37 | === 1.3 Download HDFS Files or Folder to Local === |
| 38 | |
| 39 | * 下載 Download |
| 40 | |
| 41 | {{{ |
| 42 | ~$ hadoop fs -get toHDFS fromHDFS |
| 43 | }}} |
| 44 | |
| 45 | * 檢查 Check |
| 46 | {{{ |
| 47 | ~$ ls -al | grep fromHDFS |
| 48 | ~$ diff ${HOME}/hadoop/conf fromHDFS/ |
| 49 | }}} |
| 50 | |
| 51 | === 1.4 刪除檔案 === |
| 52 | === 1.4 Remove Files or Folder === |
| 53 | |
| 54 | {{{ |
| 55 | ~$ hadoop fs -ls toHDFS/masters |
| 56 | ~$ hadoop fs -rm toHDFS/masters |
| 57 | }}} |
| 58 | |
| 59 | === 1.5 直接看檔案 === |
| 60 | === 1.5 Browse Files Directly === |
| 61 | |
| 62 | {{{ |
| 63 | ~$ hadoop fs -ls toHDFS/slaves |
| 64 | ~$ hadoop fs -cat toHDFS/slaves |
| 65 | }}} |
| 66 | |
| 67 | === 1.6 更多指令操作 === |
| 68 | === 1.6 More Commands -- Help message === |
| 69 | |
| 70 | {{{ |
| 71 | ~$ hadoop fs |
| 72 | |
| 73 | Usage: java FsShell |
| 74 | [-ls <path>] |
| 75 | [-lsr <path>] |
| 76 | [-du <path>] |
| 77 | [-dus <path>] |
| 78 | [-count[-q] <path>] |
| 79 | [-mv <src> <dst>] |
| 80 | [-cp <src> <dst>] |
| 81 | [-rm <path>] |
| 82 | [-rmr <path>] |
| 83 | [-expunge] |
| 84 | [-put <localsrc> ... <dst>] |
| 85 | [-copyFromLocal <localsrc> ... <dst>] |
| 86 | [-moveFromLocal <localsrc> ... <dst>] |
| 87 | [-get [-ignoreCrc] [-crc] <src> <localdst>] |
| 88 | [-getmerge <src> <localdst> [addnl]] |
| 89 | [-cat <src>] |
| 90 | [-text <src>] |
| 91 | [-copyToLocal [-ignoreCrc] [-crc] <src> <localdst>] |
| 92 | [-moveToLocal [-crc] <src> <localdst>] |
| 93 | [-mkdir <path>] |
| 94 | [-setrep [-R] [-w] <rep> <path/file>] |
| 95 | [-touchz <path>] |
| 96 | [-test -[ezd] <path>] |
| 97 | [-stat [format] <path>] |
| 98 | [-tail [-f] <file>] |
| 99 | [-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...] |
| 100 | [-chown [-R] [OWNER][:[GROUP]] PATH...] |
| 101 | [-chgrp [-R] GROUP PATH...] |
| 102 | [-help [cmd]] |
| 103 | |
| 104 | Generic options supported are |
| 105 | -conf <configuration file> specify an application configuration file |
| 106 | -D <property=value> use value for given property |
| 107 | -fs <local|namenode:port> specify a namenode |
| 108 | -jt <local|jobtracker:port> specify a job tracker |
| 109 | -files <comma separated list of files> specify comma separated files to be copied to the map reduce cluster |
| 110 | -libjars <comma separated list of jars> specify comma separated jar files to include in the classpath. |
| 111 | -archives <comma separated list of archives> specify comma separated archives to be unarchived on the compute machines. |
| 112 | The general command line syntax is |
| 113 | hadoop command [genericOptions] [commandOptions] |
| 114 | }}} |