測試之集群性能測試
1 DFSIO測試
在Hadoop中包含很多的基准測試,用來驗證集群的HDFS是不是設置合理,性能是不是達到預期,DFSIO是Hadoop的一個基准測試工具,被用來分析集群HDFS的I/O性能。
DFSIO后台執行MapReduce框架,其中Map任務以並行方式讀寫文件,Reduce任務用來收集和匯總性能數字。可以通過這個基准測試對比吞吐量、IO速率的結果以及整個磁盤的原始速度,來確定你的集群是否得到了期待的性能。另外,可以通過這些測試中指標的嚴重偏差發現集群中一個或多個問題節點,結合監控系統一起使用能夠更好的定位Hadoop集群的瓶頸所在。
2 寫性能測試
執行以下命令來運行HDFS寫性能測試,其中參數-nrFiles指定了測試中要寫的文件數目,參數-fileSize指明了寫入每個文件的大小單位是MB。該命令會在HDFS上產生一系列的文件存放在HDFS的/benchmarks/TestDFSIO文件夾下。
請注意,由於部署了Kerberos,hdfs不允許任意讀寫,此時需要kinit某個用戶,然后指定TestDFSIO的寫目錄,指定方法為:
添加參數-D test.build.data=/user/用戶名/benchmark
由於我們yarn配置了允許的用戶:
所以用以上用戶來測試,這里我選擇hive用戶。
[root@hadoop101 ~]# kinit hive [root@hadoop101 ~]# hadoop jar /opt/cloudera/parcels/CDH/lib/hadoop-mapreduce/hadoop-mapreduce-client-jobclient-2.6.0-cdh5.12.1-tests.jar TestDFSIO -D test.build.data=/user/hive/benchmark -write -nrFiles 100 -fileSize 10
====沒有配置,我們則用Hdfs用戶來測試:
[hdfs@hadoop101 ~]$ hadoop jar /home/kris/apps/usr/webserver/cloudera/parcels/CDH/lib/hadoop-mapreduce/hadoop-mapreduce-client-jobclient-2.6.0-cdh5.14.2-tests.jar TestDFSIO -write -nrFiles 100 -fileSize 10
20/04/21 22:44:58 INFO fs.TestDFSIO: TestDFSIO.1.7
20/04/21 22:44:58 INFO fs.TestDFSIO: nrFiles = 100
20/04/21 22:44:58 INFO fs.TestDFSIO: nrBytes (MB) = 10.0
20/04/21 22:44:58 INFO fs.TestDFSIO: bufferSize = 1000000
20/04/21 22:44:58 INFO fs.TestDFSIO: baseDir = /benchmarks/TestDFSIO 20/04/21 22:44:59 INFO fs.TestDFSIO: creating control file: 10485760 bytes, 100 files 20/04/21 22:45:01 INFO fs.TestDFSIO: created control files for: 100 files 20/04/21 22:45:01 INFO client.RMProxy: Connecting to ResourceManager at el-hadoop-3/172.26.0.109:8032
20/04/21 22:45:01 INFO client.RMProxy: Connecting to ResourceManager at el-hadoop-3/172.26.0.109:8032
20/04/21 22:45:01 INFO mapred.FileInputFormat: Total input paths to process : 100
20/04/21 22:45:01 INFO mapreduce.JobSubmitter: number of splits:100
20/04/21 22:45:01 INFO Configuration.deprecation: io.bytes.per.checksum is deprecated. Instead, use dfs.bytes-per-checksum 20/04/21 22:45:01 INFO Configuration.deprecation: dfs.https.address is deprecated. Instead, use dfs.namenode.https-address 20/04/21 22:45:02 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1586707133037_8119 20/04/21 22:45:02 INFO impl.YarnClientImpl: Submitted application application_1586707133037_8119 20/04/21 22:45:02 INFO mapreduce.Job: The url to track the job: http://el-hadoop-3:8088/proxy/application_1586707133037_8119/
20/04/21 22:45:02 INFO mapreduce.Job: Running job: job_1586707133037_8119 20/04/21 22:45:08 INFO mapreduce.Job: Job job_1586707133037_8119 running in uber mode : false
20/04/21 22:45:08 INFO mapreduce.Job: map 0% reduce 0%
20/04/21 22:45:16 INFO mapreduce.Job: map 2% reduce 0%
20/04/21 22:45:17 INFO mapreduce.Job: map 7% reduce 0% ... File Input Format Counters Bytes Read=11290 File Output Format Counters Bytes Written=81
20/04/21 22:46:25 INFO fs.TestDFSIO: ----- TestDFSIO ----- : write
20/04/21 22:46:25 INFO fs.TestDFSIO: Date & time: Tue Apr 21 22:46:25 CST 2020
20/04/21 22:46:25 INFO fs.TestDFSIO: Number of files: 100
20/04/21 22:46:25 INFO fs.TestDFSIO: Total MBytes processed: 1000.0
20/04/21 22:46:25 INFO fs.TestDFSIO: Throughput mb/sec: 16.99004383431309
20/04/21 22:46:25 INFO fs.TestDFSIO: Average IO rate mb/sec: 19.468568801879883
20/04/21 22:46:25 INFO fs.TestDFSIO: IO rate std deviation: 9.590634021553296
20/04/21 22:46:25 INFO fs.TestDFSIO: Test exec time sec: 83.914
20/04/21 22:46:25 INFO fs.TestDFSIO:
讀性能測試
性能基准測試針對HDFS的讀操作進行,讀操作將用到第一步的寫操作,因此寫操作必須在讀操作之前執行
[hdfs@hadoop101 ~]$ hadoop jar /home/kris/apps/usr/webserver/cloudera/parcels/CDH/lib/hadoop-mapreduce/hadoop-mapreduce-client-jobclient-2.6.0-cdh5.14.2-tests.jar TestDFSIO -read -nrFiles 100 -fileSize 10
20/04/21 22:49:25 INFO fs.TestDFSIO: TestDFSIO.1.7
20/04/21 22:49:25 INFO fs.TestDFSIO: nrFiles = 100
20/04/21 22:49:25 INFO fs.TestDFSIO: nrBytes (MB) = 10.0
20/04/21 22:49:25 INFO fs.TestDFSIO: bufferSize = 1000000
20/04/21 22:49:25 INFO fs.TestDFSIO: baseDir = /benchmarks/TestDFSIO 20/04/21 22:49:26 INFO fs.TestDFSIO: creating control file: 10485760 bytes, 100 files 20/04/21 22:49:29 INFO fs.TestDFSIO: created control files for: 100 files 20/04/21 22:49:29 INFO client.RMProxy: Connecting to ResourceManager at el-hadoop-3/172.26.0.109:8032
20/04/21 22:49:29 INFO client.RMProxy: Connecting to ResourceManager at el-hadoop-3/172.26.0.109:8032
20/04/21 22:49:29 INFO mapred.FileInputFormat: Total input paths to process : 100
20/04/21 22:49:29 INFO mapreduce.JobSubmitter: number of splits:100
20/04/21 22:49:29 INFO Configuration.deprecation: io.bytes.per.checksum is deprecated. Instead, use dfs.bytes-per-checksum 20/04/21 22:49:29 INFO Configuration.deprecation: dfs.https.address is deprecated. Instead, use dfs.namenode.https-address ... File Input Format Counters Bytes Read=11290 File Output Format Counters Bytes Written=84
20/04/21 22:50:46 INFO fs.TestDFSIO: ----- TestDFSIO ----- : read 20/04/21 22:50:46 INFO fs.TestDFSIO: Date & time: Tue Apr 21 22:50:46 CST 2020
20/04/21 22:50:46 INFO fs.TestDFSIO: Number of files: 100
20/04/21 22:50:46 INFO fs.TestDFSIO: Total MBytes processed: 1000.0
20/04/21 22:50:46 INFO fs.TestDFSIO: Throughput mb/sec: 217.10811984368215
20/04/21 22:50:46 INFO fs.TestDFSIO: Average IO rate mb/sec: 288.4814147949219
20/04/21 22:50:46 INFO fs.TestDFSIO: IO rate std deviation: 131.65626363914566
20/04/21 22:50:46 INFO fs.TestDFSIO: Test exec time sec: 77.665
20/04/21 22:50:46 INFO fs.TestDFSIO:
清理測試數據
[hdfs@el-hadoop101 ~]$ hadoop jar /home/kris/apps/usr/webserver/cloudera/parcels/CDH/lib/hadoop-mapreduce/hadoop-mapreduce-client-jobclient-2.6.0-cdh5.14.2-tests.jar TestDFSIO -clean 20/04/21 22:52:32 INFO fs.TestDFSIO: TestDFSIO.1.7
20/04/21 22:52:32 INFO fs.TestDFSIO: nrFiles = 1
20/04/21 22:52:32 INFO fs.TestDFSIO: nrBytes (MB) = 1.0
20/04/21 22:52:32 INFO fs.TestDFSIO: bufferSize = 1000000
20/04/21 22:52:32 INFO fs.TestDFSIO: baseDir = /benchmarks/TestDFSIO 20/04/21 22:52:33 INFO fs.TestDFSIO: Cleaning up test files
測試參考
在某一集群運行此命令,此集群配置10個datanode和3個namenode,每個節點采用10塊2T硬盤,128G內存,32核CPU,采用雙千兆網口,結果如下:
序號 |
操作 |
文件數目 |
文件大小 |
吞吐量(mb/sec) |
平均IO速率(mb/sec) |
IO速率標准差 |
消耗時間(sec) |
1 |
寫 |
100 |
1000 |
31.01 |
134.33 |
285.7 |
74.52 |
2 |
寫 |
1000 |
100 |
79.53 |
129.08 |
119.17 |
116 |
3 |
寫 |
1000 |
1000 |
17.59 |
34.45 |
65.44 |
431.6 |
4 |
讀 |
10 |
100 |
58.63 |
64.07 |
20.79 |
34.05 |
5 |
讀 |
1000 |
100 |
8.07 |
10.49 |
6.33 |
104.78 |
6 |
讀 |
1000 |
1000 |
5.64 |
6.13 |
1.84 |
1220.84 |
TeraSort測試
Hadoop的TeraSort是一個常用的測試,目的是利用MapReduce來盡可能快的對數據進行排序。TeraSort使用MapReduce框架通過分區操作將Map過程中的結果輸出到Reduce任務,確保整體排序的順序。TeraSort測試可以很好的對MapReduce框架的每個過程進行壓力測試,為調優和配置Hadoop集群提供一個合理的參考。
生成測試數據
在進行TeraSort測試之前的一個准備過程就是數據的產生,可以使用teragen命令來生成TeraSort測試輸入的數據。teragen命令的第一個參數是記錄的數目,第二個參數是生成數據的HDFS目錄。下面這個命令在HDFS的terasort-input目錄中生成1GB的數據,由1千萬條記錄組成。
[root@hadoop101 ~]#
time hadoop jar /opt/cloudera/parcels/CDH/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar teragen 10000000 /user/hive/terasort-input
[hdfs@hadoop101 ~]$ time hadoop jar /home/hopson/apps/usr/webserver/cloudera/parcels/CDH/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar teragen 10000000 /user/hive/terasort-input 20/04/21 22:57:23 INFO client.RMProxy: Connecting to ResourceManager at el-hadoop-3/172.26.0.109:8032
20/04/21 22:57:24 INFO terasort.TeraGen: Generating 10000000 using 2
20/04/21 22:57:24 INFO mapreduce.JobSubmitter: number of splits:2
20/04/21 22:57:24 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1586707133037_8121 20/04/21 22:57:24 INFO impl.YarnClientImpl: Submitted application application_1586707133037_8121 20/04/21 22:57:24 INFO mapreduce.Job: The url to track the job: http://el-hadoop-3:8088/proxy/application_1586707133037_8121/
20/04/21 22:57:24 INFO mapreduce.Job: Running job: job_1586707133037_8121 .. FILE: Number of write operations=0 HDFS: Number of bytes read=167 HDFS: Number of bytes written=1000000000 HDFS: Number of read operations=8 HDFS: Number of large read operations=0 HDFS: Number of write operations=4 Job Counters Launched map tasks=2 Other local map tasks=2 Total time spent by all maps in occupied slots (ms)=23479 Total time spent by all reduces in occupied slots (ms)=0 Total time spent by all map tasks (ms)=23479 Total vcore-milliseconds taken by all map tasks=23479 Total megabyte-milliseconds taken by all map tasks=24042496 Map-Reduce Framework Map input records=10000000 Map output records=10000000 Input split bytes=167 Spilled Records=0 Failed Shuffles=0 Merged Map outputs=0 GC time elapsed (ms)=319 CPU time spent (ms)=19430 Physical memory (bytes) snapshot=717750272 Virtual memory (bytes) snapshot=5582888960 Total committed heap usage (bytes)=910163968 org.apache.hadoop.examples.terasort.TeraGen$Counters CHECKSUM=21472776955442690 File Input Format Counters Bytes Read=0 File Output Format Counters Bytes Written=1000000000 real 0m23.727s user 0m6.806s sys 0m0.411s
執行測試
對於TeraSort第一個參數是HDFS上輸入文件的路徑,第二個參數是HDFS上輸出結果的路徑。
[root@hadoop101 ~]#
time hadoop jar /opt/cloudera/parcels/CDH/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar terasort /user/hive/terasort-input /user/hive/terasort-ouput
[hdfs@hadoop101 ~]$ time hadoop jar /home/hopson/apps/usr/webserver/cloudera/parcels/CDH/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar terasort /user/hive/terasort-input /user/hive/terasort-ouput 20/04/21 23:02:08 INFO terasort.TeraSort: starting 20/04/21 23:02:10 INFO input.FileInputFormat: Total input paths to process : 2 Spent 128ms computing base-splits. Spent 3ms computing TeraScheduler splits. Computing input splits took 131ms Sampling 8 splits of 8 Making 4 from 100000 sampled records Computing parititions took 867ms Spent 1000ms computing partitions .. HDFS: Number of bytes read=1000001008 HDFS: Number of bytes written=1000000000 HDFS: Number of read operations=36 HDFS: Number of large read operations=0 HDFS: Number of write operations=8 Job Counters Launched map tasks=8 Launched reduce tasks=4 Data-local map tasks=8 Total time spent by all maps in occupied slots (ms)=88911 Total time spent by all reduces in occupied slots (ms)=47828 Total time spent by all map tasks (ms)=88911 Total time spent by all reduce tasks (ms)=47828 Total vcore-milliseconds taken by all map tasks=88911 Total vcore-milliseconds taken by all reduce tasks=47828 Total megabyte-milliseconds taken by all map tasks=91044864 Total megabyte-milliseconds taken by all reduce tasks=48975872 Map-Reduce Framework Map input records=10000000 Map output records=10000000 Map output bytes=1020000000 Map output materialized bytes=436911769 Input split bytes=1008 Combine input records=0 Combine output records=0 Reduce input groups=10000000 Reduce shuffle bytes=436911769 Reduce input records=10000000 Reduce output records=10000000 Spilled Records=20000000 Shuffled Maps =32 Failed Shuffles=0 Merged Map outputs=32 GC time elapsed (ms)=4132 CPU time spent (ms)=101330 Physical memory (bytes) snapshot=7406276608 Virtual memory (bytes) snapshot=33618665472 Total committed heap usage (bytes)=8776056832 Shuffle Errors BAD_ID=0 CONNECTION=0 IO_ERROR=0 WRONG_LENGTH=0 WRONG_MAP=0 WRONG_REDUCE=0 File Input Format Counters Bytes Read=1000000000 File Output Format Counters Bytes Written=1000000000
20/04/21 23:02:49 INFO terasort.TeraSort: done real 0m42.053s user 0m8.690s sys 0m0.413s
驗證
驗證TeraSort基准測試程序結果的正確性,可以使用teravalidate命令來執行。第一個參數是排序的結果集的HDFS上的位置。第二個參數是驗證結果集正確性的報告存放位置。
[root@hadoop101 ~]#
time hadoop jar /opt/cloudera/parcels/CDH/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar teravalidate /user/hive/terasort-ouput /user/hive/terasort-validate
[hdfs@hadoop101 ~]$ time hadoop jar /home/kris/apps/usr/webserver/cloudera/parcels/CDH/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar teravalidate /user/hive/terasort-ouput /user/hive/terasort-validate 20/04/21 23:05:20 INFO client.RMProxy: Connecting to ResourceManager at el-hadoop-3/172.26.0.109:8032
20/04/21 23:05:20 INFO input.FileInputFormat: Total input paths to process : 4 Spent 20ms computing base-splits. Spent 3ms computing TeraScheduler splits. 20/04/21 23:05:20 INFO mapreduce.JobSubmitter: number of splits:4 ... 20/04/21 23:05:43 INFO mapreduce.Job: Counters: 50 File System Counters FILE: Number of bytes read=256 FILE: Number of bytes written=746005 FILE: Number of read operations=0 FILE: Number of large read operations=0 FILE: Number of write operations=0 HDFS: Number of bytes read=1000000504 HDFS: Number of bytes written=24 HDFS: Number of read operations=15 HDFS: Number of large read operations=0 HDFS: Number of write operations=2 Job Counters Launched map tasks=4 Launched reduce tasks=1 Data-local map tasks=1 Rack-local map tasks=3 Total time spent by all maps in occupied slots (ms)=26512 Total time spent by all reduces in occupied slots (ms)=2701 Total time spent by all map tasks (ms)=26512 Total time spent by all reduce tasks (ms)=2701 Total vcore-milliseconds taken by all map tasks=26512 Total vcore-milliseconds taken by all reduce tasks=2701 Total megabyte-milliseconds taken by all map tasks=27148288 Total megabyte-milliseconds taken by all reduce tasks=2765824 Map-Reduce Framework Map input records=10000000 Map output records=12 Map output bytes=328 Map output materialized bytes=384 Input split bytes=504 Combine input records=0 Combine output records=0 Reduce input groups=9 Reduce shuffle bytes=384 Reduce input records=12 Reduce output records=1 Spilled Records=24 Shuffled Maps =4 Failed Shuffles=0 Merged Map outputs=4 GC time elapsed (ms)=495 CPU time spent (ms)=16210 Physical memory (bytes) snapshot=2590765056 Virtual memory (bytes) snapshot=13983645696 Total committed heap usage (bytes)=3243245568 Shuffle Errors BAD_ID=0 CONNECTION=0 IO_ERROR=0 WRONG_LENGTH=0 WRONG_MAP=0 WRONG_REDUCE=0 File Input Format Counters Bytes Read=1000000000 File Output Format Counters Bytes Written=24 real 0m25.183s user 0m7.004s sys 0m0.394s
[hdfs@el-hadoop101 ~]$hadoop fs -cat /user/hive/terasort-validate/part-r-00000 checksum 4c49607ac53602
該文件有內容,說明結果是有序的。
測試參考
在某一集群運行此命令,此集群配置10個datanode和3個namenode,每個節點采用10塊2T硬盤,128G內存,32核CPU,結果如下:
TeraSort命令耗時46.553s
YARN動態資源池
CDH 集成了 YARN 組件,提供了動態資源隔離能力,並對內存資源和 CPU 資源采用了不同的資源隔離方案。CM 提供了可視化界面來配置動態資源池,同時支持計划模式,對於指定類型的時間使用特定的資源管理策略,能有效的管理高峰在線業務期以及高峰離線計算期的不同資源負載管理矛盾。
當前 YARN 支持內存和 CPU 兩種資源類型的管理和分配。 對於內存資源是限制性資源, 應用程序到達內存限制, 會發生 OOM, 就會被殺死, 因此內存直接決定應用程序的運行。CPU 資源一般用 Cgroups 進行資源控制, 內存資源隔離除 Cgroups 之外提供了另外一個更靈活的方案,就是線程監控方案,以獲取更加靈活的資源控制效果。默認情況下 YARN 采用線程監控的方案控制內存使用,每個 NodeManager 會啟動一個額外監控線程監控每個 container 內存資源使用量,一旦發現它超過約定的資源量,則會將其殺死。
在 YARN 中, 用戶以隊列的形式組織, 每個用戶可屬於一個或多個隊列, 且只能向這些隊列中提交 application。 每個隊列被划分了一定比例的資源。 用戶提交應用程序時, 可以指定每個任務需要的虛擬 CPU 個數以及內存要求。
本章中僅演示功能,可以按照實際情況調整。
前期配置
1)確認開啟HDFS權限檢查 (默認是開啟的)
2)啟用 ResourceManager ACL
在YARN中搜索acl,其中yarn.acl.enable默認值為true。而對於yarn.admin.acl默認值為*,意味着所有人都可以提交任務、管理已提交 (比如取消kill) 的任務。格式為”以逗號分隔的用戶列表+空格+以逗號分隔的組列表”,例如”user1,user2 group1,group2”。如果只有組信息,需要在最前端加入一個空格,例如” group1,group2”。另外特別需要注意的是需要將”yarn”加入到用戶列表中,默認安裝CDH后,有關YARN服務的命令會以yarn用戶的身份進行運行,若yarn不設置於yarn.admin.acl中,可能出現權限相關的錯誤 (例如刷新動態資源池)。
下圖中配置了yarn用戶和admins用戶組作為管理員。
3)關閉未聲明資源池的自動生成
默認情況下,允許未聲明的池是選中的,需要關閉,否則如果用戶指定一個尚未聲明的資源池,比如prod,YARN將會自動生成一個prod資源池。
配置文件修改后需要重新啟動YARN服務,重新部署客戶端配置。
4)配置不指定特定的queue時使用default queue
默認情況下,使用默認隊列時的 Fair Scheduler 用戶是選中的,意味着如果用戶提交任務時不指定特定的queue,就使用以用戶命名的queue。
搜索:yarn.scheduler.fair.user,將其取消
資源池設置
1)點擊群集-動態資源池配置進入動態資源池的設置
2)訪問動態資源池管理頁面
此界面展示了當前資源池的分配情況,默認情況下,只有一個資源池root.default。但是如果在本文開頭的前期配置之前執行了任務,yarn會自動建立users資源池。
權重 (weight) 定義了兩個資源池資源分配的比例。如將users資源池設置權重為4而default的權重為1,那么集群資源的80%會被分配給users資源池。注意,這里提到的資源分配不是一個靜態的概念,例如當前資源池users中沒有任何任務在運行,那么資源池default是允許使用超過20%的集群資源。
點擊資源池對應的編輯按鈕,如編輯users,請注意,users可以使用與root相同的ACL配置,也可以使用不同的配置。
3)在Resource Limits欄, 設置資源池權重,資源約束等
4)在計划策略欄,設置資源池users的調度算法,一般使用默認的DRF
5)在提交訪問控制(Submission Access Control)欄,設置哪些用戶或組可以向該資源池提交任務
6)在管理訪問控制 (Administration Access Control) 欄設置哪些用戶或組可以對資源池中的任務進行管理
創建資源池
點擊創建資源池可以創建一個新的資源池,可以參照上文的配置方法配置新建立的資源池的屬性
可以為每個資源池創建子池。
YARN任務放置規則配置
點擊放置規則,選擇創建規則,進入配置選項
根據實際情況選擇放置規則
選擇重新排列防止規則設置規則優先級。
如需采用最嚴格的資源權限控制,可以在資源池權限配置中為每個用戶組配置相應的資源池,然后此處刪除所有放置規則,只添加“已在運行時指定”一條放置規則, 並且不勾選自動創建池,此時用戶提交任務時必須指定使用的資源池,方法為指定參數
-Dmapreduce.job.queuename=<pool name> |
2 靜態資源池
靜態資源隔離能力基於 Linux 容器技術。Linux 容器工具,即 LXC,可以提供輕量級的虛擬化,以便隔離進程和資源。使用 LXC 的優點就是不需要安裝太多的軟件包,使用過程也不會占用太多的資源,LXC 是在 Linux 平台上基於容器的虛擬化技術的未來標准,最初的 LXC 技術是由 IBM 研發的,目前已經進入 Linux 內核主線,這意味着 LXC 技術將是目前最有競爭力的輕量級虛擬容器技術。LXC 項目由一個 Linux 內核補丁和一些用戶空間(userspace)工具組成。這些工具使用由補丁增加的內核新特性,提供一套簡化的工具來維護容器。2.6.29 版本后的 Linux 內核版本已經包含該補丁提供的大部分功能。所以強烈建議使用最新的內核源代碼。 LXC 在資源管理方面依賴 Linux 內核的 CGroups (Control Groups) 系統,CGroups 系統是 Linux 內核提供的一個基於進 程組的資源管理的框架,可以為特定的進程組限定可以使用的資源。它最初由 Google 的工程師提出,后來被整合進 Linux 內核。CGroups 也是 LXC 為實現虛擬化所使用的資源管理手段,可以說沒有 CGroups 就沒有 LXC。
CDH 支持基於 CGroups 或者 Linux 容器進行靜態資源隔離,保證不同應用、不同任務之間的資源使用獨立性。
CM 提供了靜態服務的監控和運維界面,能方便的查看和管理靜態服務池。
測試之郵件報警
點擊Cloudera Management Service
郵件服務器主機名稱:自己選擇,可用smtp.163.com、smtp.qq.com等
郵件服務器用戶名:對應郵件服務器的郵箱賬號,用此賬號發郵件
郵件服務器密碼:郵件服務器用戶名對應的密碼
郵件發件人地址:發件人地址一般可以與郵件服務器用戶名一樣
郵件收件人: 接收報警信息的地址,可為任意可用郵件地址(多個人用,隔開)
重啟Cloudera Management Service
測試發送郵件
測試之數據備份
NameNode元數據備份
選擇活動的NameNode
進入安全模式
選擇保存Namespace
進入活動namenode所在服務器備份
[root@hadoop101 ~]# mkdir /root/namenode_back [root@hadoop101 ~]# tar -zcvf /root/namenode_back/nn_back.tar.gz /dfs/nn/
tar: Removing leading `/' from member names
/dfs/nn/
/dfs/nn/in_use.lock /dfs/nn/current/
/dfs/nn/current/edits_inprogress_0000000000037191075 /dfs/nn/current/edits_0000000000036958153-0000000000036960653
...
/dfs/nn/current/edits_0000000000036305400-0000000000036344955
/dfs/nn/current/fsimage_0000000000037191074.md5 /dfs/nn/current/edits_0000000000037178008-0000000000037179639
/dfs/nn/current/edits_0000000000036941796-0000000000036943432
/dfs/nn/current/fsimage_0000000000037189435 /dfs/nn/current/edits_0000000000036727644-0000000000036729281
/dfs/nn/current/edits_0000000000036739092-0000000000036740725
...
/dfs/nn/current/edits_0000000000036522931-0000000000036524567
/dfs/nn/current/VERSION /dfs/nn/current/edits_0000000000037184542-0000000000037186167
/dfs/nn/current/edits_0000000000036722738-0000000000036724374
...
/dfs/nn/current/edits_0000000000036720180-0000000000036722737
/dfs/nn/current/fsimage_0000000000037189435.md5 /dfs/nn/current/edits_0000000000036967223-0000000000036968854
...
/dfs/nn/current/edits_0000000000036252237-0000000000036273536
/dfs/nn/current/fsimage_0000000000037191074 /dfs/nn/current/edits_0000000000036943433-0000000000036945070
/dfs/nn/current/edits_0000000000036409679-0000000000036453971
/dfs/nn/current/edits_0000000000036518027-0000000000036519658
/dfs/nn/current/edits_0000000000036745627-0000000000036747263
/dfs/nn/current/seen_txid /dfs/nn/current/edits_0000000000036737460-0000000000036739091
/dfs/nn/current/edits_0000000000036514752-0000000000036516383
... [root@hadoop101 ~]# ll total 4 drwxr-xr-x 2 root root 4096 Apr 21 22:11 namenode_back [root@hadoop101 ~]# cd namenode_back/ [root@hadoop101 namenode_back]# ll total 24584
-rw-r--r-- 1 root root 25170701 Apr 21 22:11 nn_back.tar.gz
備份MySQL元數據
在MySQL所在節點運行以下命令:
[root@hadoop101 ~]# mysqldump -u root -p -A > /root/mysql_back.dump Enter password: 可以通過以下命令恢復: [root@hadoop101 ~]# mysql -u root -p -A < /root/mysql_back.dump -A :全部數據庫
升級之節點的添加和刪除
准備機器
新准備一台機器hadoop104,配置好對應主機的網絡IP、主機名稱、關閉防火牆。安裝JDK,下載依賴,關閉SELINUX,解壓CM,修改config.ini,創建/opt/cloudera/parcel-repo,創建cloudera-scm用戶,最后啟動agent。
詳見前邊。
注意:如果集群配置了Kerberos,則需要在該機器配置。
此時頁面點擊主機 會自動出現hadoop104
添加節點
1)點擊向集群中添加新主機
2)運行向導
3)選擇機器hadoop104
4)等待激活
5)檢查主機
6)創建主機模板
這里點擊創建后自己選擇需要的服務。
如果安裝過程應用主機模板失敗,也可以直接在CM中應用。
之后重新部署啟動即可。
7)重新平衡
刪除節點
1)停止agent服務
2)停止角色並刪除
之后重新部署重啟即可。