hadoop集羣設置
- 目的
- 先決條件
- 安裝
- 非安全模式下配置hadoop
- 配置hadoop進程的環境
- 配置hadoop進程
- 監控NodeManager的健康
- DataNode文件
- hadoop支架感受
- 日誌
- 操做hadoop集羣
- 集羣啓動
- 集羣關閉
- Web界面
This document describes how to install and configure Hadoop clusters ranging from a few nodes to extremely large clusters with thousands of nodes. To play with Hadoop, you may first want to install it on a single machine (see Single Node Setup).html
This document does not cover advanced topics such as Security or High Availability.java
目的
該文檔描述瞭如何安裝和配置從幾個到很是多的節點的hadoop集羣。爲了使用hadoop,你應該首先想在一臺機器上安裝它,請參考(上一篇)node
This document does not cover advanced topics such as Security or High Availability.web
這個文檔不涉及高級話題,好比安全Security 和高可用shell
先決條件
- 安裝java,查看Hadoop Wiki查看合適的版本
- 從apache鏡像中下載一個穩定的版本
Installing a Hadoop cluster typically involves unpacking the software on all the machines in the cluster or installing it via a packaging system as appropriate for your operating system. It is important to divide up the hardware into functions.apache
Typically one machine in the cluster is designated as the NameNode and another machine as the ResourceManager, exclusively. These are the masters. Other services (such as Web App Proxy Server and MapReduce Job History server) are usually run either on dedicated hardware or on shared infrastructure, depending upon the load.安全
The rest of the machines in the cluster act as both DataNode and NodeManager. These are the workers.服務器
安裝
安裝hadoop機器一般是在集羣中的全部機器上解壓軟件,或者是適合你操做系統的打包系統。按功能區區分硬件是很重要的。網絡
一般狀況下集羣中的一臺機器被指定爲NameNode,別的機器被指定爲ResourceManager,這些屬於「主人」。別的服務(好比WEB App Proxy Server或者MapReduce job History server)一般專一與一臺硬件或者是共享設備,這些取決於負載。app
The rest of the machines in the cluster act as both DataNode and NodeManager. These are the workers.
集羣中其他的集羣做爲DataNode和NodeManager.他們是「工人」。
Hadoop’s Java configuration is driven by two types of important configuration files:
Read-only default configuration - core-default.xml, hdfs-default.xml, yarn-default.xml and mapred-default.xml.
Site-specific configuration - etc/hadoop/core-site.xml, etc/hadoop/hdfs-site.xml, etc/hadoop/yarn-site.xml and etc/hadoop/mapred-site.xml.
Additionally, you can control the Hadoop scripts found in the bin/ directory of the distribution, by setting site-specific values via the etc/hadoop/hadoop-env.sh and etc/hadoop/yarn-env.sh.
To configure the Hadoop cluster you will need to configure the environment in which the Hadoop daemons execute as well as the configuration parameters for the Hadoop daemons.
HDFS daemons are NameNode, SecondaryNameNode, and DataNode. YARN daemons are ResourceManager, NodeManager, and WebAppProxy. If MapReduce is to be used, then the MapReduce Job History Server will also be running. For large installations, these are generally running on separate hosts.
在非安全模式下配置hadoop
hadoop的Java配置注意是由兩個重要的配置文件:
- 只讀配置 core-default.xml, hdfs-default.xml, yarn-default.xml and mapred-default.xml.
- 特定的配置文件- etc/hadoop/core-site.xml, etc/hadoop/hdfs-site.xml, etc/hadoop/yarn-site.xml 和etc/hadoop/mapred-site.xml.
除此以外,你能夠經過設置etc/hadoop-env.sh和etc/hadoop/yarn-env.sh中的特定值來控制bin目錄下hadoop腳本。
爲了設置hadoop集羣你須要設置hadoop進程執行的機器的環境和hadoop進程的參數。
HDFS的進程有NameNode SecondaryNameNode DataNode.YARN進程有ResourceManager NodeManager WebAppProxy.若是使用了MapReduce那麼MapReduce job History服務也會運行。節點多的話,這些一般在單獨的機器上運行。
Administrators should use the etc/hadoop/hadoop-env.sh and optionally the etc/hadoop/mapred-env.sh and etc/hadoop/yarn-env.sh scripts to do site-specific customization of the Hadoop daemons’ process environment.
At the very least, you must specify the JAVA_HOME so that it is correctly defined on each remote node.
Administrators can configure individual daemons using the configuration options shown below in the table:
Daemon | Environment Variable |
---|---|
NameNode | HDFS_NAMENODE_OPTS |
DataNode | HDFS_DATANODE_OPTS |
Secondary NameNode | HDFS_SECONDARYNAMENODE_OPTS |
ResourceManager | YARN_RESOURCEMANAGER_OPTS |
NodeManager | YARN_NODEMANAGER_OPTS |
WebAppProxy | YARN_PROXYSERVER_OPTS |
Map Reduce Job History Server | MAPRED_HISTORYSERVER_OPTS |
For example, To configure Namenode to use parallelGC and a 4GB Java Heap, the following statement should be added in hadoop-env.sh :
export HDFS_NAMENODE_OPTS="-XX:+UseParallelGC -Xmx4g"
See etc/hadoop/hadoop-env.sh for other examples.
Other useful configuration parameters that you can customize include:
In most cases, you should specify the HADOOP_PID_DIR and HADOOP_LOG_DIR directories such that they can only be written to by the users that are going to run the hadoop daemons. Otherwise there is the potential for a symlink attack.
It is also traditional to configure HADOOP_HOME in the system-wide shell environment configuration. For example, a simple script inside /etc/profile.d:
HADOOP_HOME=/path/to/hadoop export HADOOP_HOME
配置hadoop進程的環境
管理員應該使用etc/hadoop/hadoop-env.sh 或者etc/hadoop/mapred-env.sh 和etc/hadoop/yarn-env.sh去定製hadoop進程的運行環境。
至少,你必須指定JAVA_HOME在每個遠程節點上正確的定義了。
管理員可使用下表中的參數選項配置每一個進程:
Daemon Environment Variable NameNode HDFS_NAMENODE_OPTS DataNode HDFS_DATANODE_OPTS Secondary NameNode HDFS_SECONDARYNAMENODE_OPTS ResourceManager YARN_RESOURCEMANAGER_OPTS NodeManager YARN_NODEMANAGER_OPTS WebAppProxy YARN_PROXYSERVER_OPTS Map Reduce Job History Server MAPRED_HISTORYSERVER_OPTS 例如,爲了指定NameNode使用parallelGC和4GB的Java內存,以下命令須要加入到hadoop-env.sh文件。
export HDFS_NAMENODE_OPTS="-XX:+UseParallelGC -Xmx4g"
查看etc/hadoop/hadoop-env.sh 得到別的示例.你能夠定製的有用的配置參數包括:
- HADOOP_PID_DIR - 進程ID文件存儲的目錄
- HADOOP_LOG_DIR - 進程日誌文件存儲的路徑,若是日誌文件不存在的話他們將會自動建立。
- HADOOP_HEAPSIZE_MAX - Java進程使用的最大內存值,JVM的單位值在這裏一樣有效。若是當前麼有單位值,將會假設他以兆爲單位。默認狀況下,hadoop將由JVM決定如何使用。這個值能夠由單一進程上述列出的正確的_OPTS參數值覆蓋。例如:
- setting HADOOP_HEAPSIZE_MAX=1g and HADOOP_NAMENODE_OPTS="-Xmx5g" will configure the NameNode with 5GB heap.
- 設置HADOOP_HEADSIZE_MAX=1g和HADOOP_NAMENODE_OPTS="-Xmx5g"將會設置NameNode爲5G內存
在大部分狀況下,你應該直到HADOOP_PID_DIR和HADOOP_LOG_DIR目錄,這些目錄只能由運行hadoop進程的用戶去建立,不然的話將會有符號連接的攻擊。
It is also traditional to configure HADOOP_HOME in the system-wide shell environment configuration. For example, a simple script inside /etc/profile.d:
一般也會在系統全局變量中配置HADOOP_HOME,例如在/etc/profile.d腳本中
HADOOP_HOME=/path/to/hadoop export HADOOP_HOME
This section deals with important parameters to be specified in the given configuration files:
Parameter | Value | Notes |
---|---|---|
fs.defaultFS | NameNode URI | hdfs://host:port/ |
io.file.buffer.size | 131072 | Size of read/write buffer used in SequenceFiles. |
etc/hadoop/hdfs-site.xml
Configurations for NameNode:
Parameter | Value | Notes |
---|---|---|
dfs.namenode.name.dir | Path on the local filesystem where the NameNode stores the namespace and transactions logs persistently. | If this is a comma-delimited list of directories then the name table is replicated in all of the directories, for redundancy. |
dfs.hosts / dfs.hosts.exclude | List of permitted/excluded DataNodes. | If necessary, use these files to control the list of allowable datanodes. |
dfs.blocksize | 268435456 | HDFS blocksize of 256MB for large file-systems. |
dfs.namenode.handler.count | 100 | More NameNode server threads to handle RPCs from large number of DataNodes. |
Parameter | Value | Notes |
---|---|---|
dfs.datanode.data.dir | Comma separated list of paths on the local filesystem of a DataNode where it should store its blocks. | If this is a comma-delimited list of directories, then data will be stored in all named directories, typically on different devices. |
etc/hadoop/yarn-site.xml
Configurations for ResourceManager and NodeManager:
Parameter | Value | Notes |
---|---|---|
yarn.acl.enable | true / false | Enable ACLs? Defaults to false. |
yarn.admin.acl | Admin ACL | ACL to set admins on the cluster. ACLs are of for comma-separated-usersspacecomma-separated-groups. Defaults to special value of * which means anyone. Special value of just space means no one has access. |
yarn.log-aggregation-enable | false | Configuration to enable or disable log aggregation |
Parameter | Value | Notes |
---|---|---|
yarn.resourcemanager.address | ResourceManager host:port for clients to submit jobs. | host:port If set, overrides the hostname set in yarn.resourcemanager.hostname. |
yarn.resourcemanager.scheduler.address | ResourceManager host:port for ApplicationMasters to talk to Scheduler to obtain resources. | host:port If set, overrides the hostname set in yarn.resourcemanager.hostname. |
yarn.resourcemanager.resource-tracker.address | ResourceManager host:port for NodeManagers. | host:port If set, overrides the hostname set in yarn.resourcemanager.hostname. |
yarn.resourcemanager.admin.address | ResourceManager host:port for administrative commands. | host:port If set, overrides the hostname set in yarn.resourcemanager.hostname. |
yarn.resourcemanager.webapp.address | ResourceManager web-ui host:port. | host:port If set, overrides the hostname set in yarn.resourcemanager.hostname. |
yarn.resourcemanager.hostname | ResourceManager host. | host Single hostname that can be set in place of setting all yarn.resourcemanager*address resources. Results in default ports for ResourceManager components. |
yarn.resourcemanager.scheduler.class | ResourceManager Scheduler class. | CapacityScheduler (recommended), FairScheduler (also recommended), or FifoScheduler. Use a fully qualified class name, e.g., org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler. |
yarn.scheduler.minimum-allocation-mb | Minimum limit of memory to allocate to each container request at the Resource Manager. | In MBs |
yarn.scheduler.maximum-allocation-mb | Maximum limit of memory to allocate to each container request at the Resource Manager. | In MBs |
yarn.resourcemanager.nodes.include-path / yarn.resourcemanager.nodes.exclude-path | List of permitted/excluded NodeManagers. | If necessary, use these files to control the list of allowable NodeManagers. |
Parameter | Value | Notes |
---|---|---|
yarn.nodemanager.resource.memory-mb | Resource i.e. available physical memory, in MB, for given NodeManager | Defines total available resources on the NodeManager to be made available to running containers |
yarn.nodemanager.vmem-pmem-ratio | Maximum ratio by which virtual memory usage of tasks may exceed physical memory | The virtual memory usage of each task may exceed its physical memory limit by this ratio. The total amount of virtual memory used by tasks on the NodeManager may exceed its physical memory usage by this ratio. |
yarn.nodemanager.local-dirs | Comma-separated list of paths on the local filesystem where intermediate data is written. | Multiple paths help spread disk i/o. |
yarn.nodemanager.log-dirs | Comma-separated list of paths on the local filesystem where logs are written. | Multiple paths help spread disk i/o. |
yarn.nodemanager.log.retain-seconds | 10800 | Default time (in seconds) to retain log files on the NodeManager Only applicable if log-aggregation is disabled. |
yarn.nodemanager.remote-app-log-dir | /logs | HDFS directory where the application logs are moved on application completion. Need to set appropriate permissions. Only applicable if log-aggregation is enabled. |
yarn.nodemanager.remote-app-log-dir-suffix | logs | Suffix appended to the remote log dir. Logs will be aggregated to ${yarn.nodemanager.remote-app-log-dir}/${user}/${thisParam} Only applicable if log-aggregation is enabled. |
yarn.nodemanager.aux-services | mapreduce_shuffle | Shuffle service that needs to be set for Map Reduce applications. |
yarn.nodemanager.env-whitelist | Environment properties to be inherited by containers from NodeManagers | For mapreduce application in addition to the default values HADOOP_MAPRED_HOME should to be added. Property value should JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_MAPRED_HOME |
Parameter | Value | Notes |
---|---|---|
yarn.log-aggregation.retain-seconds | -1 | How long to keep aggregation logs before deleting them. -1 disables. Be careful, set this too small and you will spam the name node. |
yarn.log-aggregation.retain-check-interval-seconds | -1 | Time between checks for aggregated log retention. If set to 0 or a negative value then the value is computed as one-tenth of the aggregated log retention time. Be careful, set this too small and you will spam the name node. |
etc/hadoop/mapred-site.xml
Configurations for MapReduce Applications:
Parameter | Value | Notes |
---|---|---|
mapreduce.framework.name | yarn | Execution framework set to Hadoop YARN. |
mapreduce.map.memory.mb | 1536 | Larger resource limit for maps. |
mapreduce.map.java.opts | -Xmx1024M | Larger heap-size for child jvms of maps. |
mapreduce.reduce.memory.mb | 3072 | Larger resource limit for reduces. |
mapreduce.reduce.java.opts | -Xmx2560M | Larger heap-size for child jvms of reduces. |
mapreduce.task.io.sort.mb | 512 | Higher memory-limit while sorting data for efficiency. |
mapreduce.task.io.sort.factor | 100 | More streams merged at once while sorting files. |
mapreduce.reduce.shuffle.parallelcopies | 50 | Higher number of parallel copies run by reduces to fetch outputs from very large number of maps. |
Parameter | Value | Notes |
---|---|---|
mapreduce.jobhistory.address | MapReduce JobHistory Server host:port | Default port is 10020. |
mapreduce.jobhistory.webapp.address | MapReduce JobHistory Server Web UI host:port | Default port is 19888. |
mapreduce.jobhistory.intermediate-done-dir | /mr-history/tmp | Directory where history files are written by MapReduce jobs. |
mapreduce.jobhistory.done-dir | /mr-history/done | Directory where history files are managed by the MR JobHistory Server. |
配置Hadoop進程
這一部分處理了已給定配置文件的重要的參數:
- etc/hadoop/core-site.xml
Parameter Value Notes fs.defaultFS NameNode URI hdfs://host:port/ io.file.buffer.size 131072 Size of read/write buffer used in SequenceFiles.
etc/hadoop/hdfs-site.xml
配置NameNode:
Parameter Value Notes dfs.namenode.name.dir Path on the local filesystem where the NameNode stores the namespace and transactions logs persistently. If this is a comma-delimited list of directories then the name table is replicated in all of the directories, for redundancy. dfs.hosts / dfs.hosts.exclude List of permitted/excluded DataNodes. If necessary, use these files to control the list of allowable datanodes. dfs.blocksize 268435456 HDFS blocksize of 256MB for large file-systems. dfs.namenode.handler.count 100 More NameNode server threads to handle RPCs from large number of DataNodes.
- 配置DataNode:
Parameter Value Notes dfs.datanode.data.dir Comma separated list of paths on the local filesystem of a DataNode where it should store its blocks. If this is a comma-delimited list of directories, then data will be stored in all named directories, typically on different devices.
etc/hadoop/yarn-site.xml
配置 ResourceManager 和odeManager:
Parameter Value Notes yarn.acl.enable true / false Enable ACLs? Defaults to false. yarn.admin.acl Admin ACL ACL to set admins on the cluster. ACLs are of for comma-separated-usersspacecomma-separated-groups. Defaults to special value of * which means anyone. Special value of just space means no one has access. yarn.log-aggregation-enable false Configuration to enable or disable log aggregation
- 配置 ResourceManager:
Parameter Value Notes yarn.resourcemanager.address ResourceManager host:port for clients to submit jobs. host:port If set, overrides the hostname set in yarn.resourcemanager.hostname. yarn.resourcemanager.scheduler.address ResourceManager host:port for ApplicationMasters to talk to Scheduler to obtain resources. host:port If set, overrides the hostname set in yarn.resourcemanager.hostname. yarn.resourcemanager.resource-tracker.address ResourceManager host:port for NodeManagers. host:port If set, overrides the hostname set in yarn.resourcemanager.hostname. yarn.resourcemanager.admin.address ResourceManager host:port for administrative commands. host:port If set, overrides the hostname set in yarn.resourcemanager.hostname. yarn.resourcemanager.webapp.address ResourceManager web-ui host:port. host:port If set, overrides the hostname set in yarn.resourcemanager.hostname. yarn.resourcemanager.hostname ResourceManager host. host Single hostname that can be set in place of setting all yarn.resourcemanager*address resources. Results in default ports for ResourceManager components. yarn.resourcemanager.scheduler.class ResourceManager Scheduler class. CapacityScheduler (recommended), FairScheduler (also recommended), or FifoScheduler. Use a fully qualified class name, e.g., org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler. yarn.scheduler.minimum-allocation-mb Minimum limit of memory to allocate to each container request at the Resource Manager. In MBs yarn.scheduler.maximum-allocation-mb Maximum limit of memory to allocate to each container request at the Resource Manager. In MBs yarn.resourcemanager.nodes.include-path / yarn.resourcemanager.nodes.exclude-path List of permitted/excluded NodeManagers. If necessary, use these files to control the list of allowable NodeManagers.
- 配置 NodeManager:
Parameter Value Notes yarn.nodemanager.resource.memory-mb Resource i.e. available physical memory, in MB, for given NodeManager Defines total available resources on the NodeManager to be made available to running containers yarn.nodemanager.vmem-pmem-ratio Maximum ratio by which virtual memory usage of tasks may exceed physical memory The virtual memory usage of each task may exceed its physical memory limit by this ratio. The total amount of virtual memory used by tasks on the NodeManager may exceed its physical memory usage by this ratio. yarn.nodemanager.local-dirs Comma-separated list of paths on the local filesystem where intermediate data is written. Multiple paths help spread disk i/o. yarn.nodemanager.log-dirs Comma-separated list of paths on the local filesystem where logs are written. Multiple paths help spread disk i/o. yarn.nodemanager.log.retain-seconds 10800 Default time (in seconds) to retain log files on the NodeManager Only applicable if log-aggregation is disabled. yarn.nodemanager.remote-app-log-dir /logs HDFS directory where the application logs are moved on application completion. Need to set appropriate permissions. Only applicable if log-aggregation is enabled. yarn.nodemanager.remote-app-log-dir-suffix logs Suffix appended to the remote log dir. Logs will be aggregated to ${yarn.nodemanager.remote-app-log-dir}/${user}/${thisParam} Only applicable if log-aggregation is enabled. yarn.nodemanager.aux-services mapreduce_shuffle Shuffle service that needs to be set for Map Reduce applications. yarn.nodemanager.env-whitelist Environment properties to be inherited by containers from NodeManagers For mapreduce application in addition to the default values HADOOP_MAPRED_HOME should to be added. Property value should JAVA_HOME,HADOOP_COMMON_HOME,HADOOP_HDFS_HOME,HADOOP_CONF_DIR,CLASSPATH_PREPEND_DISTCACHE,HADOOP_YARN_HOME,HADOOP_MAPRED_HOME
- 配置 History Server (Needs to be moved elsewhere):
Parameter Value Notes yarn.log-aggregation.retain-seconds -1 How long to keep aggregation logs before deleting them. -1 disables. Be careful, set this too small and you will spam the name node. yarn.log-aggregation.retain-check-interval-seconds -1 Time between checks for aggregated log retention. If set to 0 or a negative value then the value is computed as one-tenth of the aggregated log retention time. Be careful, set this too small and you will spam the name node.
etc/hadoop/mapred-site.xml
配置 MapReduce Applications:
Parameter Value Notes mapreduce.framework.name yarn Execution framework set to Hadoop YARN. mapreduce.map.memory.mb 1536 Larger resource limit for maps. mapreduce.map.java.opts -Xmx1024M Larger heap-size for child jvms of maps. mapreduce.reduce.memory.mb 3072 Larger resource limit for reduces. mapreduce.reduce.java.opts -Xmx2560M Larger heap-size for child jvms of reduces. mapreduce.task.io.sort.mb 512 Higher memory-limit while sorting data for efficiency. mapreduce.task.io.sort.factor 100 More streams merged at once while sorting files. mapreduce.reduce.shuffle.parallelcopies 50 Higher number of parallel copies run by reduces to fetch outputs from very large number of maps.
- 配置apReduce JobHistory Server:
Parameter Value Notes mapreduce.jobhistory.address MapReduce JobHistory Server host:port Default port is 10020. mapreduce.jobhistory.webapp.address MapReduce JobHistory Server Web UI host:port Default port is 19888. mapreduce.jobhistory.intermediate-done-dir /mr-history/tmp Directory where history files are written by MapReduce jobs. mapreduce.jobhistory.done-dir /mr-history/done Directory where history files are managed by the MR JobHistory Server.
Hadoop provides a mechanism by which administrators can configure the NodeManager to run an administrator supplied script periodically to determine if a node is healthy or not.
Administrators can determine if the node is in a healthy state by performing any checks of their choice in the script. If the script detects the node to be in an unhealthy state, it must print a line to standard output beginning with the string ERROR. The NodeManager spawns the script periodically and checks its output. If the script’s output contains the string ERROR, as described above, the node’s status is reported as unhealthy and the node is black-listed by the ResourceManager. No further tasks will be assigned to this node. However, the NodeManager continues to run the script, so that if the node becomes healthy again, it will be removed from the blacklisted nodes on the ResourceManager automatically. The node’s health along with the output of the script, if it is unhealthy, is available to the administrator in the ResourceManager web interface. The time since the node was healthy is also displayed on the web interface.
The following parameters can be used to control the node health monitoring script in etc/hadoop/yarn-site.xml.
Parameter | Value | Notes |
---|---|---|
yarn.nodemanager.health-checker.script.path | Node health script | Script to check for node’s health status. |
yarn.nodemanager.health-checker.script.opts | Node health script options | Options for script to check for node’s health status. |
yarn.nodemanager.health-checker.interval-ms | Node health script interval | Time interval for running health script. |
yarn.nodemanager.health-checker.script.timeout-ms | Node health script timeout interval | Timeout for health script execution. |
The health checker script is not supposed to give ERROR if only some of the local disks become bad. NodeManager has the ability to periodically check the health of the local disks (specifically checks nodemanager-local-dirs and nodemanager-log-dirs) and after reaching the threshold of number of bad directories based on the value set for the config property yarn.nodemanager.disk-health-checker.min-healthy-disks, the whole node is marked unhealthy and this info is sent to resource manager also. The boot disk is either raided or a failure in the boot disk is identified by the health checker script.
監控 NodeManagers的健康值
Hadoop提供了一種機制,經過這種機制管理員能夠配置NodeManager 週期性的去執行一個管理員提供的腳本去決定一個節點是否健康。
管理員能夠經過執行腳本中的一些檢查去決定一個節點是否處於健康狀態。若是腳本檢測到節點屬於非健康狀態,它必須在標準輸出臺上以ERROR開頭的一行日誌。NodeManager週期性的產生腳本而且檢查其輸出。若是腳本輸出中包含如上所描述的ERROR字符,該節點狀態將會報告爲不健康而且被ResourceManager列爲黑名單。將不會有新的任務分配到該節點上。然而,NodeManager會繼續執行腳本,以便若是該節點從新變爲健康狀態,它將會從ResourceManager的黑名單節點中自動移除。節點的健康狀態伴隨着腳本的輸出,若是它是非健康的,它在ResourceManager的web界面是可用的,從節點變爲健康開始它一樣會顯示在web界面。
在etc/hadoop/yarn-site.xml中的以下參數能夠用來控制節點健康監控:
Parameter Value Notes yarn.nodemanager.health-checker.script.path Node health script Script to check for node’s health status. yarn.nodemanager.health-checker.script.opts Node health script options Options for script to check for node’s health status. yarn.nodemanager.health-checker.interval-ms Node health script interval Time interval for running health script. yarn.nodemanager.health-checker.script.timeout-ms Node health script timeout interval Timeout for health script execution. 若是本地磁盤變壞的話健康檢測腳本將不會給出ERROR。NodeManager能夠週期性的檢測本地磁盤(尤爲是nodemanager-local-dirs和nodemanager-log-dirs)的健康情況,若是到了yarn.nodemanager.disk-health-check.min-healthy-disks的臨界值,所有的node被標記爲非健康,這一信息也會發送到ResourceManager.啓動盤被攻擊或者啓動盤的錯誤都會標記爲健康檢查腳本。
List all worker hostnames or IP addresses in your etc/hadoop/workers file, one per line. Helper scripts (described below) will use the etc/hadoop/workers file to run commands on many hosts at once. It is not used for any of the Java-based Hadoop configuration. In order to use this functionality, ssh trusts (via either passphraseless ssh or some other means, such as Kerberos) must be established for the accounts used to run Hadoop.
Slaves文件
在etc/hadoop/workers文件中列舉的全部的"worker"域名或IP地址信息,一行爲一個。幫助腳本將使用etc/hadoop/workers文件在每個主機上運行。它不使用任何基於Java的hadoop配置。爲了使用這個功能,必須爲運行Hadoop的帳戶設置SSH信任(經過免密或者別的方式好比Kerberos)。
Many Hadoop components are rack-aware and take advantage of the network topology for performance and safety. Hadoop daemons obtain the rack information of the workers in the cluster by invoking an administrator configured module. See the Rack Awareness documentation for more specific information.
It is highly recommended configuring rack awareness prior to starting HDFS.
Hadoop Rack Awareness Hadoop機架感知
許多Hadoop組件利用網絡拓撲學的性能和安全性是支持機架感應的。Hadoop進程經過使用管理員的配置模塊是包含集羣中「工人」的機架信息的。查看機架感應文檔( Rack Awareness)獲取更多特定的內容。
強烈建議在開始使用HDFS以前優先配置機架感應。
Hadoop uses the Apache log4j via the Apache Commons Logging framework for logging. Edit the etc/hadoop/log4j.properties file to customize the Hadoop daemons’ logging configuration (log-formats and so on).
日誌
Hadoop經過Apache Commons Logging 框架的Apache log4j(Apache log4j )記錄日誌。
編輯etc/hadoop/log4j.properties文件去定製Hadoop進程的日誌配置(日誌格式化等等)。
Once all the necessary configuration is complete, distribute the files to the HADOOP_CONF_DIR directory on all the machines. This should be the same directory on all machines.
In general, it is recommended that HDFS and YARN run as separate users. In the majority of installations, HDFS processes execute as ‘hdfs’. YARN is typically using the ‘yarn’ account.
操做hadoop集羣
一旦全部的必要的配置完成了,分發全部的文件到集羣中全部機器下的HADOOP_CONF_DIR文件夾下。這個文件夾應該在全部的機器上是同樣的。
一般狀況下。HDFS和YARN應該使用不一樣的用戶去運行。在大部分的配置下,HDFS以hdfs帳戶執行,YARN用yarn帳戶。
To start a Hadoop cluster you will need to start both the HDFS and YARN cluster.
The first time you bring up HDFS, it must be formatted. Format a new distributed filesystem as hdfs:
[hdfs]$ $HADOOP_HOME/bin/hdfs namenode -format <cluster_name>
Start the HDFS NameNode with the following command on the designated node as hdfs:
[hdfs]$ $HADOOP_HOME/bin/hdfs --daemon start namenode
Start a HDFS DataNode with the following command on each designated node as hdfs:
[hdfs]$ $HADOOP_HOME/bin/hdfs --daemon start datanode
If etc/hadoop/workers and ssh trusted access is configured (see Single Node Setup), all of the HDFS processes can be started with a utility script. As hdfs:
[hdfs]$ $HADOOP_HOME/sbin/start-dfs.sh
Start the YARN with the following command, run on the designated ResourceManager as yarn:
[yarn]$ $HADOOP_HOME/bin/yarn --daemon start resourcemanager
Run a script to start a NodeManager on each designated host as yarn:
[yarn]$ $HADOOP_HOME/bin/yarn --daemon start nodemanager
Start a standalone WebAppProxy server. Run on the WebAppProxy server as yarn. If multiple servers are used with load balancing it should be run on each of them:
[yarn]$ $HADOOP_HOME/bin/yarn --daemon start proxyserver
If etc/hadoop/workers and ssh trusted access is configured (see Single Node Setup), all of the YARN processes can be started with a utility script. As yarn:
[yarn]$ $HADOOP_HOME/sbin/start-yarn.sh
Start the MapReduce JobHistory Server with the following command, run on the designated server as mapred:
[mapred]$ $HADOOP_HOME/bin/mapred --daemon start historyserver
Hadoop 啓動
若是要啓動hadoop集羣的話你首先要同時啓動HDFS和YARN集羣。
第一次啓動HDFS的時候,必須進行格式化。將hdfs格式化爲一個新的分佈式文件系統:
[hdfs]$ $HADOOP_HOME/bin/hdfs namenode -format <cluster_name>在指定的節點上使用hdfs用戶執行以下的命令啓動NameNode
[hdfs]$ $HADOOP_HOME/bin/hdfs --daemon start namenode在指定的節點上使用hdfs用戶執行以下的命令啓動DataNode:
[hdfs]$ $HADOOP_HOME/bin/hdfs --daemon start datanode若是etc/hadoop/workers和ssh免密已經設置了的話(Single Node Setup),可使用一個有用的腳原本啓動HDFS全部的進程,
[hdfs]$ $HADOOP_HOME/sbin/start-dfs.sh在指定的ResourceManager節點上使用yarn用戶執行以下命令啓動YARN:
[yarn]$ $HADOOP_HOME/bin/yarn --daemon start resourcemanager在每個指定的主機上用yarn用戶執行腳本去啓動NodeManager:
[yarn]$ $HADOOP_HOME/bin/yarn --daemon start nodemanager啓動一個單獨的WebAppProxy服務。使用yarn用戶啓動WebAppProxy服務。若是有多個服務器用來作負載均衡的話應該在每一臺機器上面執行它:
[yarn]$ $HADOOP_HOME/bin/yarn --daemon start proxyserver若是etc/hadoop/workers和ssh免密都設置的話(Single Node Setup),全部的YARN進程可使用一個有效的腳本啓動,使用yarn用戶:
[yarn]$ $HADOOP_HOME/sbin/start-yarn.sh在指定的服務器上使用mapred用戶執行以下命令啓動MapReduce JobHistory服務:
[mapred]$ $HADOOP_HOME/bin/mapred --daemon start historyserver
Stop the NameNode with the following command, run on the designated NameNode as hdfs:
[hdfs]$ $HADOOP_HOME/bin/hdfs --daemon stop namenode
Run a script to stop a DataNode as hdfs:
[hdfs]$ $HADOOP_HOME/bin/hdfs --daemon stop datanode
If etc/hadoop/workers and ssh trusted access is configured (see Single Node Setup), all of the HDFS processes may be stopped with a utility script. As hdfs:
[hdfs]$ $HADOOP_HOME/sbin/stop-dfs.sh
Stop the ResourceManager with the following command, run on the designated ResourceManager as yarn:
[yarn]$ $HADOOP_HOME/bin/yarn --daemon stop resourcemanager
Run a script to stop a NodeManager on a worker as yarn:
[yarn]$ $HADOOP_HOME/bin/yarn --daemon stop nodemanager
If etc/hadoop/workers and ssh trusted access is configured (see Single Node Setup), all of the YARN processes can be stopped with a utility script. As yarn:
[yarn]$ $HADOOP_HOME/sbin/stop-yarn.sh
Stop the WebAppProxy server. Run on the WebAppProxy server as yarn. If multiple servers are used with load balancing it should be run on each of them:
[yarn]$ $HADOOP_HOME/bin/yarn stop proxyserver
Stop the MapReduce JobHistory Server with the following command, run on the designated server as mapred:
[mapred]$ $HADOOP_HOME/bin/mapred --daemon stop historyserver
Hadoop 關閉
使用hdfs用戶在指定的NameNode服務器上執行以下命令中止NameNode:
[hdfs]$ $HADOOP_HOME/bin/hdfs --daemon stop namenode使用hdfs用戶運行腳本中止DataNode:
[hdfs]$ $HADOOP_HOME/bin/hdfs --daemon stop datanode若是etc/hadoop/worker和ssh免密已經設置的話,全部的HDFS進行可使用一個有用的腳原本中止。使用hdfs用戶
[hdfs]$ $HADOOP_HOME/sbin/stop-dfs.sh在指定的ResourceManager機器上執行以下命令中止ResourceManager:
[yarn]$ $HADOOP_HOME/bin/yarn --daemon stop resourcemanager在workers機器上執行腳本中止NodeManager:
[yarn]$ $HADOOP_HOME/bin/yarn --daemon stop nodemanagerIf etc/hadoop/workers and ssh trusted access is configured (see Single Node Setup), all of the YARN processes can be stopped with a utility script. As yarn:
若是etc/hadoop/workers和ssh免密已經設置的話,全部的YARN進程可使用一個有效的腳本進行中止:
[yarn]$ $HADOOP_HOME/sbin/stop-yarn.sh使用yarn用戶在WebAppProxy服務器上執行以下命令中止WebAppProxy服務,若是多個服務器用於作負載均衡,應該在每一臺機器上執行他們:
[yarn]$ $HADOOP_HOME/bin/yarn stop proxyserverStop the MapReduce JobHistory Server with the following command, run on the designated server as mapred:
使用mapred用戶在指定的服務器上執行以下命令挺屍MapReduce JobHistory服務。
[mapred]$ $HADOOP_HOME/bin/mapred --daemon stop historyserver
Once the Hadoop cluster is up and running check the web-ui of the components as described below:
Daemon | Web Interface | Notes |
---|---|---|
NameNode | http://nn_host:port/ | Default HTTP port is 9870. |
ResourceManager | http://rm_host:port/ | Default HTTP port is 8088. |
MapReduce JobHistory Server | http://jhs_host:port/ | Default HTTP port is 19888. |
Web 界面
一旦Hadoop集羣已經啓動而且運行,使用以下的描述來檢查組件的的web界面:
Daemon Web Interface Notes NameNode http://nn_host:port/ Default HTTP port is 9870. ResourceManager http://rm_host:port/ Default HTTP port is 8088. MapReduce JobHistory Server http://jhs_host:port/ Default HTTP port is 19888.