Hadoop快速入門css
2018/09/04html
目錄java
1. Hadoop概述 4node
1.1. Hadoop是什麼 4mysql
1.2. 分佈式必要性 4linux
1.2.1. 分佈式存儲的必要性 4git
1.2.2. 分佈式計算必要性 5github
1.3. Hadoop包括哪些組件 6web
1.3.1. 說明 6ajax
1.3.2. 結構圖 6
2. 單機安裝 6
2.1. 安裝準備 6
2.2. Hadoop文件加載流程圖 7
2.3. 安裝步驟 7
2.3.1. 第一步:修改主機名 7
2.3.2. 第二步:建立一個hadoop系統用戶 8
2.3.3. 第三步:使用Hadoop登陸,上傳相關安裝軟件 10
2.3.4. 第四步:安裝JDK 11
2.3.5. 第五步:準備Hadoop文件 12
2.3.6. 第六步:修改配置文件 13
2.3.7. 第七步:將Hadoop的命令加到環境變量 16
2.3.8. 第八步:格式化HDFS文件系統 17
2.3.9. 第九步,啓動HDFS文件系統 17
2.3.10. 第十步:啓動YARN調度程序 18
2.4. HDFS工做原理 21
3. 集羣部署 22
3.1. 集羣部署是什麼 22
3.2. 集羣部署結構圖 22
3.3. 部署準備 24
3.4. Linux虛擬機的準備 24
3.5. 免密登陸的實現 24
3.5.1. 免密登陸是什麼 24
3.5.2. Linux免密登陸原理圖 25
3.5.3. 操做步驟 25
3.6. 集羣部署步驟 29
3.6.1. 第一步:配置slaves配置文件 29
3.6.2. 第二步:修改全部服務器的hdfs-site.xml配置 29
3.6.3. 第三步:啓動測試 29
3.7. 工做原理 30
3.7.1. 上傳工做原理 30
3.7.2. 下載工做原理 31
4. HDFS文件系統(分佈式存儲) 31
4.1. HDFS是什麼 31
4.2. HDFS經常使用操做命令 31
4.3. Java API操做HDFS 32
4.3.1. 說明 32
4.3.2. 配置步驟 32
4.3.3. 實現上傳、下載、刪除、查看 35
5. 實戰案例-網盤的實現 37
5.1. 需求 37
5.2. 思路 37
5.3. 準備 37
5.4. 實現步驟 38
5.4.1. 第一部分:編寫公共代碼 38
5.4.2. 第二部分:用戶功能實現 44
5.4.3. 第三部分:網盤功能 56
6. MapReduce(分佈式計算) 57
6.1. MapReduce是什麼 57
6.2. MapReduce運行流程圖 57
6.3. 入門示例 57
6.3.1. 說明 57
6.3.2. 配置步驟 58
6.4. MapRedurce 運行原理圖 66
6.5. 本地模式 67
6.5.1. 第一步:配置Hadoop的環境變量 67
6.5.2. 第二步:須要winutils.exe支持 69
6.5.3. 第三步:將demo.txt放在本地目錄 70
6.5.4. 第四步:修改WcRunner 70
6.5.5. 第五步:直接運行WcRunner類 72
6.5.6. 第六步:查看測試結果 72
7. Zookeeper 72
8. HA集羣部署Hadoop 72
8.1. HA集羣是什麼 72
8.2. 高可用是什麼 73
8.3. 爲何須要使用HA集羣 73
8.4. 部署步驟 73
8.4.1. 需求說明 73
8.4.2. 部署思路 74
8.4.3. 第一部分:HA機制的集羣配置 74
8.4.4. 第二部分:配置Zookeeper集羣 75
8.4.5. 第三步部分:配置NameNode的HA集羣 75
8.4.6. 第四部分:配置ResourceManger的HA集羣 78
9. 附錄A 配置文件參數 78
9.1. core-default.xml 78
9.2. hdfs-default.xml 81
9.3. mapred-default.xml 83
9.4. yarn-default.xml 89
9.5. 新舊屬性對應表 90
分佈式系統概述
1.1 分佈式系統的必要性
咱們學習了java.我會OA系統開發,我會crm系統開發.
業務系統,咱們的開發時知足了業務需求!!!
老闆問 : 你能不能寫一個,1000萬併發的業務系統呢?
--大數據須要的技術(2.5月)
Hadoop開發生態
HDFS
MapReduce
Hive
Spark
flume
sqoop
hbase
pig
....
The Apache™ Hadoop® project develops open-source software for reliable, scalable, distributed computing. |
根據官方的定義Hadoop是一個開源的分佈式計算開發軟件。
所謂的分佈式計算,簡單而言就是能夠實現將數據邏輯的處理交予一個服務器集羣處理。
在天天T級別的的數據系統,沒有分佈式的數據計算以及存儲系統。想一下都恐怖。
Hadoop的出現,讓原本須要投資過億才能夠實現的併發性系統,使用極低的成本就能夠實現。
--傳統模式下載邏輯的實現
|
--分佈式模式下載邏輯的實現
--分佈式文件系統,讓一個文件系統分佈式放在不一樣的服務器裏面。下載的時候能夠在不一樣的服務器下載對應的數據塊合併成一個文件。
這樣能夠提升下載上傳的效率。其副本機制硬件損壞致使的數據丟失。
|
需求:如今有1000個文本文件,每一個大小爲2G,使用程序讀取,而且計算輸出計算的結果。
傳統模式下,只能在一臺電腦上面計算,效率極低。
|
在分佈式系統下,系統會將計算分散在一個服務器集羣裏面執行須要的邏輯處理。極大地提交了程序的執行效率。
|
Hadoop核心主要包括分佈式存儲以及分佈式計算。分佈式存儲使用默認使用HDFS分佈式文件系統,分佈式計算使用MapReduce與YARN模塊。
|
所謂的單機安裝,就是在單臺服務器中安裝Hadoop軟件系統。
|
根據運行文件加載流程圖,得出Hadoop須要配置的文件包括:
爲了方便管理Hadoop主機,咱們須要給不一樣的Hadoop主機一個惟一的主機名。因此在安裝Hadoop以前,須要給主機修改一個主機名。
--修改主機名
使用命令:sudo vi /etc/sysconfig/network
|
--修改後,讓主機名生效
使用命令:sudo hostname u4
退出,從新登陸
|
--讓主機名替代IP,做爲訪問的地址
編輯/etc/hosts文件的映射,使用命令:sudo vi /etc/hosts
|
測試是否生效,若是修改後使用 ping u4,返回ping通訊息,說明成功
|
--這樣方便使用hadoop用戶管理hadoop
--先建立一個hadoop組
使用命令:groupadd hadoop
|
--在建立一個 hadoop用戶,將用戶的所屬組設置爲hadoop組
|
--授予hadoop用戶有sudoer權限
經過輸入visudo 命令,打開sudoers文件
增長 :hadoop ALL=(ALL) ALL命令,保存
|
cat /etc/sudoers文件,查看是否成功
|
問題:爲何須要給hadoop給予sudoers的權限呢?
答:是由於,若是不給hadoop用戶sudoers的權限,即便使用sudo命令,也有一些系統功能是沒法使用的。給了sudoers權限,hadoop能夠經過sudo得到全部的系統訪問權限!!
--修改WinSCP的root用戶修改成新建立的hadoop用戶
|
--上傳安裝包
|
--建立一個app文件夾,將相關的軟件統一安裝到裏面
|
--解壓jdk安裝包到app目錄
使用命令:
tar -zxvf jdk-8u181-linux-x64.tar.gz
|
--配置全局JAVA_HOME以及PATH環境變量
編輯/etc/profile,使用命令sudo vi /etc/profile
注意:hadoop是普通用戶,因此修改非屬於它文件或者目錄須要使用sudo開頭得到管理權限修改
在profile文件最後追加
|
export JAVA_HOME=/home/hadoop/app/jdk1.8.0_181 export PATH=$PATH:$JAVA_HOME/bin |
--經過source /etc/profile讓配置生效,並測試是否配置成功
|
--解壓Hadoop安裝包到app文件夾,而且修改目錄名hadoop
使用命令:tar -zxvf hadoop-2.9.1.tar.gz -C app/
|
進入app將hadoop-2.9.1 目錄名修改成hadoop
|
--hadoop目錄簡單說明
|
bin:應用程序,主要用於hadoop操做,經常使用的就是hadoop命令
etc:hadoop配置文件
include:本地實現庫的頭文件,說明是使用C語言或者C++編寫的
lib:本地實現庫
sbin:也是應用程序,主要用於啓動,關閉hadoop
share:Java實現類庫
--配置文件說明
修改/home/hadoop/app/hadoop/etc/hadoop的
問題:配置的屬性能夠在哪裏找到呢?
學習任何框架,必需要知道一個知識點,配置的屬性均可以在代碼裏面找到。經分析,
配置文件的解釋類通常都是,Configuration以及縮寫,Builder的單詞以及縮寫
能夠搜索hadoop源碼包 「*-default.xml」,能夠找到全部配置文件分別能夠配置的屬性有哪些
|
--hadoop-env.sh文件
指定Hadoop的JAVA_HOME環境變量
export JAVA_HOME=/home/hadoop/app/jdk1.8.0_181
|
--修改core-site.xml配置文件
core-site.xml是hadoop核心配置文件
<configuration> <!-- 必須指定使用的文件系統 --> <property> <name>fs.defaultFS</name> <!--注意:最後的斜槓必須加上--> <value>hdfs://u4:9000/</value> </property> <!--必需要指定hadoop數據文件的位置--> <property> <name>hadoop.tmp.dir</name> <!--注意:data文件必須事先建立好--> <value>/home/hadoop/app/hadoop/data</value> </property> </configuration>
|
--修改hdfs-site.xml配置文件
hdfs-site.xml是HDFS文件系統的配置文件,用於配置HDFS配置參數
由於每一個datanode上只能存放一個副本,如今是單機配置,數據節點只有一個,因此副本的個數只須要1就能夠了
<configuration> <!--單機配置,數據副本只配置一個就能夠--> <property> <name>dfs.replication</name> <value>1</value> </property> </configuration>
|
只要配置以上兩個配置文件,hadoop就能夠啓動了。可是沒法使用MapReduce程序進行數據分析。因此建議仍是將mapred-site.xml配置文件和yarn-site.xml。
--修改mapred-site.xml配置
mapred-site.xml配置文件用於MapReduce數據分析框架的參數,必需要指定使用哪一個調度框架。
複製mapred-site.xml.template修改文件名爲mapred-site.xml
使用命令: cp -v mapred-site.xml.template mapred-site.xml
|
編輯mapred-site.xml配置文件
<configuration> <!--指定調度使用的是hadoop自帶的yarn--> <property> <name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration>
|
--修改yarn-site.xml配置文件
yarn-site.xml配置文件用於設置YARN調度框架的參數,必需要要指定ResourceManager的節點。
必需要指定節點的選舉規則
<configuration>
<!-- Site specific YARN configuration properties --> <property> <!--指定ResourceManger--> <name>yarn.resourcemanager.hostname</name> <value>u4</value> </property> <!--指定節點調度選舉規則--> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> </configuration>
|
--修改slaves文件
將localhost修改成主機名u4
|
爲了能夠在任何目錄的當前路徑能夠直接訪問hadoop的bin以及sbin的命令,須要將這兩個目錄路徑加入到PATH環境變量
--編輯/etc/profile文件
使用命令 sudo vi /etc/profile,修改成
export JAVA_HOME=/home/hadoop/app/jdk1.8.0_181 export HADOOP_HOME=/home/hadoop/app/hadoop export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin |
--讓環境變量生效
|
--使用命令: hadoop namenode -format
--若是不報異常,表示成功。
|
成功後,會在hadoop配置爲data數據目錄產生數據文件
|
--首先啓動hdfs文件系統
使用start-dfs.sh
|
--測試HDFS文件系統是否成功
上傳文件到HDFS文件系統
使用命令:hadoop fs -put jdk-8u181-linux-x64.tar.gz hdfs://u4:9000/
注意:上傳端口默認爲9000,路徑的最後的斜槓不要寫漏
|
--使用web客戶端查看
注意:web端口默認爲50070
|
--啓動yarn調度程序
啓動yarn調度程序,才能夠執行MapReduce分析程序
使用start-yarn.sh命令啓動
工做原理
|
--測試是否成功
需求:經過hadoop自帶的示例程序,測試分析文本中,單詞的出現次數。
|
先建立一個文本,起名爲demo.txt。隨便寫入文字
|
在hdfs文件系統一個wordcount文件夾(文件夾隨便你寫)
hadoop fs -mkdir hdfs://u4:9000/wordcount/ |
|
再在wordcount文件夾裏面建立一個 input文件夾(文件夾名也是隨便你寫)
hadoop fs -mkdir hdfs://u4:9000/wordcount/input |
|
執行測試MapReduce測試示例程序
hadoop jar hadoop-mapreduce-examples-2.9.1.jar wordcount /wordcount/input /wordcount/output
使用格式:hadoop jar <mapreduce程序> <入口類名> [參數列表]
mapreduce]$ hadoop jar hadoop-mapreduce-examples-2.9.1.jar wordcount /wordcount/input /wordcount/output
|
|
下載分析數據文件,查看
|
HDFS主要分爲:NameNode、SecondaryNameNode以及DataNode三個部分。
1.NameNode:名字子節點。用於統一接收客戶端的請求,讓客戶端得到操做對應的數據節點。
2.SecondaryNameNode:日誌備份節點,是HDFS的數據操做的備份機制。經過它來確保數據的有效性
3.DataNode:數據節點,用於存儲數據
操做流程,如圖所示:
|
所謂的集羣部署就是讓Hadoop系統軟件在多臺機器同時運行,而且協同分佈式處理數據。
|
2.集羣后,一臺ResourceManager能夠調動多臺NodeManager
|
上面的安裝,發現每次啓動Hadoop或者關閉都要手工輸入密碼登陸。可是若是集羣部署,同時要啓動全部的NameNode以及DataNode。那麼這樣操做很是麻煩。
若是要實現同時一塊兒啓動全部的hadoop的NameNode以及全部DataNode。須要配置免密登陸。
所謂遠程登陸Linux系統不須要任何密碼。
首先第一步,咱們要知道遠程登陸Linux使用的ssh協議。
SSH 是 Secure Shell的簡寫。就是一種安全的通訊的協議。
Linux的遠程登陸就是使用該協議的。Linux實現的SSH的遠程登陸軟件支持用戶密碼登陸,也支持密鑰登陸。
免密登陸,就是經過密鑰登陸。
準備知識:Linux的遠程登陸使用SSH協議基於非對稱加密算法(RSA)。
必需要指定,所謂的非對稱算法,就是加密的密鑰和解密的密鑰分別是一個密鑰對。
|
使用hadoop用戶登陸,而後使用ssk-keygen命令建立一個密鑰對。
|
在hadoop的我的文件夾下。使用ll -a查看是否已經建立了.ssh文件夾
問題:爲何須要使用-a參數呢?
答:由於.開頭的文件夾是隱藏文件夾,必須使用-a才能夠顯示。 -a:表示顯示全部類型的文件已經文件夾包括隱藏的
注意:文件默認的權限是 700的,千萬不要修改。免密登陸要求,.ssh文件必須爲700權限。
|
進入.ssh文件夾,建立authorized_keys文件,將公鑰複製到authorized_keys
經過命令:cat id_rsa.pub >> authorized_keys
|
--查看是否成功
經過命令:cat authorized_keys命名查看是否成功
|
Linux系統規定authorized_keys必須是600權限,免密登陸才生效。
經過命令: chmod 600 authorized_keys
|
回到上一層,使用命令 tar -czvf ssh.tar.gz .ssh/壓縮。
|
上傳到遠程系統的指定路徑,經過 scp ssh.tar.gz 遠程主機用戶@主機名: 遠程路徑
如:上傳到u2服務器,使用命令:scp ssh.tar.gz hadoop@u2:/home/hadoop/ssh.tar.gz
|
經過ssh命令登陸遠程主機。
執行命令爲:ssh u2,根據提示輸入密碼
|
--登陸成功,當前主機名會修改成u2
|
|
--查看
|
經過exit命名,退回到u1服務器
|
再使用ssh u2命令登陸,確認是否不用輸入密碼了。若是是,表示配置成功
|
注意:重複這個步驟,全部須要免密登陸的機器就實現全部機器的免密登陸了
配置完成後,將用於NameNode和ResourceManger的服務器的slaves增長數據節點的配置就能夠
編輯u1服務器的hadoop的slaves配置文件
--進入到slaves目錄
|
--編輯 vi slaves,內容以下:
u1 u2 u3 |
--文件的副本數據,必須大於1,必須小於等於數據節點的個數。
|
回到u1服務器啓動hadoop測試。
--啓動hdfs
|
--啓動yarn
|
|
|
HDFS全稱:Hadoop Distributed File System,就是Hadoop分佈式文件系統。
實現了將數據分佈在多臺的Linux系統上。從而提升了文件的存取效率。經過副本機制,下降數據丟失的機率。
hadoop fs -put :上傳
hadoop fs -get :下載
hadoop fs -mkdir : 建立文件夾
hadoop fs -rm : 刪除文件或者文件夾
hadoop fs -ls :查看文件目錄
hadoop fs -chown :修改文件或者文件夾的所屬者
hadoop fs -cp :複製
hadoop fs -chmod 受權
hadoop fs -du : 查看文件夾大小
hadoop fs -mv :移動文件夾或者目錄
hadoop fs -cat :查看文件內容
HDFS分佈式文件系統提供了Java API操做的支持。
需求:使用Java API實現對HDFS的文件的上傳。
--建立一個普通的Java的項目,導入必須的Jar包
將標紅的的文件夾下的全部jar包複製項目
|
--項目結構
|
鏈接HDFS分佈式文件系統,須要使用到core-site.xml和hdfs-site.xml配置文件。
因此複製這兩個配置文件到項目的classpath根本目錄。
|
建立HdfsUtils得到HDFS操做對象FileSystem對象。
package org.ranger.utils;
import java.io.IOException; import java.net.URI; import java.net.URISyntaxException;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem;
public class HdfsUtils {
//得到配置創建鏈接,得到HDFS操做對象 public static FileSystem getFileSystem() { FileSystem fs=null; //1.建立配置類,讀取配置文件 Configuration conf=new Configuration(); //2.建立HDFS操做對象FileSystem對象 try { //參數1:表示HDFS的操做路徑 //參數2:設置的參數 //參數3:HDFS的操做用戶,必須與HDFS的用戶一一對應 fs=FileSystem.get(new URI("hdfs://u1:9000/"), conf, "hadoop"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } return fs; } public static void main(String[] args) { //若是不報錯,輸出信息,表示成功 System.out.println(HdfsUtils.getFileSystem()); } } |
package org.ranger.test; import java.io.FileInputStream; import java.io.IOException; import org.apache.commons.io.IOUtils; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.junit.Test; import org.ranger.utils.HdfsUtils; public class HdfsUploadTest { /** * 需求:將本地文件上傳到HDSF */ @Test public void fileupload() { //1.得到操做對象 FileSystem fs = HdfsUtils.getFileSystem(); try { //2.設置上傳到指定的HDFS的目錄,得到一個輸出流 FSDataOutputStream output = fs.create(new Path("/wc/input/demo.txt")); //3.得到本地的文件流 FileInputStream input=new FileInputStream("C:/wc/input/demo.txt"); //4.將文件輸入流複製到輸出流中 IOUtils.copy(input, output);
//5.關閉流 input.close(); output.close(); fs.close(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } } |
上傳以前,HDFS上面的目錄結構是否正確,設置的用戶是否和代碼的設置的使用兼容
實現上傳、下載、刪除、查看目錄、查看文件,建立文件夾。
package org.ranger.test; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.net.URISyntaxException; import org.apache.commons.io.IOUtils; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.LocatedFileStatus; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.RemoteIterator; import org.junit.Test; import org.ranger.utils.HdfsUtils; //注意:hdfs是不支持修改的,修改須要先下載修改再上傳。 public class HdfsCurdTest1 { // 1.下載 @Test public void download() throws IOException { FileSystem fs = HdfsUtils.getFileSystem(); Path path = new Path("hdfs://u1:9000/hadoop-2.9.1.tar.gz"); // 將Hadoop的文件下載到本地 FSDataInputStream in = fs.open(path); FileOutputStream out = new FileOutputStream(new File("c://hadoop-2.9.1.tar.gz")); IOUtils.copy(in, out);
} // 2.上傳,使用copyFromLocalFile @Test public void upload() throws IOException, InterruptedException, URISyntaxException { FileSystem fs = HdfsUtils.getFileSystem(); fs.copyFromLocalFile(new Path("c://demo.txt"), new Path("/demo2.txt")); } //3.建立文件夾 @Test public void mkdir() throws IllegalArgumentException, IOException { FileSystem fs = HdfsUtils.getFileSystem(); fs.mkdirs(new Path("/test/aa")); } //4 .刪除文件夾或者文件 @Test public void rm() throws IllegalArgumentException, IOException { FileSystem fs = HdfsUtils.getFileSystem(); fs.delete(new Path("/test"), true); } //5.查看文件目錄 @Test public void dirList() throws IllegalArgumentException, IOException { FileSystem fs = HdfsUtils.getFileSystem(); FileStatus[] status = fs.listStatus(new Path("/")); for (FileStatus fileStatus : status) { System.out.println(fileStatus.getPath().getName()); } } //6.查看全部文件 @Test public void fileList() throws IllegalArgumentException, IOException { FileSystem fs = HdfsUtils.getFileSystem(); RemoteIterator<LocatedFileStatus> listFiles = fs.listFiles(new Path("/"), true); while (listFiles.hasNext()) { LocatedFileStatus status = listFiles.next(); System.out.println(status.getPath().getName()); } } } |
實現一個相似百度網盤的的分佈式網盤。可以實現對網盤上的文件增刪查,能夠對文件夾建立,上傳,更名
數據庫SQL腳本
CREATE TABLE `tb_user` ( `user_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '用戶編號', `user_name` VARCHAR(50) NULL DEFAULT NULL COMMENT '用戶名', `user_account` VARCHAR(50) NULL DEFAULT NULL COMMENT '用戶登陸帳戶', `user_password` VARCHAR(50) NULL DEFAULT NULL COMMENT '密碼', `user_status` VARCHAR(50) NULL DEFAULT NULL COMMENT '狀態,0可用,1禁用', PRIMARY KEY (`user_id`), UNIQUE INDEX `user_account` (`user_account`) ) ENGINE=InnoDB ; |
--建立一個動態網站項目,而且將三層架構的分包建立好,以及將須要的基礎類的類名也寫好
|
--注意:屬性和數據庫對應表的字段一一對應
package org.ranger.pojo; public class User { private String userId;// BIGINT(20) '用戶編號', private String userName;// VARCHAR(50) '用戶名', private String userAccount;// VARCHAR(50) '用戶登陸帳戶', private String userPassword;// VARCHAR(50) '密碼', private Integer userStatus;// VARCHAR(50) '狀態,0可用,1禁用', public String getUserId() { return userId; } public void setUserId(String userId) { this.userId = userId; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getUserAccount() { return userAccount; } public void setUserAccount(String userAccount) { this.userAccount = userAccount; } public String getUserPassword() { return userPassword; } public void setUserPassword(String userPassword) { this.userPassword = userPassword; } public Integer getUserStatus() { return userStatus; } public void setUserStatus(Integer userStatus) { this.userStatus = userStatus; } } |
編寫DBUtils類,得到數據庫鏈接。
注意:要導入mysql的驅動包。
--DBUtils類代碼
package org.ranger.utils; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class DbUtils { //鏈接數據庫四要素 private static final String DRIVER="org.gjt.mm.mysql.Driver"; private static final String URL="jdbc:mysql://localhost:3306/network_disk"; private static final String USER="root"; private static final String PASSWORD="123456"; public static Connection getConnection() { try { //1.加載驅動 Class.forName(DRIVER); //2.返回鏈接對象 return DriverManager.getConnection(URL, USER, PASSWORD); } catch (SQLException e) {
e.printStackTrace(); } catch (ClassNotFoundException e) {
e.printStackTrace(); } //3.若是報異常,返回空對象 return null; } public static void main(String[] args) { System.out.println(DbUtils.getConnection()); } }
|
--DAO接口
package org.ranger.dao;
import java.sql.SQLException;
public interface DAO<T> { /** * * 插入記錄 * * @param entity * @return * @throws SQLException */ int insert(T entity) throws SQLException;
/** * 經過編號刪除記錄 * * @param id * @return * @throws SQLException */ int deleteById(Long id) throws SQLException;
/** * 經過編號查詢記錄 * @param id * @return * @throws SQLException */ T findById(Long id) throws SQLException;
}
|
--實現部分,UserDAO
package org.ranger.dao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import org.ranger.pojo.User; import org.ranger.utils.DbUtils;
public class UserDAO implements DAO<User>{
@Override public int insert(User entity) throws SQLException { //1.得到數據庫鏈接 Connection conn = DbUtils.getConnection(); String sql ="INSERT INTO tb_user(user_name, user_account, user_password, user_status) VALUES (?, ?, ?, ?)"; //2.得到操做對象 PreparedStatement ps = conn.prepareStatement(sql); //3.設置參數 ps.setString(1, entity.getUserName()); ps.setString(2, entity.getUserAccount()); ps.setString(3, entity.getUserPassword()); //若是爲空,設置爲0 ps.setInt(4,entity.getUserStatus()==null?0:entity.getUserStatus()); //4.操做 int count = ps.executeUpdate(); ps.close(); conn.close(); return count; }
@Override public int deleteById(Long id) throws SQLException { //1.得到數據庫鏈接 Connection conn = DbUtils.getConnection(); String sql ="DELETE FROM tb_user WHERE user_id=?"; //2.得到操做對象 PreparedStatement ps = conn.prepareStatement(sql); //3.設置參數 ps.setLong(1, id);
//4.操做 int count = ps.executeUpdate(); ps.close(); conn.close(); return count; }
@Override public User findById(Long id) throws SQLException {
//1.得到數據庫鏈接 Connection conn = DbUtils.getConnection(); String sql ="SELECT * FROM tb_user WHERE user_id = ?"; //2.得到操做對象 PreparedStatement ps = conn.prepareStatement(sql); //3.設置參數 ps.setLong(1, id);
//4.操做 ResultSet rs = ps.executeQuery(); User user =null; if(rs.next()) { user =new User(); user.setUserId(rs.getString("user_id")); user.setUserName(rs.getString("user_name")); user.setUserAccount(rs.getString("user_account")); user.setUserPassword(rs.getString("user_password")); user.setUserStatus(rs.getInt("user_status")); } ps.close(); conn.close(); return user; }
public User findByAccount(String account) throws SQLException {
//1.得到數據庫鏈接 Connection conn = DbUtils.getConnection(); String sql ="SELECT * FROM tb_user WHERE user_account = ?"; //2.得到操做對象 PreparedStatement ps = conn.prepareStatement(sql); //3.設置參數 ps.setString(1, account); //4.操做 ResultSet rs = ps.executeQuery(); User user =null; if(rs.next()) { user =new User(); user.setUserId(rs.getString("user_id")); user.setUserName(rs.getString("user_name")); user.setUserAccount(rs.getString("user_account")); user.setUserPassword(rs.getString("user_password")); user.setUserStatus(rs.getInt("user_status")); } ps.close(); conn.close(); return user; } } |
package org.ranger.dao.test;
import java.sql.SQLException; import org.junit.Test; import org.ranger.dao.UserDAO; import org.ranger.pojo.User; public class UserDAOTest {
@Test public void insert() { UserDAO userDAO=new UserDAO(); User user =new User(); try { user.setUserName("張三"); user.setUserAccount("zhangsan"); userDAO.insert(user ); } catch (SQLException e) { e.printStackTrace(); } } } |
--編寫一個註冊頁面
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>用戶註冊</title> <style type="text/css"> body { margin: 5px; vertical-align: middle; text-align: center; } input { margin: 5px; } </style> </head>
<body> <!--提示信息--> <span style="color: red;"> ${register_msg }</span>
<form action="${pageContext.request.contextPath }/user" method="post"> <input name="action" type="hidden" value="register"> 用戶帳號:<input name="userAccount" type="text"><br/> 用戶密碼:<input name="userPassword" type="password"><br/> 確認密碼:<input name="confirmPassword" type="password"><br/> <input value="用戶註冊" type="submit">
</form> </body> </html> |
--修改UserDAO增長一個經過帳號查詢記錄的方法
public User findByAccount(String account) throws SQLException {
//1.得到數據庫鏈接 Connection conn = DbUtils.getConnection(); String sql ="SELECT * FROM tb_user WHERE user_account = ?"; //2.得到操做對象 PreparedStatement ps = conn.prepareStatement(sql); //3.設置參數 ps.setString(1, account);
//4.操做 ResultSet rs = ps.executeQuery(); User user =null; if(rs.next()) { user =new User(); user.setUserId(user.getUserId()); user.setUserName(user.getUserName()); user.setUserAccount(user.getUserAccount()); user.setUserPassword(user.getUserPassword()); user.setUserStatus(user.getUserStatus()); } ps.close(); conn.close(); return user; }
|
--編寫UserService代碼
接口部分
package org.ranger.service;
import java.sql.SQLException;
import org.ranger.pojo.User;
public interface UserService {
/** * 用戶註冊 * @param user * @return * @throws SQLException */ User register(User user) throws SQLException;
}
|
實現部分
package org.ranger.service.impl;
import java.sql.SQLException;
import org.ranger.dao.UserDAO; import org.ranger.pojo.User; import org.ranger.service.UserService;
public class UserServiceImpl implements UserService {
@Override public User register(User user) throws SQLException { UserDAO userDAO=new UserDAO(); int count = userDAO.insert(user); //若是插入成功,返回該用戶 if(count>0) { return userDAO.findByAccount(user.getUserAccount()); } return null; }
}
|
--編寫UserServlet控制器
package org.ranger.web.servlet;
import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.ranger.pojo.User; import org.ranger.service.UserService; import org.ranger.service.impl.UserServiceImpl;
public class UserServlet extends HttpServlet {
private static final long serialVersionUID = -6221395694585506253L;
@Override public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println(req.getParameter("userAccount")); String action = req.getParameter("action");
switch (action) { case "register": this.register(req, resp); break;
default: System.out.println("-找不到調用的方法-"); break; }
}
/** * 用戶註冊 * * @param req * @param resp * @throws IOException * @throws ServletException */ private void register(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { //1.得到表單參數 System.out.println("-用戶註冊-"); String userAccount = req.getParameter("userAccount"); String userPassword = req.getParameter("userPassword"); String confirmPassword = req.getParameter("confirmPassword"); //2.驗證兩次輸入的密碼是正確 if (userPassword.equals(confirmPassword)) { UserService userService = new UserServiceImpl(); User user = new User(); user.setUserAccount(userAccount); user.setUserPassword(userPassword); user.setUserStatus(0);
User resultUser = userService.register(user); HttpSession session = req.getSession(); //註冊成功,將用戶數據放在會話 session.setAttribute("user", resultUser); req.setAttribute("register_msg", "註冊成功!"); //註冊成功自動登陸 req.getRequestDispatcher("/WEB-INF/views/main.jsp").forward(req, resp); return ; } else { req.setAttribute("register_msg", "兩次輸入的密碼不一致"); }
} catch (Exception e) {
e.printStackTrace(); req.setAttribute("register_msg", "出現系統錯誤,請聯繫管理員"); } req.getRequestDispatcher("/user_register.jsp").forward(req, resp);
}
}
|
--編寫一個編碼過濾器,統一處理表單中文亂碼問題
package org.ranger.web.filter;
import java.io.IOException;
import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse;
/** * 統一設置編碼集 * @author ranger * */ public class CharsetFilter implements Filter {
private static String encoding="UTF-8";
@Override public void destroy() {
}
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { request.setCharacterEncoding(encoding); response.setCharacterEncoding(encoding); chain.doFilter(request, response);
}
@Override public void init(FilterConfig filterConfig) throws ServletException { String param = filterConfig.getInitParameter("encoding"); if(param!=null&&!"".equals(param)) { encoding=param; } }
}
|
--配置web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> <display-name>network_disk</display-name> <!-- 編碼集過濾器 --> <filter> <filter-name>charsetFilter</filter-name> <filter-class>org.ranger.web.filter.CharsetFilter</filter-class> </filter> <filter-mapping> <filter-name>charsetFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!-- 配置servlet --> <servlet> <servlet-name>userServlet</servlet-name> <servlet-class>org.ranger.web.servlet.UserServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>userServlet</servlet-name> <url-pattern>/user</url-pattern> </servlet-mapping>
<welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app> |
--建立一個登錄頁面
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>用戶註冊</title> <style type="text/css"> body { margin: 5px; vertical-align: middle; text-align: center; } input { margin: 5px; } </style> </head>
<body>
<span style="color: red;"> ${login_msg }</span>
<form action="${pageContext.request.contextPath }/user" method="post"> <input name="action" type="hidden" value="login"> 用戶帳號:<input name="userAccount" type="text"><br/> 用戶密碼:<input name="userPassword" type="password"><br/>
<input value="用戶登陸" type="submit">
</form> </body> </html> |
---修改UserService接口,標紅代碼
public interface UserService {
/** * 用戶註冊 * @param user * @return * @throws SQLException */ User register(User user) throws SQLException; /** * 用戶登陸 * @param user * @return * @throws SQLException */ User login(User user) throws SQLException; } |
--修改UserServiceImpl實現
public class UserServiceImpl implements UserService {
@Override public User register(User user) throws SQLException { UserDAO userDAO = new UserDAO(); int count = userDAO.insert(user); // 若是插入成功,返回該用戶 if (count > 0) { return userDAO.findByAccount(user.getUserAccount()); } return null; }
@Override public User login(User user) throws SQLException { try { UserDAO userDAO = new UserDAO(); User resultUser = userDAO.findByAccount(user.getUserAccount()); if (user.getUserPassword().equals(resultUser.getUserPassword())) { return resultUser; } } catch (Exception e) { e.printStackTrace(); } return null; } } |
--修改UserServlet代碼
public class UserServlet extends HttpServlet { private static final long serialVersionUID = -6221395694585506253L; @Override public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println(req.getParameter("userAccount")); String action = req.getParameter("action"); switch (action) { case "register": this.register(req, resp); break; case "login": this.login(req, resp); break; default: System.out.println("-找不到調用的方法-"); break; } }
private void register(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ..........忽略代碼 }
/** * 用戶登陸 * @param req * @param resp * @throws IOException * @throws ServletException */ private void login(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("-用戶登陸-"); String userAccount = req.getParameter("userAccount"); String userPassword = req.getParameter("userPassword"); UserService userService = new UserServiceImpl(); User user = new User(); user.setUserAccount(userAccount); user.setUserPassword(userPassword); try { User resultUser = userService.login(user); if (resultUser != null) { HttpSession session = req.getSession(); session.setAttribute("user", resultUser); req.getRequestDispatcher("/WEB-INF/views/main.jsp").forward(req, resp); return; } else { req.setAttribute("login_msg", "用戶名或者密碼不正確"); } } catch (SQLException e) { System.out.println("-登陸失敗-"); req.setAttribute("login_msg", "出現系統異常,請聯繫管理員"); e.printStackTrace(); } req.getRequestDispatcher("/user_login.jsp").forward(req, resp); } } |
--編寫主界面代碼
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css"> body { margin: 0; } a{ color: blue; } a:hover { color: blue; } </style> </head> <body> <div style="text-align: right; padding: 8px"> <span style="padding-right: 10px;"> [${sessionScope.user.userAccount}]</span> <span style="padding-right: 10px;"> <a href="${pageContext.request.contextPath }/user?action=undo">[註銷]</a> </span> </div> </body> </html> |
--修改UserServlet代碼
package org.ranger.web.servlet;
import java.io.IOException; import java.sql.SQLException;
import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.ranger.pojo.User; import org.ranger.service.UserService; import org.ranger.service.impl.UserServiceImpl;
public class UserServlet extends HttpServlet {
private static final long serialVersionUID = -6221395694585506253L;
@Override public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String action = req.getParameter("action");
switch (action) { case "register": this.register(req, resp); break; case "login": this.login(req, resp); break;
case "undo": this.undo(req, resp); break; default: System.out.println("-找不到調用的方法-"); req.setAttribute("login_msg", "找不到調用的方法"); req.getRequestDispatcher("/user_login.jsp").forward(req, resp); break; }
}
private void register(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { // 1.得到表單參數 System.out.println("-用戶註冊-"); .......忽略代碼
}
private void login(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("-用戶登陸-"); .......忽略代碼
}
/** * 用戶註銷 * @param req * @param resp * @throws IOException * @throws ServletException */ private void undo(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { System.out.println("-用戶註銷-"); HttpSession session = req.getSession(); session.removeAttribute("user"); req.getRequestDispatcher("/user_login.jsp").forward(req, resp); }
}
|
思路:
--鏈接得到HDFS鏈接操做對象
--在註冊的時候,就給用戶建立一塊專屬文件夾,用其用戶命名
--將該該文件夾的所屬者修改成該用戶名
MapReduce是Hadoop裏面的分佈式數據計算模塊(框架)。經過MapReduce可讓數據處理在分佈式的Linux計算後再聚合返回。
|
若是所示:MapReduce分爲Map和Reduce兩部分。
Map部分就是分佈式計算,demo.txt每一條數據,都會執行一次Map計算。
Reduce部分是分佈彙總分組計算,必須在Map計算結束後,再分組彙總計算。
經過MapReduce程序實現,統計demo.txt 文本的單詞統計。
demo.txt文本內容
hello world hello tom hello boy hello girl hello jim hello jack |
輸出結果爲:
boy 1 girl 1 hello 6 jack 1 jim 1 tom 1 world 1 |
--建立一個Java普通項目,導入Hadoop依賴的jar包
jar放在hadoop安裝包的share/hadoop目錄下,如圖標紅的文件夾的全部jar包複製到項目。
|
建立Java項目,而且建立一個存放MapReduce程序的包
|
--建立一個demo.txt文件,並寫好內容。再將文件上傳對HDFS的目錄中,如:/wc/deme.txt
建立一個demo.txt在當前linux用戶我的目錄
|
編輯demo.txt文件
|
上傳文件到hdfs文件系統
|
Mapper類是一個規範,因此必須須要繼承Mapper類
package org.ranger.mapredure.wc;
import java.io.IOException;
import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Mapper;
/** * 注意事項:Mapper類必須須要指定四個數據類型(KEYIN, VALUEIN, KEYOUT, VALUEOUT) * * KEYIN:傳入Mapper數據key的類型,Hadoop傳入一個數據偏移量做爲key * VALUEIN:傳入Mapper數據value的類型 * * KEYOUT:Mapper傳出的key的類型 * VALUEOUT:Mapper傳出的value的類型 * * 問題:爲何數據類型使用LongWritable, Text,而不是Long,String呢? * 答:由於Java實行的數據類型,序列化會包含大量信息,Hadoop基於效率的緣由重寫了這些類型 * @author ranger * * 注意事項:無論傳入傳出,Mapper都是使用key-value的方式傳遞 * */ public class WcMapper extends Mapper<LongWritable, Text, Text, LongWritable>{
/** * 每條數據計算,都執行一次!! */ @Override protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, LongWritable>.Context context) throws IOException, InterruptedException { //1.得到Hadoop傳遞過來的數據 String line = value.toString(); //2.分割數據 String[] fields = line.split(" ");
//3.傳出數據 for(String field:fields) { //<字段名,1> context.write(new Text(field), new LongWritable(1)); }
}
}
|
package org.ranger.mapredure.wc;
import java.io.IOException;
import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Reducer;
/** * 分組聚合計算 * 注意事項:傳入的key-value和Mapper傳出的保持一致 * * @author ranger * */ public class WcReducer extends Reducer<Text, LongWritable, Text, LongWritable> {
@Override protected void reduce(Text key, Iterable<LongWritable> values, Reducer<Text, LongWritable, Text, LongWritable>.Context context) throws IOException, InterruptedException {
//1.聲明一個變量,統計單詞的個數 long count=0; for (LongWritable value : values) { count+=value.get(); } //2.輸出結果 context.write(key, new LongWritable(count));
}
}
|
package org.ranger.mapredure.wc;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
/** * 執行MapReduce程序的入口 * * 1.設置 * * @author ranger * */ public class WcRunner {
public static void main(String[] args) {
try {
//1.建立一個job對象 Configuration conf=new Configuration(); Job job = Job.getInstance(conf);
//設置入口的主類 job.setJarByClass(WcRunner.class);
//設置job對應的Mapper和Reducer job.setMapperClass(WcMapper.class); job.setReducerClass(WcReducer.class);
//設置Mapper的輸出類型 job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(LongWritable.class);
//設置reduce的輸出類型 job.setOutputKeyClass(Text.class); job.setOutputValueClass(LongWritable.class);
//map設置數據的得到 FileInputFormat.setInputPaths(job, new Path("/wc/")); FileOutputFormat.setOutputPath(job, new Path("/output/"));
//提交job job.waitForCompletion(true);
} catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
}
|
注意:由於放在Hadoop裏面運行,因此能夠導jar包時,不用勾上lib。
|
將jar文件上傳到任何一個Hadoop服務器上。放在Hadoop的MapReduce目錄下
/home/hadoop/app/hadoop/share/hadoop/mapreduce
執行格式:hadoop jar wc.jar 入口類全名
如:hadoop jar wc.jar org.ranger.mapredure.wc.WcRunner
|
使用:hadoop fs -ls /output目錄查看輸出文件
在使用:hadoop fs -cat /output/part-r-00000查看數據結果
|
|
若是,程序調試都是放在Hadoop上面執行,會大大下降開發的效率。MapReduce支持本地模式。
所謂的本地模式,就是在本機測試,不須要放在Hadoop上面,MapReduce也能夠運行。
注意事項:必須使用64位的JDK。不然會報錯。
|
--將hadoop-2.9.1.tar.gz解壓到D:\java\hadoop-2.9.1
|
--配置環境變量
HADOOP_HOME=D:\java\hadoop-2.9.1
|
PATH=%HADOOP_HOME%\bin
|
--測試環境變量是否成功
在cmd下使用set命令查看環境變量
|
--下載winutils.exe路徑
https://github.com/steveloughran/winutils/releases
--解壓將全部文件複製到hadoop的bin目錄
|
|
修改WcRunner的輸入輸出路徑爲本地路徑
package org.ranger.mapredure.wc; import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
/** * WcRunner 執行MapReduce程序的入口 * @author ranger * */ public class WcRunner { public static void main(String[] args) { try { //1.建立一個job對象 Configuration conf=new Configuration(); Job job = Job.getInstance(conf) //設置入口的主類 job.setJarByClass(WcRunner.class); //設置job對應的Mapper和Reducer job.setMapperClass(WcMapper.class); job.setReducerClass(WcReducer.class); //設置Mapper的輸出類型 job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(LongWritable.class); //設置reduce的輸出類型 job.setOutputKeyClass(Text.class); job.setOutputValueClass(LongWritable.class); //map設置數據的得到 FileInputFormat.setInputPaths(job, new Path("c:/wc/input/")); FileOutputFormat.setOutputPath(job, new Path("c:/wc/output/")); //提交job job.waitForCompletion(true); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InterruptedException e) { e.printStackTrace(); } } } |
|
|
所謂的日誌清洗,就是在雜亂日誌裏面,提取擁有的信息,在進行數據分析。
需求:分析網站時間段的訪問量。
package cn.gzsxt.mapreduces;
import java.io.IOException; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale;
import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Mapper; import org.apache.hadoop.mapreduce.Reducer;
/** * 問題:爲何使用內部類將Map計算和Reduce計算放在一塊兒 答:這樣能夠快速找到Map對應的Reduce 問題:爲何使用靜態內部類,而不內部類。 * 答:緣由是但願能夠直接使用LogMapReducer類就能夠訪問。不須要建立LogMapReducer對象 * * 需求:分析網站訪問時間段的訪問量。 * * @author ranger * */ public class LogMapReducer {
/** * map 計算,得到每一條是數據的時間 * * @author ranger * */ static class LogMapper extends Mapper<LongWritable, Text, Text, LongWritable> {
@Override protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, LongWritable>.Context context) throws IOException, InterruptedException { String line = value.toString(); // 127.0.0.1 - - [03/Nov/2017:08:58:42 +0800] "GET / HTTP/1.1" 200 11418 // 須要的值在第四個裏面
String[] values = line.split(" "); String datestr = values[3]; // 時間處理,[03/Nov/2017:08:58:42 // 第一步:去掉[ StringBuilder sb = new StringBuilder(datestr); String resultDate = sb.substring(1); // 日期的轉換,注意這個是美國時間,須要設置爲US SimpleDateFormat format = new SimpleDateFormat("dd/MMM/yyyy:HH:mm:ss",Locale.US);
Date date; try { date = format.parse(resultDate); // 如何得到日期裏面的一個單位, Calendar calendar = Calendar.getInstance(); calendar.setTime(date); //得到24小時制的時間 int hour = calendar.get(Calendar.HOUR_OF_DAY);
System.out.println(datestr + "====時間字符串"); context.write(new Text(hour + ""), new LongWritable(1));
} catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); }
}
}
// 01 123123 static class LogReducer extends Reducer<Text, LongWritable, Text, LongWritable> {
@Override protected void reduce(Text key, Iterable<LongWritable> values, Reducer<Text, LongWritable, Text, LongWritable>.Context context) throws IOException, InterruptedException { long count = 0; for (LongWritable val : values) { // 每次迭代加1 count = count + val.get(); } context.write(key, new LongWritable(count));
}
}
} |
HA是High Available縮寫,是雙機集羣系統簡稱,是一個高可用性集羣,是保證業務連續性的有效解決方案,通常有兩個或兩個以上的節點,且分爲活動節點及備用節點。
工做後會常常聽到「雙機熱備」這個詞。表達的是同一意思。
--來自百度百科
「高可用性」(High Availability)一般來描述一個系統通過專門的設計,從而減小停工時間,而保持其服務的高度可用性。
--來自百度百科
上面的集羣部署是咱們發現只有NameNode節點,萬一NameNode節點宕機,集羣也崩潰了。
咱們發現ResourceManager節點也只有一個,萬一ResourceManager節點宕機,集羣也崩潰。
因此咱們須要經過HA的機制來部署NameNode節點以及ResourceManger來確保集羣的容錯性、可用行。
--如圖:經過HA集羣,能夠實現NameNode和ResourceManager的雙機熱備,在一臺NameNode或者ResourceManager崩潰後,另一臺能夠直接切換。
|
需求:部署一個HA的Hadoop集羣。
如圖所示:
|
u1~u7的準備,統一配置。<參考單機部署與集羣部署章節>
注意:只要在u1和u3配置slaves就能夠。
<參考Zookeeper章節>
|
配置NameNode的HA集羣,就是配置NameNode的雙機熱備。
--基於以上描述的流程,NameNode必須配置一下參數
(1)必須指定Zookeeper服務器
(2)必須指定兩臺NameNode的服務器名稱
(3)必須指定使用的是HA策略
(4)必須指定Journal節點位置
(5)必須配置zkfc發送shell的殺機進程的ssh登陸信息
(6)必須配置rpc入口,實現元數據的同步
--由於NameNode是HDFS文件系統的配置,因此能夠配置的配置文件使用兩個
(1)core-site.xml
(2)hdfs-site.xml
--在core-site.xml配置zookeeper服務器訪問路徑
<configuration> <!-1.指定默認的HDFS操做路徑--> <property> <name>fs.defaultFS</name> <value>hdfs://ns</value> </property> <!--2.設置數據的存放位置--> <property> <name>hadoop.tmp.dir</name> <value>/home/hadoop/app/hadoop-2.9.1/data/</value> </property> <!--3.設置Zookeeper集羣的訪問路徑--> <property> <name>ha.zookeeper.quorum</name> <value>u5:2181,u6:2181,u7:2181</value> </property> </configuration>
|
問題:爲何Zookeeper配置core-site.xml裏面呢?
答:由於Zookeeper不只僅在NameNode裏面用,能夠在Hadoop其餘不少地方用到,因此配置在hadoop核心文件裏面
<configuration> <!--1.設置數據副本的個數--> <property> <name>dfs.replication</name> <value>3</value> </property> <!--設置默認使用ha集羣---> <property> <name>dfs.ha.automatic-failover.enabled</name> <value>true</value> </property>
<!--設置HA的HDFS的訪問服務名--> <property> <name>dfs.nameservices</name> <value>ns</value> </property> <!--設置訪問服務名,對應的NameNode--> <property> <name>dfs.ha.namenodes.ns</name> <value>nn1,nn2</value> <!--配置rpc通信訪問路徑--> <property> <name>dfs.namenode.rpc-address.ns.nn1</name> <value>u1:8020</value> </property> <property> <name>dfs.namenode.rpc-address.ns.nn2</name> <value>u2:8020</value> </property> <!--配置https通信訪問路徑--> <property> <name>dfs.namenode.http-address.sn.nn1</name> <value>u1:50070</value> </property> <property> <name>dfs.namenode.http-address.sn.nn2</name> <value>u1:50070</value> </property> <!--配置qjouranl的節點路徑--> <property> <name>dfs.namenode.shared.edits.dir</name> <value>qjournal://u5:8485;u6:8485;u7:8485/sn</value> </property> <property> <!--配置qjouranl的節點數據存放路徑-->
<name>dfs.journalnode.edits.dir</name> <value>/home/hadoop/app/hadoop-2.9.1/data/</value> </property>
<!--配置客戶端 訪問NameNode的HA的入口類--> <property> <name>dfs.client.failover.proxy.provider.mycluster</name> <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value> </property> <!--設置zkfc遠程殺死進程配置,使用ssh登陸--> <property> <name>dfs.ha.fencing.methods</name> <value>sshfence</value> </property> <!--設置zkfc遠程殺死進程配置,指定登陸的公鑰--> <property> <name>dfs.ha.fencing.ssh.private-key-files</name> <value>/home/hadoop/.ssh/id_rsa</value> </property> </property> </configuration>
|
序號 |
參數名 |
參數值 |
參數說明 |
1 |
hadoop.tmp.dir |
/tmp/hadoop-${user.name} |
數據目錄設置 |
2 |
hadoop.native.lib |
true |
使用本地hadoop庫標識。 |
3 |
hadoop.http.filter.initializers |
|
http服務器過濾鏈設置 |
4 |
hadoop.security.group.mapping |
org.apache.hadoop.security.ShellBasedUnixGroupsMapping |
組內用戶的列表的類設定 |
5 |
hadoop.security.authorization |
false |
服務端認證開啓 |
6 |
hadoop.security.authentication |
simple |
無認證或認證設置 |
7 |
hadoop.security.token.service.use_ip |
true |
是否開啓使用IP地址做爲鏈接的開關 |
8 |
hadoop.logfile.size |
10000000 |
日誌文件最大爲10M |
9 |
hadoop.logfile.count |
10 |
日誌文件數量爲10個 |
10 |
io.file.buffer.size |
4096 |
流文件的緩衝區爲4K |
11 |
io.bytes.per.checksum |
512 |
校驗位數爲512字節 |
12 |
io.skip.checksum.errors |
FALSE |
校驗出錯後是拋出異常仍是略過標識。True則略過。 |
13 |
io.compression.codecs |
org.apache.hadoop.io.compress.DefaultCodec, |
壓縮和解壓的方式設置 |
org.apache.hadoop.io.compress.GzipCodec, |
|||
org.apache.hadoop.io.compress.BZip2Codec, |
|||
org.apache.hadoop.io.compress.SnappyCodec |
|||
14 |
io.serializations |
org.apache.hadoop.io.serializer.WritableSerialization |
序例化和反序列化的類設定 |
15 |
fs.default.name |
file:/// |
缺省的文件系統URI標識設定。 |
16 |
fs.trash.interval |
0 |
文件廢棄標識設定,0爲禁止此功能 |
17 |
fs.file.impl |
org.apache.hadoop.fs.LocalFileSystem |
本地文件操做類設置 |
18 |
fs.hdfs.impl |
org.apache.hadoop.hdfs.DistributedFileSystem |
HDFS文件操做類設置 |
19 |
fs.s3.impl |
org.apache.hadoop.fs.s3.S3FileSystem |
S3文件操做類設置 |
20 |
fs.s3n.impl |
org.apache.hadoop.fs.s3native.NativeS3FileSystem |
S3文件本地操做類設置 |
21 |
fs.kfs.impl |
org.apache.hadoop.fs.kfs.KosmosFileSystem |
KFS文件操做類設置. |
22 |
fs.hftp.impl |
org.apache.hadoop.hdfs.HftpFileSystem |
HTTP方式操做文件設置 |
23 |
fs.hsftp.impl |
org.apache.hadoop.hdfs.HsftpFileSystem |
HTTPS方式操做文件設置 |
24 |
fs.webhdfs.impl |
org.apache.hadoop.hdfs.web.WebHdfsFileSystem |
WEB方式操做文件類設置 |
25 |
fs.ftp.impl |
org.apache.hadoop.fs.ftp.FTPFileSystem |
FTP文件操做類設置 |
26 |
fs.ramfs.impl |
org.apache.hadoop.fs.InMemoryFileSystem |
內存文件操做類設置 |
27 |
fs.har.impl |
org.apache.hadoop.fs.HarFileSystem |
壓縮文件操做類設置. |
28 |
fs.har.impl.disable.cache |
TRUE |
是否緩存har文件的標識設定 |
29 |
fs.checkpoint.dir |
${hadoop.tmp.dir}/dfs/namesecondary |
備份名稱節點的存放目前錄設置 |
30 |
fs.checkpoint.edits.dir |
${fs.checkpoint.dir} |
備份名稱節點日誌文件的存放目前錄設置 |
31 |
fs.checkpoint.period |
3600 |
動態檢查的間隔時間設置 |
32 |
fs.checkpoint.size |
67108864 |
日誌文件大小爲64M |
33 |
fs.s3.block.size |
67108864 |
寫S3文件系統的塊的大小爲64M |
34 |
fs.s3.buffer.dir |
${hadoop.tmp.dir}/s3 |
S3文件數據的本地存放目錄 |
35 |
fs.s3.maxRetries |
4 |
S3文件數據的償試讀寫次數 |
36 |
fs.s3.sleepTimeSeconds |
10 |
S3文件償試的間隔 |
37 |
local.cache.size |
10737418240 |
緩存大小設置爲10GB |
38 |
io.seqfile.compress.blocksize |
1000000 |
壓縮流式文件中的最小塊數爲100萬 |
39 |
io.seqfile.lazydecompress |
TRUE |
塊是否須要壓縮標識設定 |
40 |
io.seqfile.sorter.recordlimit |
1000000 |
內存中排序記錄塊類最小爲100萬 |
41 |
io.mapfile.bloom.size |
1048576 |
BloomMapFiler過濾量爲1M |
42 |
io.mapfile.bloom.error.rate |
0.005 |
|
43 |
hadoop.util.hash.type |
murmur |
缺乏hash方法爲murmur |
44 |
ipc.client.idlethreshold |
4000 |
鏈接數據最小閥值爲4000 |
45 |
ipc.client.kill.max |
10 |
一個客戶端鏈接數最大值爲10 |
46 |
ipc.client.connection.maxidletime |
10000 |
斷開與服務器鏈接的時間最大爲10秒 |
47 |
ipc.client.connect.max.retries |
10 |
創建與服務器鏈接的重試次數爲10次 |
48 |
ipc.server.listen.queue.size |
128 |
接收客戶鏈接的監聽隊例的長度爲128 |
49 |
ipc.server.tcpnodelay |
FALSE |
開啓或關閉服務器端TCP鏈接算法 |
50 |
ipc.client.tcpnodelay |
FALSE |
開啓或關閉客戶端TCP鏈接算法 |
51 |
webinterface.private.actions |
FALSE |
Web交互的行爲設定 |
52 |
hadoop.rpc.socket.factory.class.default |
org.apache.hadoop.net.StandardSocketFactory |
缺省的socket工廠類設置 |
53 |
hadoop.rpc.socket.factory.class.ClientProtocol |
|
與dfs鏈接時的缺省socket工廠類 |
54 |
hadoop.socks.server |
|
服務端的工廠類缺省設置爲SocksSocketFactory. |
55 |
topology.node.switch.mapping.impl |
org.apache.hadoop.net.ScriptBasedMapping |
|
56 |
topology.script.file.name |
|
|
57 |
topology.script.number.args |
100 |
參數數量最多爲100 |
58 |
hadoop.security.uid.cache.secs |
14400 |
|
序號 |
參數名 |
參數值 |
參數說明 |
1 |
dfs.namenode.logging.level |
info |
輸出日誌類型 |
2 |
dfs.secondary.http.address |
0.0.0.0:50090 |
備份名稱節點的http協議訪問地址與端口 |
3 |
dfs.datanode.address |
0.0.0.0:50010 |
數據節點的TCP管理服務地址和端口 |
4 |
dfs.datanode.http.address |
0.0.0.0:50075 |
數據節點的HTTP協議訪問地址和端口 |
5 |
dfs.datanode.ipc.address |
0.0.0.0:50020 |
數據節點的IPC服務訪問地址和端口 |
6 |
dfs.datanode.handler.count |
3 |
數據節點的服務鏈接處理線程數 |
7 |
dfs.http.address |
0.0.0.0:50070 |
名稱節點的http協議訪問地址與端口 |
8 |
dfs.https.enable |
false |
支持https訪問方式標識 |
9 |
dfs.https.need.client.auth |
false |
客戶端指定https訪問標識 |
10 |
dfs.https.server.keystore.resource |
ssl-server.xml |
Ssl密鑰服務端的配置文件 |
11 |
dfs.https.client.keystore.resource |
ssl-client.xml |
Ssl密鑰客戶端的配置文件 |
12 |
dfs.datanode.https.address |
0.0.0.0:50475 |
數據節點的HTTPS協議訪問地址和端口 |
13 |
dfs.https.address |
0.0.0.0:50470 |
名稱節點的HTTPS協議訪問地址和端口 |
14 |
dfs.datanode.dns.interface |
default |
數據節點採用IP地址標識 |
15 |
dfs.datanode.dns.nameserver |
default |
指定DNS的IP地址 |
16 |
dfs.replication.considerLoad |
true |
加載目標或不加載的標識 |
17 |
dfs.default.chunk.view.size |
32768 |
瀏覽時的文件塊大小設置爲32K |
18 |
dfs.datanode.du.reserved |
0 |
每一個卷預留的空閒空間數量 |
19 |
dfs.name.dir |
${hadoop.tmp.dir}/dfs/name |
存貯在本地的名字節點數據鏡象的目錄,做爲名字節點的冗餘備份 |
20 |
dfs.name.edits.dir |
${dfs.name.dir} |
存貯文件操做過程信息的存貯目錄 |
21 |
dfs.web.ugi |
webuser,webgroup |
Web接口訪問的用戶名和組的賬戶設定 |
22 |
dfs.permissions |
true |
文件操做時的權限檢查標識。 |
23 |
dfs.permissions.supergroup |
supergroup |
超級用戶的組名定義 |
24 |
dfs.block.access.token.enable |
false |
數據節點訪問令牌標識 |
25 |
dfs.block.access.key.update.interval |
600 |
升級訪問鑰時的間隔時間 |
26 |
dfs.block.access.token.lifetime |
600 |
訪問令牌的有效時間 |
27 |
dfs.data.dir |
${hadoop.tmp.dir}/dfs/data |
數據節點的塊本地存放目錄 |
28 |
dfs.datanode.data.dir.perm |
755 |
數據節點的存貯塊的目錄訪問權限設置 |
29 |
dfs.replication |
3 |
缺省的數據塊副本的數量 |
30 |
dfs.replication.max |
512 |
塊複製的最大數量 |
31 |
dfs.replication.min |
1 |
塊複製的最小數量 |
32 |
dfs.block.size |
67108864 |
缺省的文件塊大小爲64M |
33 |
dfs.df.interval |
60000 |
磁盤空間統計間隔爲6秒 |
34 |
dfs.client.block.write.retries |
3 |
塊寫入出錯時的重試次數 |
35 |
dfs.blockreport.intervalMsec |
3600000 |
塊的報告間隔時爲1小時 |
36 |
dfs.blockreport.initialDelay |
0 |
塊順序報告的間隔時間 |
37 |
dfs.heartbeat.interval |
3 |
數據節點的心跳檢測間隔時間 |
38 |
dfs.namenode.handler.count |
10 |
名稱節點的鏈接處理的線程數量 |
39 |
dfs.safemode.threshold.pct |
0.999f |
啓動安全模式的閥值設定 |
40 |
dfs.safemode.extension |
30000 |
當閥值達到量值後擴展的時限 |
41 |
dfs.balance.bandwidthPerSec |
1048576 |
啓動負載均衡的數據節點可利用帶寬最大值爲1M |
42 |
dfs.hosts |
|
可與名稱節點鏈接的主機地址文件指定。 |
43 |
dfs.hosts.exclude |
|
不充計與名稱節點鏈接的主機地址文件設定 |
44 |
dfs.max.objects |
0 |
文件數、目錄數、塊數的最大數量 |
45 |
dfs.namenode.decommission.interval |
30 |
名稱節點解除命令執行時的監測時間週期 |
46 |
dfs.namenode.decommission.nodes.per.interval |
5 |
名稱節點解除命令執行是否完檢測次數 |
47 |
dfs.replication.interval |
3 |
名稱節點計算數據節點的複製工做的週期數. |
48 |
dfs.access.time.precision |
3600000 |
充許訪問文件的時間精確到1小時 |
49 |
dfs.support.append |
false |
是否充許連接文件指定 |
50 |
dfs.namenode.delegation.key.update-interval |
86400000 |
名稱節點上的代理令牌的主key的更新間隔時間爲24小時 |
51 |
dfs.namenode.delegation.token.max-lifetime |
604800000 |
代理令牌的有效時間最大值爲7天 |
52 |
dfs.namenode.delegation.token.renew-interval |
86400000 |
代理令牌的更新時間爲24小時 |
53 |
dfs.datanode.failed.volumes.tolerated |
0 |
決定中止數據節點提供服務充許卷的出錯次數。0次則任何卷出錯都要中止數據節點 |
序號 |
參數名 |
參數值 |
參數說明 |
1 |
hadoop.job.history.location |
|
做業跟蹤管理器的靜態歷史文件的存放目錄。 |
2 |
hadoop.job.history.user.location |
|
能夠指定具體某個做業的跟蹤管理器的歷史文件存放目錄 |
3 |
mapred.job.tracker.history.completed.location |
|
已完成做業的歷史文件的存放目錄 |
4 |
io.sort.factor |
10 |
排完序的文件的合併時的打開文件句柄數 |
5 |
io.sort.mb |
100 |
排序文件的內存緩存大小爲100M |
6 |
io.sort.record.percent |
0.05 |
排序線程阻塞的內存緩存剩餘比率 |
7 |
io.sort.spill.percent |
0.80 |
當緩衝佔用量爲該值時,線程須要將內容先備份到磁盤中。 |
8 |
io.map.index.skip |
0 |
索引條目的間隔設定 |
9 |
mapred.job.tracker |
local |
做業跟蹤管理器是否和MR任務在一個進程中 |
10 |
mapred.job.tracker.http.address |
0.0.0.0:50030 |
做業跟蹤管理器的HTTP服務器訪問端口和地址 |
11 |
mapred.job.tracker.handler.count |
10 |
做業跟蹤管理器的管理線程數,線程數比例是任務管理跟蹤器數量的0.04 |
12 |
mapred.task.tracker.report.address |
127.0.0.1:0 |
任務管理跟蹤器的主機地址和端口地址 |
13 |
mapred.local.dir |
${hadoop.tmp.dir}/mapred/local |
MR的中介數據文件存放目錄 |
14 |
mapred.system.dir |
${hadoop.tmp.dir}/mapred/system |
MR的控制文件存放目錄 |
15 |
mapreduce.jobtracker.staging.root.dir |
${hadoop.tmp.dir}/mapred/staging |
每一個正在運行做業文件的存放區 |
16 |
mapred.temp.dir |
${hadoop.tmp.dir}/mapred/temp |
MR臨時共享文件存放區 |
17 |
mapred.local.dir.minspacestart |
0 |
MR本地中介文件刪除時,不充許有任務執行的數量值。 |
18 |
mapred.local.dir.minspacekill |
0 |
MR本地中介文件刪除時,除非全部任務都已完成的數量值。 |
19 |
mapred.tasktracker.expiry.interval |
600000 |
任務管理跟蹤器不發送心跳的累計時間間隔超過600秒,則任務管理跟蹤器失效 |
20 |
mapred.tasktracker.resourcecalculatorplugin |
|
指定的一個用戶訪問資源信息的類實例 |
21 |
mapred.tasktracker.taskmemorymanager.monitoring-interval |
5000 |
監控任務管理跟蹤器任務內存使用率的時間間隔 |
22 |
mapred.tasktracker.tasks.sleeptime-before-sigkill |
5000 |
發出進程終止後,間隔5秒後發出進程消亡信號 |
23 |
mapred.map.tasks |
2 |
每一個做業缺省的map任務數爲2 |
24 |
mapred.reduce.tasks |
1 |
每一個做業缺省的reduce任務數爲1 |
25 |
mapreduce.tasktracker.outofband.heartbeat |
false |
讓在任務結束後發出一個額外的心跳信號 |
26 |
mapreduce.tasktracker.outofband.heartbeat.damper |
1000000 |
當額外心跳信號發出量太多時,則適當阻止 |
27 |
mapred.jobtracker.restart.recover |
false |
充許任務管理器恢復時採用的方式 |
28 |
mapred.jobtracker.job.history.block.size |
3145728 |
做業歷史文件塊的大小爲3M |
29 |
mapreduce.job.split.metainfo.maxsize |
10000000 |
分隔元信息文件的最大值是10M如下 |
30 |
mapred.jobtracker.taskScheduler |
org.apache.hadoop.mapred.JobQueueTaskScheduler |
設定任務的執行計劃實現類 |
31 |
mapred.jobtracker.taskScheduler.maxRunningTasksPerJob |
|
做業同時運行的任務數的最大值 |
32 |
mapred.map.max.attempts |
4 |
Map任務的重試次數 |
33 |
mapred.reduce.max.attempts |
4 |
Reduce任務的重試次數 |
34 |
mapred.reduce.parallel.copies |
5 |
在複製階段時reduce並行傳送的值。 |
35 |
mapreduce.reduce.shuffle.maxfetchfailures |
10 |
取map輸出的最大重試次數 |
36 |
mapreduce.reduce.shuffle.connect.timeout |
180000 |
REDUCE任務鏈接任務管理器得到map輸出時的總耗時是3分鐘 |
37 |
mapreduce.reduce.shuffle.read.timeout |
180000 |
REDUCE任務等待map輸出數據的總耗時是3分鐘 |
38 |
mapred.task.timeout |
600000 |
若是任務無讀無寫時的時間耗時爲10分鐘,將被終止 |
39 |
mapred.tasktracker.map.tasks.maximum |
2 |
任管管理器可同時運行map任務數爲2 |
40 |
mapred.tasktracker.reduce.tasks.maximum |
2 |
任管管理器可同時運行reduce任務數爲2 |
41 |
mapred.jobtracker.completeuserjobs.maximum |
100 |
當用戶的完成做業數達100個後,將其放入做業歷史文件中 |
42 |
mapreduce.reduce.input.limit |
-1 |
Reduce輸入量的限制。 |
43 |
mapred.job.tracker.retiredjobs.cache.size |
1000 |
做業狀態爲已不在執行的保留在內存中的量爲1000 |
44 |
mapred.job.tracker.jobhistory.lru.cache.size |
5 |
做業歷史文件裝載到內存的數量 |
45 |
mapred.child.java.opts |
-Xmx200m |
啓動task管理的子進程時的內存設置 |
46 |
mapred.child.env |
|
子進程的參數設置 |
47 |
mapred.child.ulimit |
|
虛擬機所需內存的設定。 |
48 |
mapred.cluster.map.memory.mb |
-1 |
|
49 |
mapred.cluster.reduce.memory.mb |
-1 |
|
50 |
mapred.cluster.max.map.memory.mb |
-1 |
|
51 |
mapred.cluster.max.reduce.memory.mb |
-1 |
|
52 |
mapred.job.map.memory.mb |
-1 |
|
53 |
mapred.job.reduce.memory.mb |
-1 |
|
54 |
mapred.child.tmp |
/tmp |
Mr任務信息的存放目錄 |
55 |
mapred.inmem.merge.threshold |
1000 |
內存中的合併文件數設置 |
56 |
mapred.job.shuffle.merge.percent |
0.66 |
|
57 |
mapred.job.shuffle.input.buffer.percent |
0.70 |
|
58 |
mapred.job.reduce.input.buffer.percent |
0.0 |
|
59 |
mapred.map.tasks.speculative.execution |
true |
Map任務的多實例並行運行標識 |
60 |
mapred.reduce.tasks.speculative.execution |
true |
Reduce任務的多實例並行運行標識 |
61 |
mapred.job.reuse.jvm.num.tasks |
1 |
每虛擬機運行的任務數 |
62 |
mapred.min.split.size |
0 |
Map的輸入數據被分解的塊數設置 |
63 |
mapred.jobtracker.maxtasks.per.job |
-1 |
一個單獨做業的任務數設置 |
64 |
mapred.submit.replication |
10 |
提交做業文件的複製級別 |
65 |
mapred.tasktracker.dns.interface |
default |
任務管理跟蹤器是否報告IP地址名的開關 |
66 |
mapred.tasktracker.dns.nameserver |
default |
做業和任務管理跟蹤器之間通信方式採用的DNS服務的主機名或IP地址 |
67 |
tasktracker.http.threads |
40 |
http服務器的工做線程數量 |
68 |
mapred.task.tracker.http.address |
0.0.0.0:50060 |
任務管理跟蹤器的http服務器的地址和端口 |
69 |
keep.failed.task.files |
false |
失敗任務是否保存到文件中 |
70 |
mapred.output.compress |
false |
做業的輸出是否壓縮 |
71 |
mapred.output.compression.type |
RECORD |
做業輸出採用NONE, RECORD or BLOCK三種方式中一種壓縮的寫入到流式文件 |
72 |
mapred.output.compression.codec |
org.apache.hadoop.io.compress.DefaultCodec |
壓縮類的設置 |
73 |
mapred.compress.map.output |
false |
Map的輸出是否壓縮 |
74 |
mapred.map.output.compression.codec |
org.apache.hadoop.io.compress.DefaultCodec |
Map的輸出壓縮的實現類指定 |
75 |
map.sort.class |
org.apache.hadoop.util.QuickSort |
排序鍵的排序類指定 |
76 |
mapred.userlog.limit.kb |
0 |
每一個任務的用戶日誌文件大小 |
77 |
mapred.userlog.retain.hours |
24 |
做業完成後的用戶日誌留存時間爲24小時 |
78 |
mapred.user.jobconf.limit |
5242880 |
Jobconf的大小爲5M |
79 |
mapred.hosts |
|
可與做業管理跟蹤器鏈接的主機名 |
80 |
mapred.hosts.exclude |
|
不可與做業管理跟蹤器鏈接的主機名 |
81 |
mapred.heartbeats.in.second |
100 |
做業管理跟蹤器的每秒中到達的心跳數量爲100 |
82 |
mapred.max.tracker.blacklists |
4 |
任務管理跟蹤器的黑名單列表的數量 |
83 |
mapred.jobtracker.blacklist.fault-timeout-window |
180 |
任務管理跟蹤器超時180分鐘則訪任務將被重啓 |
84 |
mapred.jobtracker.blacklist.fault-bucket-width |
15 |
|
85 |
mapred.max.tracker.failures |
4 |
任務管理跟蹤器的失敗任務數設定 |
86 |
jobclient.output.filter |
FAILED |
控制任務的用戶日誌輸出到做業端時的過濾方式 |
87 |
mapred.job.tracker.persist.jobstatus.active |
false |
是否持久化做業管理跟蹤器的信息 |
88 |
mapred.job.tracker.persist.jobstatus.hours |
0 |
持久化做業管理跟蹤器的信息的保存時間 |
89 |
mapred.job.tracker.persist.jobstatus.dir |
/jobtracker/jobsInfo |
做業管理跟蹤器的信息存放目錄 |
90 |
mapreduce.job.complete.cancel.delegation.tokens |
true |
恢復時是否變動領牌 |
91 |
mapred.task.profile |
false |
任務分析信息是否建設標誌 |
92 |
mapred.task.profile.maps |
0-2 |
設置map任務的分析範圍 |
93 |
mapred.task.profile.reduces |
0-2 |
設置reduce任務的分析範圍 |
94 |
mapred.line.input.format.linespermap |
1 |
每次切分的行數設置 |
95 |
mapred.skip.attempts.to.start.skipping |
2 |
在跳轉模式未被設定的狀況下任務的重試次數 |
96 |
mapred.skip.map.auto.incr.proc.count |
true |
MapRunner在調用map功能後的增量處理方式設置 |
97 |
mapred.skip.reduce.auto.incr.proc.count |
true |
在調用reduce功能後的增量處理方式設置 |
98 |
mapred.skip.out.dir |
|
跳過記錄的輸出目錄 |
99 |
mapred.skip.map.max.skip.records |
0 |
|
100 |
mapred.skip.reduce.max.skip.groups |
0 |
|
101 |
job.end.retry.attempts |
0 |
Hadoop償試鏈接通知器的次數 |
102 |
job.end.retry.interval |
30000 |
通知償試迴應的間隔操做爲30秒 |
103 |
hadoop.rpc.socket.factory.class.JobSubmissionProtocol |
|
指定與做業跟蹤管理器的通信方式,缺省是採用rpc方式 |
104 |
mapred.task.cache.levels |
2 |
任務緩存級別設置 |
105 |
mapred.queue.names |
default |
分隔做業隊例的分隔符設定 |
106 |
mapred.acls.enabled |
false |
指定ACL訪問控制列表 |
107 |
mapred.queue.default.state |
RUNNING |
定義隊列的狀態 |
108 |
mapred.job.queue.name |
default |
已提交做業的隊列設定 |
109 |
mapreduce.job.acl-modify-job |
|
指定可修改做業的ACL列表 |
110 |
mapreduce.job.acl-view-job |
|
指定可瀏臨做業的ACL列表 |
111 |
mapred.tasktracker.indexcache.mb |
10 |
任務管理跟蹤器的索引內存的最大容器 |
112 |
mapred.combine.recordsBeforeProgress |
10000 |
在聚合處理時的記錄塊數 |
113 |
mapred.merge.recordsBeforeProgress |
10000 |
在彙總處理時的記錄塊數 |
114 |
mapred.reduce.slowstart.completed.maps |
0.05 |
|
115 |
mapred.task.tracker.task-controller |
org.apache.hadoop.mapred.DefaultTaskController |
任務管理器的設定 |
116 |
mapreduce.tasktracker.group |
|
任務管理器的組成員設定 |
117 |
mapred.healthChecker.script.path |
|
腳本的絕對路徑指定,這些腳本是心跳服務的 |
118 |
mapred.healthChecker.interval |
60000 |
節點心跳信息的間隔 |
119 |
mapred.healthChecker.script.timeout |
600000 |
|
120 |
mapred.healthChecker.script.args |
|
參數列表 |
121 |
mapreduce.job.counters.limit |
120 |
做業計數器的最小值 |
序號 |
參數 |
默認值 |
參數說明 |
1 |
yarn.resourcemanager.hostname |
|
RM的hostname |
2 |
yarn.resourcemanager.address |
${yarn.resourcemanager.hostname}:8032 |
RM對客戶端暴露的地址,客戶端經過該地址向RM提交應用程序等 |
3 |
yarn.resourcemanager.scheduler.address |
${yarn.resourcemanager.hostname}:8030 |
RM對AM暴露的地址,AM經過地址想RM申請資源,釋放資源等 |
4 |
yarn.resourcemanager.webapp.address |
${yarn.resourcemanager.hostname}:8088 |
RM對外暴露的web http地址,用戶可經過該地址在瀏覽器中查看集羣信息 |
5 |
yarn.resourcemanager.webapp.https.address |
${yarn.resourcemanager.hostname}:8090 |
web https 地址 |
6 |
yarn.resourcemanager.resource-tracker.address |
${yarn.resourcemanager.hostname}:8031 |
RM對NM暴露地址,NM經過該地址向RM彙報心跳,領取任務等 |
7 |
yarn.resourcemanager.resource-tracker.client.thread-count |
50 |
處理來自NM的RPC請求的handler數 |
8 |
yarn.resourcemanager.admin.address |
${yarn.resourcemanager.hostname}:8033 |
管理員能夠經過該地址向RM發送管理命令等 |
9 |
yarn.resourcemanager.scheduler.class |
org.apache.hadoop.yarn.server.resourcemanager |
資源調度器主類 |
10 |
.scheduler.capacity.CapacityScheduler |
||
11 |
yarn.resourcemanager.scheduler.client.thread-count |
50 |
處理來自AM的RPC請求的handler數 |
12 |
yarn.scheduler.minimum-allocation-mb |
1024 |
可申請的最少內存資源,以MB爲單位 |
13 |
yarn.scheduler.maximum-allocation-mb |
8192 |
可申請的最大內存資源,以MB爲單位 |
14 |
yarn.scheduler.minimum-allocation-vcores |
1 |
可申請的最小虛擬CPU個數 |
15 |
yarn.scheduler.maximum-allocation-vcores |
32 |
可申請的最 大虛擬CPU個數 |
16 |
yarn.nodemanager.local-dirs |
${hadoop.tmp.dir}/nm-local-dir |
中間結果存放位置,可配置多目錄 |
17 |
yarn.log-aggregation-enable |
FALSE |
是否啓用日誌聚合 |
18 |
yarn.nodemanager.remote-app-log-dir |
/tmp/logs |
日誌聚合目錄 |
19 |
yarn.nodemanager.resource.memory-mb |
8192 |
NM總的可用物理內存,以MB爲單位。一旦設置,不可動態修改 |
20 |
yarn.nodemanager.resource.cpu-vcores |
8 |
可分配的CPU個數 |
21 |
yarn.nodemanager.aux-services |
|
NodeManager上運行的附屬服務。需配置成mapreduce_shuffle,纔可運行MapReduce程序 |
廢棄屬性 |
新屬性 |
create.empty.dir.if.nonexist |
mapreduce.jobcontrol.createdir.ifnotexist |
dfs.access.time.precision |
dfs.namenode.accesstime.precision |
dfs.backup.address |
dfs.namenode.backup.address |
dfs.backup.http.address |
dfs.namenode.backup.http-address |
dfs.balance.bandwidthPerSec |
dfs.datanode.balance.bandwidthPerSec |
dfs.block.size |
dfs.blocksize |
dfs.data.dir |
dfs.datanode.data.dir |
dfs.datanode.max.xcievers |
dfs.datanode.max.transfer.threads |
dfs.df.interval |
fs.df.interval |
dfs.encryption.key.provider.uri |
hadoop.security.key.provider.path |
dfs.federation.nameservice.id |
dfs.nameservice.id |
dfs.federation.nameservices |
dfs.nameservices |
dfs.http.address |
dfs.namenode.http-address |
dfs.https.address |
dfs.namenode.https-address |
dfs.https.client.keystore.resource |
dfs.client.https.keystore.resource |
dfs.https.enable |
dfs.http.policy |
dfs.https.need.client.auth |
dfs.client.https.need-auth |
dfs.max.objects |
dfs.namenode.max.objects |
dfs.max-repl-streams |
dfs.namenode.replication.max-streams |
dfs.name.dir |
dfs.namenode.name.dir |
dfs.name.dir.restore |
dfs.namenode.name.dir.restore |
dfs.name.edits.dir |
dfs.namenode.edits.dir |
dfs.permissions |
dfs.permissions.enabled |
dfs.permissions.supergroup |
dfs.permissions.superusergroup |
dfs.read.prefetch.size |
dfs.client.read.prefetch.size |
dfs.replication.considerLoad |
dfs.namenode.replication.considerLoad |
dfs.replication.interval |
dfs.namenode.replication.interval |
dfs.replication.min |
dfs.namenode.replication.min |
dfs.replication.pending.timeout.sec |
dfs.namenode.replication.pending.timeout-sec |
dfs.safemode.extension |
dfs.namenode.safemode.extension |
dfs.safemode.threshold.pct |
dfs.namenode.safemode.threshold-pct |
dfs.secondary.http.address |
dfs.namenode.secondary.http-address |
dfs.socket.timeout |
dfs.client.socket-timeout |
dfs.umaskmode |
fs.permissions.umask-mode |
dfs.web.ugi |
hadoop.http.staticuser.user |
dfs.write.packet.size |
dfs.client-write-packet-size |
fs.checkpoint.dir |
dfs.namenode.checkpoint.dir |
fs.checkpoint.edits.dir |
dfs.namenode.checkpoint.edits.dir |
fs.checkpoint.period |
dfs.namenode.checkpoint.period |
fs.default.name |
fs.defaultFS |
fs.s3a.server-side-encryption-key |
fs.s3a.server-side-encryption.key |
hadoop.configured.node.mapping |
net.topology.configured.node.mapping |
hadoop.job.history.location |
mapreduce.jobtracker.jobhistory.location |
hadoop.native.lib |
io.native.lib.available |
hadoop.net.static.resolutions |
mapreduce.tasktracker.net.static.resolutions |
hadoop.pipes.command-file.keep |
mapreduce.pipes.commandfile.preserve |
hadoop.pipes.executable.interpretor |
mapreduce.pipes.executable.interpretor |
hadoop.pipes.executable |
mapreduce.pipes.executable |
hadoop.pipes.java.mapper |
mapreduce.pipes.isjavamapper |
hadoop.pipes.java.recordreader |
mapreduce.pipes.isjavarecordreader |
hadoop.pipes.java.recordwriter |
mapreduce.pipes.isjavarecordwriter |
hadoop.pipes.java.reducer |
mapreduce.pipes.isjavareducer |
hadoop.pipes.partitioner |
mapreduce.pipes.partitioner |
heartbeat.recheck.interval |
dfs.namenode.heartbeat.recheck-interval |
io.bytes.per.checksum |
dfs.bytes-per-checksum |
io.sort.factor |
mapreduce.task.io.sort.factor |
io.sort.mb |
mapreduce.task.io.sort.mb |
io.sort.spill.percent |
mapreduce.map.sort.spill.percent |
jobclient.completion.poll.interval |
mapreduce.client.completion.pollinterval |
jobclient.output.filter |
mapreduce.client.output.filter |
jobclient.progress.monitor.poll.interval |
mapreduce.client.progressmonitor.pollinterval |
job.end.notification.url |
mapreduce.job.end-notification.url |
job.end.retry.attempts |
mapreduce.job.end-notification.retry.attempts |
job.end.retry.interval |
mapreduce.job.end-notification.retry.interval |
job.local.dir |
mapreduce.job.local.dir |
keep.failed.task.files |
mapreduce.task.files.preserve.failedtasks |
keep.task.files.pattern |
mapreduce.task.files.preserve.filepattern |
key.value.separator.in.input.line |
mapreduce.input.keyvaluelinerecordreader.key.value.separator |
local.cache.size |
mapreduce.tasktracker.cache.local.size |
map.input.file |
mapreduce.map.input.file |
map.input.length |
mapreduce.map.input.length |
map.input.start |
mapreduce.map.input.start |
map.output.key.field.separator |
mapreduce.map.output.key.field.separator |
map.output.key.value.fields.spec |
mapreduce.fieldsel.map.output.key.value.fields.spec |
mapred.acls.enabled |
mapreduce.cluster.acls.enabled |
mapred.binary.partitioner.left.offset |
mapreduce.partition.binarypartitioner.left.offset |
mapred.binary.partitioner.right.offset |
mapreduce.partition.binarypartitioner.right.offset |
mapred.cache.archives |
mapreduce.job.cache.archives |
mapred.cache.archives.timestamps |
mapreduce.job.cache.archives.timestamps |
mapred.cache.files |
mapreduce.job.cache.files |
mapred.cache.files.timestamps |
mapreduce.job.cache.files.timestamps |
mapred.cache.localArchives |
mapreduce.job.cache.local.archives |
mapred.cache.localFiles |
mapreduce.job.cache.local.files |
mapred.child.tmp |
mapreduce.task.tmp.dir |
mapred.cluster.average.blacklist.threshold |
mapreduce.jobtracker.blacklist.average.threshold |
mapred.cluster.map.memory.mb |
mapreduce.cluster.mapmemory.mb |
mapred.cluster.max.map.memory.mb |
mapreduce.jobtracker.maxmapmemory.mb |
mapred.cluster.max.reduce.memory.mb |
mapreduce.jobtracker.maxreducememory.mb |
mapred.cluster.reduce.memory.mb |
mapreduce.cluster.reducememory.mb |
mapred.committer.job.setup.cleanup.needed |
mapreduce.job.committer.setup.cleanup.needed |
mapred.compress.map.output |
mapreduce.map.output.compress |
mapred.data.field.separator |
mapreduce.fieldsel.data.field.separator |
mapred.debug.out.lines |
mapreduce.task.debugout.lines |
mapred.healthChecker.interval |
mapreduce.tasktracker.healthchecker.interval |
mapred.healthChecker.script.args |
mapreduce.tasktracker.healthchecker.script.args |
mapred.healthChecker.script.path |
mapreduce.tasktracker.healthchecker.script.path |
mapred.healthChecker.script.timeout |
mapreduce.tasktracker.healthchecker.script.timeout |
mapred.heartbeats.in.second |
mapreduce.jobtracker.heartbeats.in.second |
mapred.hosts.exclude |
mapreduce.jobtracker.hosts.exclude.filename |
mapred.hosts |
mapreduce.jobtracker.hosts.filename |
mapred.inmem.merge.threshold |
mapreduce.reduce.merge.inmem.threshold |
mapred.input.dir.formats |
mapreduce.input.multipleinputs.dir.formats |
mapred.input.dir.mappers |
mapreduce.input.multipleinputs.dir.mappers |
mapred.input.dir |
mapreduce.input.fileinputformat.inputdir |
mapred.input.pathFilter.class |
mapreduce.input.pathFilter.class |
mapred.jar |
mapreduce.job.jar |
mapred.job.classpath.archives |
mapreduce.job.classpath.archives |
mapred.job.classpath.files |
mapreduce.job.classpath.files |
mapred.job.id |
mapreduce.job.id |
mapred.jobinit.threads |
mapreduce.jobtracker.jobinit.threads |
mapred.job.map.memory.mb |
mapreduce.map.memory.mb |
mapred.job.name |
mapreduce.job.name |
mapred.job.priority |
mapreduce.job.priority |
mapred.job.queue.name |
mapreduce.job.queuename |
mapred.job.reduce.input.buffer.percent |
mapreduce.reduce.input.buffer.percent |
mapred.job.reduce.markreset.buffer.percent |
mapreduce.reduce.markreset.buffer.percent |
mapred.job.reduce.memory.mb |
mapreduce.reduce.memory.mb |
mapred.job.reduce.total.mem.bytes |
mapreduce.reduce.memory.totalbytes |
mapred.job.reuse.jvm.num.tasks |
mapreduce.job.jvm.numtasks |
mapred.job.shuffle.input.buffer.percent |
mapreduce.reduce.shuffle.input.buffer.percent |
mapred.job.shuffle.merge.percent |
mapreduce.reduce.shuffle.merge.percent |
mapred.job.tracker.handler.count |
mapreduce.jobtracker.handler.count |
mapred.job.tracker.history.completed.location |
mapreduce.jobtracker.jobhistory.completed.location |
mapred.job.tracker.http.address |
mapreduce.jobtracker.http.address |
mapred.jobtracker.instrumentation |
mapreduce.jobtracker.instrumentation |
mapred.jobtracker.job.history.block.size |
mapreduce.jobtracker.jobhistory.block.size |
mapred.job.tracker.jobhistory.lru.cache.size |
mapreduce.jobtracker.jobhistory.lru.cache.size |
mapred.job.tracker |
mapreduce.jobtracker.address |
mapred.jobtracker.maxtasks.per.job |
mapreduce.jobtracker.maxtasks.perjob |
mapred.job.tracker.persist.jobstatus.active |
mapreduce.jobtracker.persist.jobstatus.active |
mapred.job.tracker.persist.jobstatus.dir |
mapreduce.jobtracker.persist.jobstatus.dir |
mapred.job.tracker.persist.jobstatus.hours |
mapreduce.jobtracker.persist.jobstatus.hours |
mapred.jobtracker.restart.recover |
mapreduce.jobtracker.restart.recover |
mapred.job.tracker.retiredjobs.cache.size |
mapreduce.jobtracker.retiredjobs.cache.size |
mapred.job.tracker.retire.jobs |
mapreduce.jobtracker.retirejobs |
mapred.jobtracker.taskalloc.capacitypad |
mapreduce.jobtracker.taskscheduler.taskalloc.capacitypad |
mapred.jobtracker.taskScheduler |
mapreduce.jobtracker.taskscheduler |
mapred.jobtracker.taskScheduler.maxRunningTasksPerJob |
mapreduce.jobtracker.taskscheduler.maxrunningtasks.perjob |
mapred.join.expr |
mapreduce.join.expr |
mapred.join.keycomparator |
mapreduce.join.keycomparator |
mapred.lazy.output.format |
mapreduce.output.lazyoutputformat.outputformat |
mapred.line.input.format.linespermap |
mapreduce.input.lineinputformat.linespermap |
mapred.linerecordreader.maxlength |
mapreduce.input.linerecordreader.line.maxlength |
mapred.local.dir |
mapreduce.cluster.local.dir |
mapred.local.dir.minspacekill |
mapreduce.tasktracker.local.dir.minspacekill |
mapred.local.dir.minspacestart |
mapreduce.tasktracker.local.dir.minspacestart |
mapred.map.child.env |
mapreduce.map.env |
mapred.map.child.java.opts |
mapreduce.map.java.opts |
mapred.map.child.log.level |
mapreduce.map.log.level |
mapred.map.max.attempts |
mapreduce.map.maxattempts |
mapred.map.output.compression.codec |
mapreduce.map.output.compress.codec |
mapred.mapoutput.key.class |
mapreduce.map.output.key.class |
mapred.mapoutput.value.class |
mapreduce.map.output.value.class |
mapred.mapper.regex.group |
mapreduce.mapper.regexmapper..group |
mapred.mapper.regex |
mapreduce.mapper.regex |
mapred.map.task.debug.script |
mapreduce.map.debug.script |
mapred.map.tasks |
mapreduce.job.maps |
mapred.map.tasks.speculative.execution |
mapreduce.map.speculative |
mapred.max.map.failures.percent |
mapreduce.map.failures.maxpercent |
mapred.max.reduce.failures.percent |
mapreduce.reduce.failures.maxpercent |
mapred.max.split.size |
mapreduce.input.fileinputformat.split.maxsize |
mapred.max.tracker.blacklists |
mapreduce.jobtracker.tasktracker.maxblacklists |
mapred.max.tracker.failures |
mapreduce.job.maxtaskfailures.per.tracker |
mapred.merge.recordsBeforeProgress |
mapreduce.task.merge.progress.records |
mapred.min.split.size |
mapreduce.input.fileinputformat.split.minsize |
mapred.min.split.size.per.node |
mapreduce.input.fileinputformat.split.minsize.per.node |
mapred.min.split.size.per.rack |
mapreduce.input.fileinputformat.split.minsize.per.rack |
mapred.output.compression.codec |
mapreduce.output.fileoutputformat.compress.codec |
mapred.output.compression.type |
mapreduce.output.fileoutputformat.compress.type |
mapred.output.compress |
mapreduce.output.fileoutputformat.compress |
mapred.output.dir |
mapreduce.output.fileoutputformat.outputdir |
mapred.output.key.class |
mapreduce.job.output.key.class |
mapred.output.key.comparator.class |
mapreduce.job.output.key.comparator.class |
mapred.output.value.class |
mapreduce.job.output.value.class |
mapred.output.value.groupfn.class |
mapreduce.job.output.group.comparator.class |
mapred.permissions.supergroup |
mapreduce.cluster.permissions.supergroup |
mapred.pipes.user.inputformat |
mapreduce.pipes.inputformat |
mapred.reduce.child.env |
mapreduce.reduce.env |
mapred.reduce.child.java.opts |
mapreduce.reduce.java.opts |
mapred.reduce.child.log.level |
mapreduce.reduce.log.level |
mapred.reduce.max.attempts |
mapreduce.reduce.maxattempts |
mapred.reduce.parallel.copies |
mapreduce.reduce.shuffle.parallelcopies |
mapred.reduce.slowstart.completed.maps |
mapreduce.job.reduce.slowstart.completedmaps |
mapred.reduce.task.debug.script |
mapreduce.reduce.debug.script |
mapred.reduce.tasks |
mapreduce.job.reduces |
mapred.reduce.tasks.speculative.execution |
mapreduce.reduce.speculative |
mapred.seqbinary.output.key.class |
mapreduce.output.seqbinaryoutputformat.key.class |
mapred.seqbinary.output.value.class |
mapreduce.output.seqbinaryoutputformat.value.class |
mapred.shuffle.connect.timeout |
mapreduce.reduce.shuffle.connect.timeout |
mapred.shuffle.read.timeout |
mapreduce.reduce.shuffle.read.timeout |
mapred.skip.attempts.to.start.skipping |
mapreduce.task.skip.start.attempts |
mapred.skip.map.auto.incr.proc.count |
mapreduce.map.skip.proc-count.auto-incr |
mapred.skip.map.max.skip.records |
mapreduce.map.skip.maxrecords |
mapred.skip.on |
mapreduce.job.skiprecords |
mapred.skip.out.dir |
mapreduce.job.skip.outdir |
mapred.skip.reduce.auto.incr.proc.count |
mapreduce.reduce.skip.proc-count.auto-incr |
mapred.skip.reduce.max.skip.groups |
mapreduce.reduce.skip.maxgroups |
mapred.speculative.execution.slowNodeThreshold |
mapreduce.job.speculative.slownodethreshold |
mapred.speculative.execution.slowTaskThreshold |
mapreduce.job.speculative.slowtaskthreshold |
mapred.speculative.execution.speculativeCap |
mapreduce.job.speculative.speculativecap |
mapred.submit.replication |
mapreduce.client.submit.file.replication |
mapred.system.dir |
mapreduce.jobtracker.system.dir |
mapred.task.cache.levels |
mapreduce.jobtracker.taskcache.levels |
mapred.task.id |
mapreduce.task.attempt.id |
mapred.task.is.map |
mapreduce.task.ismap |
mapred.task.partition |
mapreduce.task.partition |
mapred.task.profile |
mapreduce.task.profile |
mapred.task.profile.maps |
mapreduce.task.profile.maps |
mapred.task.profile.params |
mapreduce.task.profile.params |
mapred.task.profile.reduces |
mapreduce.task.profile.reduces |
mapred.task.timeout |
mapreduce.task.timeout |
mapred.tasktracker.dns.interface |
mapreduce.tasktracker.dns.interface |
mapred.tasktracker.dns.nameserver |
mapreduce.tasktracker.dns.nameserver |
mapred.tasktracker.events.batchsize |
mapreduce.tasktracker.events.batchsize |
mapred.tasktracker.expiry.interval |
mapreduce.jobtracker.expire.trackers.interval |
mapred.task.tracker.http.address |
mapreduce.tasktracker.http.address |
mapred.tasktracker.indexcache.mb |
mapreduce.tasktracker.indexcache.mb |
mapred.tasktracker.instrumentation |
mapreduce.tasktracker.instrumentation |
mapred.tasktracker.map.tasks.maximum |
mapreduce.tasktracker.map.tasks.maximum |
mapred.tasktracker.memory_calculator_plugin |
mapreduce.tasktracker.resourcecalculatorplugin |
mapred.tasktracker.memorycalculatorplugin |
mapreduce.tasktracker.resourcecalculatorplugin |
mapred.tasktracker.reduce.tasks.maximum |
mapreduce.tasktracker.reduce.tasks.maximum |
mapred.task.tracker.report.address |
mapreduce.tasktracker.report.address |
mapred.task.tracker.task-controller |
mapreduce.tasktracker.taskcontroller |
mapred.tasktracker.tasks.sleeptime-before-sigkill |
mapreduce.tasktracker.tasks.sleeptimebeforesigkill |
mapred.temp.dir |
mapreduce.cluster.temp.dir |
mapred.text.key.comparator.options |
mapreduce.partition.keycomparator.options |
mapred.text.key.partitioner.options |
mapreduce.partition.keypartitioner.options |
mapred.textoutputformat.separator |
mapreduce.output.textoutputformat.separator |
mapred.tip.id |
mapreduce.task.id |
mapreduce.combine.class |
mapreduce.job.combine.class |
mapreduce.inputformat.class |
mapreduce.job.inputformat.class |
mapreduce.job.counters.limit |
mapreduce.job.counters.max |
mapreduce.jobtracker.permissions.supergroup |
mapreduce.cluster.permissions.supergroup |
mapreduce.map.class |
mapreduce.job.map.class |
mapreduce.outputformat.class |
mapreduce.job.outputformat.class |
mapreduce.partitioner.class |
mapreduce.job.partitioner.class |
mapreduce.reduce.class |
mapreduce.job.reduce.class |
mapred.used.genericoptionsparser |
mapreduce.client.genericoptionsparser.used |
mapred.userlog.limit.kb |
mapreduce.task.userlog.limit.kb |
mapred.userlog.retain.hours |
mapreduce.job.userlog.retain.hours |
mapred.working.dir |
mapreduce.job.working.dir |
mapred.work.output.dir |
mapreduce.task.output.dir |
min.num.spills.for.combine |
mapreduce.map.combine.minspills |
reduce.output.key.value.fields.spec |
mapreduce.fieldsel.reduce.output.key.value.fields.spec |
security.job.submission.protocol.acl |
security.job.client.protocol.acl |
security.task.umbilical.protocol.acl |
security.job.task.protocol.acl |
sequencefile.filter.class |
mapreduce.input.sequencefileinputfilter.class |
sequencefile.filter.frequency |
mapreduce.input.sequencefileinputfilter.frequency |
sequencefile.filter.regex |
mapreduce.input.sequencefileinputfilter.regex |
session.id |
dfs.metrics.session-id |
slave.host.name |
dfs.datanode.hostname |
slave.host.name |
mapreduce.tasktracker.host.name |
tasktracker.contention.tracking |
mapreduce.tasktracker.contention.tracking |
tasktracker.http.threads |
mapreduce.tasktracker.http.threads |
topology.node.switch.mapping.impl |
net.topology.node.switch.mapping.impl |
topology.script.file.name |
net.topology.script.file.name |
topology.script.number.args |
net.topology.script.number.args |
user.name |
mapreduce.job.user.name |
webinterface.private.actions |
mapreduce.jobtracker.webinterface.trusted |
yarn.app.mapreduce.yarn.app.mapreduce.client-am.ipc.max-retries-on-timeouts |
yarn.app.mapreduce.client-am.ipc.max-retries-on-timeouts |
yarn.client.app-submission.poll-interval |
yarn.client.application-client-protocol.poll-timeout-ms |