這篇文章主要介紹“hadoop常用操作命令有哪些”,在日常操作中,相信很多人在hadoop常用操作命令有哪些問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”hadoop常用操作命令有哪些”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!
在茶陵等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站制作、外貿(mào)網(wǎng)站建設(shè) 網(wǎng)站設(shè)計(jì)制作定制制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),高端網(wǎng)站設(shè)計(jì),成都全網(wǎng)營(yíng)銷推廣,外貿(mào)網(wǎng)站制作,茶陵網(wǎng)站建設(shè)費(fèi)用合理。
dfsadmin命令
report各幾點(diǎn)使用狀態(tài)
[hdfs@hd3 ~]$ hadoop dfsadmin -report
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.
Configured Capacity: 768761769165 (715.97 GB)
Present Capacity: 739275145216 (688.50 GB)
DFS Remaining: 728906240000 (678.85 GB)
DFS Used: 10368905216 (9.66 GB)
DFS Used%: 1.40%
Under replicated blocks: 0
Blocks with corrupt replicas: 0
Missing blocks: 0
-------------------------------------------------
Datanodes available: 4 (4 total, 0 dead)
Live datanodes:
Name: 10.202.11.20:50010 (hd1)
Hostname: hd1
Rack: /default
Decommission Status : Normal
Configured Capacity: 137276063744 (127.85 GB)
DFS Used: 3119067136 (2.90 GB)
Non DFS Used: 6016712704 (5.60 GB)
DFS Remaining: 128140283904 (119.34 GB)
DFS Used%: 2.27%
DFS Remaining%: 93.34%
Last contact: Fri Jul 25 11:20:55 CST 2014
Name: 10.202.11.21:50010 (hd2)
Hostname: hd2
Rack: /default
Decommission Status : Normal
Configured Capacity: 64706464973 (60.26 GB)
DFS Used: 2280718336 (2.12 GB)
Non DFS Used: 2592439501 (2.41 GB)
DFS Remaining: 59833307136 (55.72 GB)
DFS Used%: 3.52%
DFS Remaining%: 92.47%
Last contact: Fri Jul 25 11:20:55 CST 2014
Name: 10.202.11.22:50010 (hd3)
Hostname: hd3
Rack: /default
Decommission Status : Normal
Configured Capacity: 226409611264 (210.86 GB)
DFS Used: 2314543104 (2.16 GB)
Non DFS Used: 7515787264 (7.00 GB)
DFS Remaining: 216579280896 (201.71 GB)
DFS Used%: 1.02%
DFS Remaining%: 95.66%
Last contact: Fri Jul 25 11:20:55 CST 2014
Name: 10.202.11.23:50010 (hd4)
Hostname: hd4
Rack: /default
Decommission Status : Normal
Configured Capacity: 340369629184 (316.99 GB)
DFS Used: 2654576640 (2.47 GB)
Non DFS Used: 13361684480 (12.44 GB)
DFS Remaining: 324353368064 (302.08 GB)
DFS Used%: 0.78%
DFS Remaining%: 95.29%
Last contact: Fri Jul 25 11:20:55 CST 2014
safemode進(jìn)入和離開安全模式
查看模式
[hdfs@hd2 ~]$ hadoop dfsadmin -safemode get
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.
Safe mode is OFF
進(jìn)入安全模式
[hdfs@hd2 ~]$ hadoop dfsadmin -safemode enter
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.
Safe mode is ON
nodename在啟動(dòng)時(shí)會(huì)處在安全模式,用這條命令可確保啟動(dòng)完成后不離開安全模式。也可以指定dfs.sfaemode.threshold.pct設(shè)置>1
離開安全模式
[hdfs@hd2 ~]$ hadoop dfsadmin -safemode leave
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.
Safe mode is OFF
在執(zhí)行某條命令時(shí)臨時(shí)先退出安全模式,前面寫:
[hdfs@hd2 ~]$ hadoop dfsadmin -safemode wait
Fsck檢查HDFS文件監(jiān)控狀況
檢查某個(gè)集群文件系統(tǒng)
[hdfs@hd1 ~]$ hadoop fsck /
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.
Connecting to namenode via http://hd1:50070
FSCK started by hdfs (auth:SIMPLE) from /10.202.11.20 for path / at Tue Aug 19 14:35:53 CST 2014
....................................................................................................
....................................................................................................
....................................................................................................
.............................................Status: HEALTHY
Total size: 5120355488 B
Total dirs: 176
Total files: 345
Total blocks (validated): 364 (avg. block size 14066910 B)
Minimally replicated blocks: 364 (100.0 %)
Over-replicated blocks: 0 (0.0 %)
Under-replicated blocks: 0 (0.0 %)
Mis-replicated blocks: 0 (0.0 %)
Default replication factor: 3
Average block replication: 2.6923077
Corrupt blocks: 0
Missing replicas: 0 (0.0 %)
Number of data-nodes: 4
Number of racks: 1
FSCK ended at Tue Aug 19 14:35:53 CST 2014 in 86 milliseconds
The filesystem under path '/' is HEALTHY
查詢特定文件的數(shù)據(jù)塊和分佈節(jié)點(diǎn)
[hdfs@hd2 ~]$ hadoop fsck /user/gc/hdfs_file -files -blocks -racks
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.
Connecting to namenode via http://hd1:50070
FSCK started by hdfs (auth:SIMPLE) from /10.202.11.21 for path /user/gc/hdfs_file at Thu Sep 04 10:15:25 CST 2014
/user/gc/hdfs_file 19 bytes, 1 block(s): OK
0. BP-2070684995-10.202.11.20-1405329506510:blk_9027993399902156289_85985 len=19 repl=3 [/default/10.202.11.22:50010, /default/10.202.11.20:50010, /default/10.202.11.23:50010]
Status: HEALTHY
Total size: 19 B
Total dirs: 0
Total files: 1
Total blocks (validated): 1 (avg. block size 19 B)
Minimally replicated blocks: 1 (100.0 %)
Over-replicated blocks: 0 (0.0 %)
Under-replicated blocks: 0 (0.0 %)
Mis-replicated blocks: 0 (0.0 %)
Default replication factor: 3
Average block replication: 3.0
Corrupt blocks: 0
Missing replicas: 0 (0.0 %)
Number of data-nodes: 4
Number of racks: 1
FSCK ended at Thu Sep 04 10:15:25 CST 2014 in 1 milliseconds
刪除文件
hadoop fs –rm–f /user/hive/xx
刪除文件夾
hadoop fs –rmr–f /user/hive/xx
copyFromLocal複製本地文件到HDFS
[hdfs@SCQHADoopN01 data]$ hadoop fs -copyFromLocal /data/copyToLocal_gc /user/hive/warehouse/test/part-m-00000-gc
[hdfs@SCQHADoopN01 data]$ hadoop fs -cat /user/hive/warehouse/test/part-m-00000-gc
1,abc
1,haha
copyToLocal複製hdfs文件到本地
[hdfs@SCQHADoopN01 data]$ hadoop fs -copyToLocalhdfs://nameservice1/user/hive/warehouse/test/part-m-00000 /data/copyToLocal_gc
[hdfs@SCQHADoopN01 data]$ cd /data/
[hdfs@SCQHADoopN01 data]$ ll
total 16
-rw-r--r-- 1 hdfs hdfs 13 Nov 5 15:47 copyToLocal_gc
-rw-rw-r-- 1 hdfs hdfs 19 Aug 28 14:11 hdfs_file
drwxr-xr-x 3 root root 4096 Aug 28 08:52 mapred
drwx------ 3 hdfs hadoop 4096 Oct 10 14:01 nn
[hdfs@SCQHADoopN01 data]$ more copyToLocal_gc
1,abc
1,haha
到此,關(guān)于“hadoop常用操作命令有哪些”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!