新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

hadoop常用操作命令有哪些-创新互联

这篇文章主要介绍“hadoop常用操作命令有哪些”,在日常操作中,相信很多人在hadoop常用操作命令有哪些问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”hadoop常用操作命令有哪些”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

成都创新互联公司服务项目包括溆浦网站建设、溆浦网站制作、溆浦网页制作以及溆浦网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,溆浦网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到溆浦省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!

dfsadmin命令

report各幾點使用狀態

[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進入和離開安全模式

查看模式

[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

進入安全模式

[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在啟動時會處在安全模式,用這條命令可確保啟動完成后不離開安全模式。也可以指定dfs.sfaemode.threshold.pct設置>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

在執行某條命令時臨時先退出安全模式,前面寫:

[hdfs@hd2 ~]$ hadoop dfsadmin -safemode wait

Fsck檢查HDFS文件監控狀況

檢查某個集群文件系統

[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

查詢特定文件的數據塊和分佈節點

[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 -copyToLocal hdfs://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

到此,关于“hadoop常用操作命令有哪些”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联-成都网站建设公司网站,小编会继续努力为大家带来更多实用的文章!


文章名称:hadoop常用操作命令有哪些-创新互联
链接URL:http://wjwzjz.com/article/dceoid.html
在线咨询
服务热线
服务热线:028-86922220
TOP