HDFS常用命令汇总
[toc]
# 查看是否处于安全模式
hdfs dfsadmin -safemode get
ON 说明是安全模式,OFF 说明不是安全模式
# 进入安全模式
hdfs dfsadmin -safemode enter 进入安全模式
# 离开安全模式
# 正常退出安全模式
hdfs dfsadmin -safemode leave
# 强制退出安全模式
hdfs dfsadmin -safemode forceExit
# 永久删除-跳过保存垃圾回收
dfs -rm -r -skipTrash xxx
# 删除损坏的block
hdfs fsck / -delete
# 查找损坏文件
hdfs fsck /
提示The filesystem under path '/' is CORRUPT(损坏)
说明文件有损坏
提示The filesystem under path '/' is HEALTHY
说明没有问题
# 查看HDFS存储状况基本信息
hdfs dfsadmin -report
[hadoop@10 ~]$ hdfs dfsadmin -report
WARNING: log4j.properties is not found. HADOOP_CONF_DIR may be incomplete.
Configured Capacity: 2527351275520 (2.30 TB) # HDFS可使用总空间
Present Capacity: 2470737033342 (2.25 TB)
DFS Remaining: 1337485683996 (1.22 TB) # HDFS磁盘未使用总量
DFS Used: 1133251349346 (1.03 TB) # HDFS磁盘使用总量
DFS Used%: 45.87% # HDFS磁盘使用百分比
Replicated Blocks:
Under replicated blocks: 28
Blocks with corrupt replicas: 0
Missing blocks: 0
Missing blocks (with replication factor 1): 0
Low redundancy blocks with highest priority to recover: 0
Pending deletion blocks: 41
Erasure Coded Block Groups:
Low redundancy block groups: 0
Block groups with corrupt internal blocks: 0
Missing block groups: 0
Low redundancy blocks with highest priority to recover: 0
Pending deletion blocks: 0
-------------------------------------------------
Live datanodes (5):
Name: 10.16.0.10:4001 (10.16.0.10)
Hostname: 10.16.0.10
Decommission Status : Normal # 节点状态 Normal:正常,Decommissioned in Program:节点停用中(数据正在迁移),Decommissioned:停用(数据已迁移完成)
Configured Capacity: 509765222400 (474.76 GB)
DFS Used: 228121735262 (212.45 GB) # DataNode节点中HDFS磁盘使用总量
Non DFS Used: 15205613474 (14.16 GB) # DataNode节点中非HDFS磁盘使用总量
DFS Remaining: 264576806689 (246.41 GB) # DataNode节点中HDFS磁盘空闲总量
DFS Used%: 44.75% # DataNode节点中HDFS磁盘使用百分比
DFS Remaining%: 51.90% # DataNode节点中HDFS磁盘空闲百分比
Configured Cache Capacity: 0 (0 B)
Cache Used: 0 (0 B)
Cache Remaining: 0 (0 B)
Cache Used%: 100.00%
Cache Remaining%: 0.00%
Xceivers: 18
Last contact: Fri Jan 13 10:51:27 CST 2023
Last Block Report: Fri Jan 13 10:07:15 CST 2023
Num of Blocks: 192701
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# HDFS数据均衡
./start-balancer.sh -threshold 5\
-Ddfs.datanode.balance.max.concurrent.moves=20 \
-Ddfs.datanode.balance.bandwidthPerSec=150000000 \
-Ddfs.balancer.moverThreads=500 \
-Ddfs.balancer.dispatcherThreads=100
1
2
3
4
5
2
3
4
5
或者
hdfs balancer -threshold 1
1
说明
hdfs balancer
[-threshold <threshold>]
[-policy <policy>]
[-exclude [-f <hosts-file> | <comma-separated list of hosts>]]
[-include [-f <hosts-file> | <comma-separated list of hosts>]]
[-idleiterations <idleiterations>]
1
2
3
4
5
6
2
3
4
5
6
参数说明:
参数 | 说明 |
---|---|
-threshold | 某datanode的使用率和整个集群使用率的百分比差值阈值,达到这个阈值就启动hdfs balancer,取值从1到100,不宜太小,因为在平衡过程中也有数据写入,太小无法达到平衡 |
-policy | 分为blockpool和datanode,前者是block pool级别的平衡后者是datanode级别的平衡 |
-exclude | 不为空,则不在这些机器上进行平衡 |
-include | 不为空,则仅在这些机器上进行平衡 |
-idleiterations | 最大迭代次数 |
上次更新: 2023/03/10, 20:58:04