namenode如何判断一个datanode宕机了?
连续的10次心跳报告接受不到 连续30s接受不到datanode的心跳
认为datanode可能宕机了 不能判定宕机
namenode会主动的向datanode发送检查:300000ms=300s=5min
查看一次检查时间的源代码:
<property>
<name>dfs.namenode.heartbeat.recheck-interval</name>
<value>300000</value>
<description>
This time decides the interval to check for expired datanodes.
With this value and dfs.heartbeat.interval, the interval of
deciding the datanode is stale or not is also calculated.
The unit of this configuration is millisecond.
</description>
</property>
默认情况下 检查2次 10min 断定datanode宕机了
namenode断定datanode宕机的时间:
103s+25min=630s
datanode 8次没有心跳 第九次有心跳了 第十次又没有心跳了
重新记录时间
集群启动过程中自动离开安全模式的依据:
1)datanode节点的启动的个数:默认0
<property>
<name>dfs.namenode.safemode.min.datanodes</name>
<value>0</value>
<description>
Specifies the number of datanodes that must be considered alive
before the name node exits safemode.
Values less than or equal to 0 mean not to take the number of live
datanodes into account when deciding whether to remain in safe mode
during startup.
Values greater than the number of datanodes in the cluster
will make safe mode permanent.
</description>
</property>
默认情况下 集群中的datanode节点启动0个也可以离开安全模式
2)数据块(排除副本)的汇报情况
集群处于安全模式的时候 每一个数据块的副本最小保证个数 默认1个
\<property>
\<name>dfs.namenode.replication.min\</name>
\<value>1\</value>
\<description>Minimal block replication.
\</description>
\</property>
所有数据块的存活率(不考虑副本的)
假设集群中 10000个数据块 至少0.999*10000=9990个数据块正常的才能离开安全模式
如果数据块少于这个数 这个时候集群一直处于安全模式
<property>
<name>dfs.namenode.safemode.threshold-pct</name>
<value>0.999f</value>
<description>
Specifies the percentage of blocks that should satisfy
the minimal replication requirement defined by dfs.namenode.replication.min.
Values less than or equal to 0 mean not to wait for any particular
percentage of blocks before exiting safemode.
Values greater than 1 will make safe mode permanent.
</description>
</property>
手动进入和离开安全模式的命令:
hdfs dfsadmin -safemode enter/leave/get/wait
enter 进入安全模式
leave 离开安全模式
get 获取安全模式的状态
wait 等待离开安全模式
负载均衡:
hdfs来说 负载均衡指的是每一个datanode节点上存储的数据和他的硬件匹配 实际上说的是占有率相当的
小实例:
7T
datanode01 8T 2T 25%
datanode02 4T 1T 25%
datanode03 16T 4T 25%
观察集群 2节点上存储的数据比较多 集群不处于负载均衡
集群如果没有处于负载均衡的时候 集群会自动进行负载均衡的
进行负载均衡的过程 说白了就是数据块的移动的过程 肯定跨节点 跨机架 需要网络传输
下面的参数 集群自动进行负载均衡的带宽 很慢 默认1M/s
<property>
<name>dfs.datanode.balance.bandwidthPerSec</name>
<value>1048576</value>
<description>
Specifies the maximum amount of bandwidth that each datanode
can utilize for the balancing purpose in term of
the number of bytes per second.
</description>
</property>
集群规模的比较小的情况下 20个节点以下 自动进行负载均衡就可以了
集群的规模比较大的时候:1000个节点
自动进行负载均衡 太慢了
这个手动进行负载均衡
1)修改负载均衡的带宽 加大
<property>
<name>dfs.datanode.balance.bandwidthPerSec</name>
<value>104857600000</value>
<description>
Specifies the maximum amount of bandwidth that each datanode
can utilize for the balancing purpose in term of
the number of bytes per second.
</description>
</property>