網站首頁 編程語言 正文
在生產環境中,集群節點磁盤大小不同,其使用率也會不同,HDFS雖有均衡策略,但也會有數據不平衡的情況,有些節點磁盤就會被打滿,然后這個節點就不健康了(Unhealthy Nodes),Yarn的磁盤閾值檢查(yarn.nodemanager.disk-health-checker.min-healthy-disks),默認是90%,超過這個值就會不健康,集群有個節點不健康,就會導致任務運行緩慢,之后任務再擠壓,Yarn資源被集中占用,最終影響上層服務。
問題
磁盤空間不足,待擴容,可動態增刪磁盤
yarn資源不足,待優化,可動態調整
本篇內容只添加新磁盤,yarn資源優化我們在另一篇文章再專門詳解。
官方說明
官方文檔:DataNode Hot Swap Drive
DataNode Hot Swap Drive
Datanode supports hot swappable drives. The user can add or replace HDFS data volumes without shutting down the DataNode. The following briefly describes the typical hot swapping drive procedure:
If there are new storage directories, the user should format them and mount them appropriately.
The user updates the DataNode configuration?
dfs.datanode.data.dir
?to reflect the data volume directories that will be actively in use.The user runs?
dfsadmin -reconfig datanode HOST:PORT start
?to start the reconfiguration process. The user can use?dfsadmin -reconfig datanode HOST:PORT status
?to query the running status of the reconfiguration task.Once the reconfiguration task has completed, the user can safely?
umount
?the removed data volume directories and physically remove the disks.
經過谷歌翻譯如下:
DataNode 熱插拔驅動器
Datanode 支持熱插拔驅動器。用戶可以在不關閉 DataNode 的情況下添加或替換 HDFS 數據卷。下面簡要介紹典型的熱插拔驅動器過程:
如果有新的存儲目錄,用戶應該格式化它們并適當地掛載它們。
用戶更新 DataNode 配置
dfs.datanode.data.dir
?以反映將被積極使用的數據卷目錄。用戶運行
dfsadmin -reconfig datanode HOST:PORT start
來啟動重新配置過程。用戶可以使用?dfsadmin -reconfig datanode HOST:PORT status
?查詢重配置任務的運行狀態。重新配置任務完成后,用戶可以安全地卸載已移除的數據卷目錄并物理移除磁盤。
我們先說添加新的磁盤,大意就是不需要重啟任何節點,在需要添加磁盤的節點上,添加好磁盤,這個需要運維操作,就是掛載一個新目錄,文檔中是說要配置DataNode的目錄,這里我們建議加上NameNode的目錄dfs.namenode.name.dir
,然后再執行一個使配置生效的命令,最后查看配置狀態。
具體操作
這里假設已有集群,需要加磁盤的節點為node2。運維也已經幫我們掛載好磁盤,新磁盤目錄為/data2
。
第一步:新增目錄
在node2上添加新目錄,數據目錄和元數據目錄
mkdir -p /data2/soft/hadoop/tmp/dfs/data
mkdir -p /data2/soft/hadoop/tmp/dfs/name
第二步:修改配置
修改節點node2的配置文件hdfs-site.xml,主要兩個屬性
修改前
dfs.namenode.name.dir /data/soft/hadoop/tmp/dfs/name dfs.datanode.data.dir /data/soft/hadoop/tmp/dfs/data
修改后
dfs.namenode.name.dir /data/soft/hadoop/tmp/dfs/name,/data2/soft/hadoop/tmp/dfs/name dfs.datanode.data.dir /data/soft/hadoop/tmp/dfs/data,/data2/soft/hadoop/tmp/dfs/data
第三步:使配置生效
重新配置DataNode的配置,使配置生效。
hdfs dfsadmin -reconfig datanode node2:50020 start
hdfs dfsadmin -reconfig datanode node2:50020 status
第四步:平衡數據
HDFS數據本身并不總是均勻的放置在DataNode中,在添加新磁盤后,我們需要重新平衡下數據,HDFS為我們提供了一個工具,可以分析數據塊放的位置和跨 DataNode 重新平衡數據:balancer
官方文檔:hdfs balancer
hdfs balancer [-threshold]:磁盤容量百分百,判斷集群是否平衡的目標參數,每一個 datanode 存儲使用率和集群總存儲使用率的差值都應該小于這個閥值,越小越平衡,默認10,越大平衡越快。 [-policy ]:datanode(默認):如果每個數據節點都是平衡的,則集群是平衡的。blockpool:如果每個數據節點中的每個塊池都是平衡的,則集群是平衡的。 [-exclude [-f | ]]:將指定的數據節點排除在平衡器的平衡之外。 [-include [-f | ]]:僅包括要由平衡器平衡的指定數據節點。 [-idleiterations ]:rebalanecing server啟動的線程數,默認5。
平衡前操作
在平衡時受帶寬影響,每個數據節點每秒使用的最大字節數是有限的,所以我們先臨時設置這個值,此值會覆蓋hdfs-site.xml中dfs.datanode.balance.bandwidthPerSec
的值,默認是1M,本操作命令不會持久,命令如下:
hdfs dfsadmin -setBalancerBandwidth 104857600
其他值:1024*1024=1M(1048576),52428800=50M,104857600=100M
開始平衡
本次執行平衡命令,磁盤平衡目標數為20?nohup hdfs balancer -threshold 20 > balancer.log &
其他平衡命令
平衡所有節點?nohup hdfs balancer > balancer.log &
平衡指定節點,磁盤平衡目標數為10?nohup hdfs balancer -include node7,node9,node10,node11 -threshold 10 > balancer.log &
平衡指定節點,磁盤平衡目標數,啟動線程數為10?nohup hdfs balancer -include node7,node9,node10,node11 -threshold 10 -idleiterations 10 > balancer.log &
注(可選):一般在平衡時,可以先停止存儲比較高的節點上的NodeManager,這樣在該節點上就不會受本地NodeManager落數據到本地,使得本地存儲迅速增加的影響。
yarn-daemon.sh stop nodemanager
?yarn-daemon.sh start nodemanager
原文鏈接:https://www.cnblogs.com/zhangbaohpu/p/15938072.html
相關推薦
- 2022-05-29 Linux上使用Docker部署ASP.NET?Core應用程序_實用技巧
- 2023-03-29 Python利用pynimate實現制作動態排序圖_python
- 2022-07-30 Python實現多腳本處理定時運行_python
- 2022-04-16 C語言線性表之雙鏈表詳解_C 語言
- 2022-12-22 postgresql13主從搭建Ubuntu_PostgreSQL
- 2022-04-23 C語言字符函數isalnum()和iscntrl()詳解_C 語言
- 2022-04-12 qt5之QFile讀寫文件功能詳解_C 語言
- 2022-04-21 C#?TrackBar拖動條改變滑塊顏色_C#教程
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支