生产环境这个值长期大于0,但是又没有特别大,虽然看起来没有实际影响,但是猜测应该还是哪里有点问题
执行命令:
su hdfs -c "hdfs fsck / -files -blocks -locations | grep Under“
可以看到是因为文件副本数设置为10,但是DataNode只有9个节点,因此导致识别为副本数缺失
看了下这些文件,都是两年前的,猜测是以前参数设置不当,导致文件副本数过高
手动把这些文件副本数改成3:
hdfs dfs -setrep -w 3 -R /user/yarn/.staging
hdfs dfs -setrep -w 3 -R /user/hive/.staging
hdfs dfs -setrep -w 3 -R /user/hdfs/.staging
再查看Number of Under-Replicated Blocks,已经恢复为0
参考:
https://www.ibm.com/docs/en/npi/1.3.1?topic=tas-ambari-hdfs-metric-showing-huge-value-under-replicated-blocks-in-single-node-environment
https://www.netjstech.com/2018/07/how-to-handle-corrupt-missing-under-replicated-hdfs-blocks.html