1、格式化
[root@master sbin]# hdfs namenode -format
2、命令hdfs dfsadmin
- 查看(hdfs dfsadmin -report)
[root@master ~]# hdfs dfsadmin -report
- 安全模式
#获取安全模式状态[root@master ~]# hdfs dfsadmin -safemode get#进入安全状态[root@master ~]# hdfs dfsadmin -safemode enter#离开安全模式[root@master ~]# hdfs dfsadmin -safemode leave
- 刷新节点
[root@master ~]# hdfs dfsadmin -refreshNodesRefresh nodes successful
- 打印网络拓扑
[root@master ~]# hdfs dfsadmin -printTopologyRack: /default-rack 192.168.30.11:50010 (slave1) 192.168.30.12:50010 (slave2) 192.168.30.13:50010 (slave3)
5、命令 hdfs fsck
- 查看坏块
[root@node1 ~]# hdfs fsck -list-corruptfileblocksConnecting to namenode via http://node1:50070The filesystem under path '/' has 0 CORRUPT files[root@node1 ~]# hdfs fsck -locationsConnecting to namenode via http://node1:50070FSCK started by root (auth:SIMPLE) from /192.168.30.11 for path / at Thu Jan 30 22:38:10 CST 2020.Status: HEALTHY Total size:1414 B Total dirs:3 Total files:1 Total symlinks:0 Total blocks (validated):1 (avg. block size 1414 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:3 Number of racks:1FSCK ended at Thu Jan 30 22:38:10 CST 2020 in 1 millisecondsThe filesystem under path '/' is HEALTHY
- 删除坏块
[root@node1 ~]# hdfs fsck -delete
6、命令hdfs balancer
- 设置平衡阀
[root@node1 ~]# hdfs balancer -threshold 10
7、配置机架感知
- 修改core-site.xml文件
topology.script.file.name/opt/hadoop/etc/hadoop/topology.py
- 创建对应文件
[root@node1 current]# vi /opt/hadoop/etc/hadoop/topology.py#添加如下代码:#!/usr/bin/python#coding=utf-8import sysrack={"192.168.30.12":"/dc1/rack1", "192.168.30.13":"/dc1/rack1", "192.168.30.14":"/dc1/rack2", "node2":"/dc1/rack1", "node3":"/dc1/rack1", "node4":"/dc1/rack2" }if __name__=="__main__": print rack.get(sys.argv[1],"/default-rack")
- 添加执行权限
[root@node1 current]#chmod u+x topology.py