您好,登錄后才能下訂單哦!
Yarn 集群資源管理系統
Yarn 角色及概念
?Yarn 是 Hadoop 的一個通用的資源管理系統
? Yarn 角色
– Resourcemanager
– Nodemanager
– ApplicationMaster
– Container
– Client
? ResourceManager
– 處理客戶端請求
– 啟動 / 監控 ApplicationMaster
– 監控 NodeManager
– 資源分配與調度
? NodeManager
– 單個節點上的資源管理
– 處理來自 ResourceManager 的命令
– 處理來自 ApplicationMaster 的命令
? Container
– 對任務運行行環境的抽象,封裝了 CPU 、內存等
– 多維資源以及環境變量、啟動命令等任務運行相關的信息資源分配與調度
? ApplicationMaster
– 數據切分
– 為應用程序申請資源,并分配給內部任務
– 任務監控與容錯
? Client
– 用戶與 YARN 交互的客戶端程序
– 提交應用程序、監控應用程序狀態,殺死應用程序等
Yarn 結構
? YARN 的核心思想
? 將 JobTracker 和 TaskTacker 進行分離,它由下面幾大構成組件:
– ResourceManager 一個全局的資源管理器
– NodeManager 每個節點(RM)代理
– ApplicationMaster 表示每個應用
– 每一個 ApplicationMaster 有多個 Container 在NodeManager 上運行
系統規劃
主機 角色 軟件
192.168.4.1 master Resource Manager YARN
192.168.4.2 node1 Node Manager YARN
192.168.4.3 node2 Node Manager YARN
192.168.4.4 node3 Node Manager YARN
Yarn 安裝與配置
具體實驗準備 可以參考 https://blog.51cto.com/13558754/2066708
# ssh 192.168.4.1
# cd /usr/local/hadoop/
# cd etc/hadoop/
# cp mapred-site.xml.template mapred-site.xml
# vim mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value> // 配置使用yarn 資源管理系統
</property>
</configuration>
# vim yarn-site.xml
<configuration>
<property>
<name>yarn.resourcemanager.hostname</name>
<value>master</value> //配置 Resource Manager 角色
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value> // 一個 java 的類 真實環境與開發人員溝通
</property>
</configuration>
配置完成以后
# for i in node{1..3} //將配置文件同步到所有主機
> do
> rsync -azSH --delete /usr/local/hadoop/etc/hadoop/ ${i}:/usr/local/hadoop/etc/hadoop -e 'ssh'
> done
# cd /usr/local/hadoop/
啟動 yarn 服務
# ./sbin/start-yarn.sh
在所有主機上執行 jps, 查看是否啟動成功
# for i in master node{1..3}
> do
> echo ${i}
> ssh ${i} "jps"
> done
master
3312 Jps
3005 ResourceManager
node1
3284 Jps
3162 NodeManager
node2
2882 NodeManager
3004 Jps
node3
2961 Jps
2831 NodeManager
顯示所有可用的計算節點
# ./bin/yarn node -list
18/01/31 06:41:56 INFO client.RMProxy: Connecting to ResourceManager at master/192.168.4.1:8032
Total Nodes:3
Node-Id Node-StateNode-Http-AddressNumber-of-Running-Containers
node3:46007 RUNNING node3:8042 0
node2:54895 RUNNING node2:8042 0
node1:51087 RUNNING node1:8042
resourcemanager
nodemangager
驗證 Yarn
# bin/hadoop fs -ls /input
Found 3 items
-rw-r--r-- 2 root supergroup 84854 2018-01-29 21:37 /input/LICENSE.txt
-rw-r--r-- 2 root supergroup 14978 2018-01-29 21:37 /input/NOTICE.txt
-rw-r--r-- 2 root supergroup 1366 2018-01-29 21:37 /input/README.txt
使用yarn 統計 樣本文件中單詞出現頻率
# ./bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.3.jar wordcount hdfs://master:9000/input hdfs://master:9000/output
查看結果
# ./bin/hadoop fs -cat hdfs://master:9000/output/*
Yarn 節點管理
[root@master ~] # cat /etc/hosts
192.168.4.1master
192.168.4.2 node1
192.168.4.3 node2
192.168.4.4 node3
192.168.4.5 newnode
[root@newnode ~]# rsync -azSH --delete master:/usr/local/hadoop /usr/local
[root@master hadoop]# ./sbin/start-yarn.sh
添加節點
[root@master hadoop]# ./bin/yarn node -list
18/01/28 21:06:57 INFO client.RMProxy: Connecting to ResourceManager at master/192.168.4.1:8032
Total Nodes:3
Node-Id Node-State Node-Http-Address Number-of-Running-Containers
node1:33596 RUNNING node1:8042 0
node2:53475 RUNNING node2:8042 0
node3:34736 RUNNING node3:8042 0
[root@newnode hadoop]# sbin/yarn-daemon.sh start nodemanager
[root@master hadoop]# ./bin/yarn node -list
18/01/28 21:07:53 INFO client.RMProxy: Connecting to ResourceManager at master/192.168.4.1:8032
Total Nodes:4
Node-Id Node-State Node-Http-Address Number-of-Running-Containers
newnode:39690 RUNNING newnode:8042 0
node1:33596 RUNNING node1:8042 0
node2:53475 RUNNING node2:8042 0
node3:34736 RUNNING node3:8042 0
刪除節點
[root@newnode hadoop]# sbin/yarn-daemon.sh stop nodemanager
//不會立即刪除
[root@master hadoop]# ./bin/yarn node -list
18/01/28 21:11:31 INFO client.RMProxy: Connecting to ResourceManager at master/192.168.4.1:8032
Total Nodes:4
Node-Id Node-State Node-Http-Address Number-of-Running-Containers
newnode:39690 RUNNING newnode:8042 0
node1:33596 RUNNING node1:8042 0
node2:53475 RUNNING node2:8042 0
node3:34736 RUNNING node3:8042 0
//需要重新啟動服務
[root@master hadoop]# ./sbin/stop-yarn.sh
[root@master hadoop]# ./sbin/start-yarn.sh
[root@master hadoop]# ./bin/yarn node -list
18/01/28 21:12:46 INFO client.RMProxy: Connecting to ResourceManager at master/192.168.4.1:8032
Total Nodes:3
Node-Id Node-State Node-Http-Address Number-of-Running-Containers
node1:42010 RUNNING node1:8042 0
node2:55043 RUNNING node2:8042 0
node3:38256 RUNNING node3:8042 0
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。