Hadoop常用配置总结

Hadoop守护进程日志存放目录:可以用环境变量${Hadoop_LOG_DIR}进行配置,默认情况下是${HADOOP_HOME}/logs

1.配置类型节点的环境变量

在配置集群的时候可以在conf/hadoop-env.sh配置不同节点的环境变量:

Daemon

Configure Options

NameNode

HADOOP_NAMENODE_OPTS

DataNode

HADOOP_DATANODE_OPTS

SecondaryNamenode

HADOOP_SECONDARYNAMENODE_OPTS

JobTracker

HADOOP_JOBTRACKER_OPTS

TaskTracker

HADOOP_TASKTRACKER_OPTS

例如,可以在hadoop-env.sh中加入下面一行,使NameNode使用ParallelGC

export HADOOP_NAMENODE_OPTS="-XX:+UseParallelGC ${HADOOP_NAMENODE_OPTS}" 

还可以通过conf/hadoop-env.sh配置以下选项:

HADOOP_LOG_DIR:配置hadoop后台进程日志存放的目录

HADOOP_HEAPSIZE:此选项可以可以配置hadoop后台进程可使用栈的大小,默认大小为1000M

2. 配置Hadoop守护进程
conf/core-site.xml:通过该配置文件配置文件系统根目录,即hdfs://namenode

Parameter

Value

Notes

fs.default.name

URI of NameNode.

hdfs://hostname/

conf/hdfs-site.xml:通过该配置文件,配置NameNodeDataNode数据文件的存放目录

Parameter

Value

Notes

dfs.name.dir

NameNode上存放命名空间和日志的本地目录,即fsimageedits文件的存放目录

如果该配置有由逗号分开的多条目录,那么NameNode会在每条目录中进行冗余存储

dfs.data.dir

DataNode中存放block的目录

如果是由逗号分开的多条目录,则所有的目录都用来存储数据

conf/mapred-site.xml:可以通过这个文件配置MapReduce框架

Parameter

Value

Notes

mapred.job.tracker

JobTrackerIP和端口

host:portpair.

mapred.system.dir

Path on the HDFS where where the MapReduce framework stores system files e.g. /hadoop/mapred/system/.

This is in the default filesystem (HDFS) and must be accessible from both the server and client machines.

mapred.local.dir

Comma-separated list of paths on the local filesystem where temporary MapReduce data is written.

Multiple paths help spread disk i/o.

mapred.tasktracker.{map|reduce}.tasks.maximum

The maximum number of MapReduce tasks, which are run simultaneously on a given TaskTracker, individually.

Defaults to 2 (2 maps and 2 reduces), but vary it depending on your hardware.

dfs.hosts/dfs.hosts.exclude

List of permitted/excluded DataNodes.

If necessary, use these files to control the list of allowable datanodes.

mapred.hosts/mapred.hosts.exclude

List of permitted/excluded TaskTrackers.

If necessary, use these files to control the list of allowable TaskTrackers.

mapred.queue.names

Comma separated list of queues to which jobs can be submitted.

The MapReduce system always supports atleast one queue with the name as default. Hence, this parameter's value should always contain the string default. Some job schedulers supported in Hadoop, like the Capacity Scheduler, support multiple queues. If such a scheduler is being used, the list of configured queue names must be specified here. Once queues are defined, users can submit jobs to a queue using the property name mapred.job.queue.name in the job configuration. There could be a separate configuration file for configuring properties of these queues that is managed by the scheduler. Refer to the documentation of the scheduler for information on the same.

mapred.acls.enabled

Boolean, specifying whether checks for queue ACLs and job ACLs are to be done for authorizing users for doing queue operations and job operations.

If true, queue ACLs are checked while submitting and administering jobs and job ACLs are checked for authorizing view and modification of jobs. Queue ACLs are specified using the configuration parameters of the form mapred.queue.queue-name.acl-name, defined below under mapred-queue-acls.xml. Job ACLs are described at Job Authorization

mapred.task.timeout

Map/reduce task多长时间没有返回就认为他是失败的

一般为10分钟

mapred.map.max.attemptes

如果一个map任务失败,最多可以重新调度的次数

一般为4

mapred.reduce.max.attempts

如果一个reduce任务失败,最多可以重新调度的次数

一般为4

mapred.max.map.failures.percent

一个作业可以允许的map任务失败的比率

有时候我们认为,一个作业即使有一部分任务失败但作业其他任务执行也是有用的,该参数设置一个作业可以允许最多可以承受多少map任务失败

mapred.max.reduce.failures.percent

同上,针对reduce任务

同上,针对reduce任务

mapred.tasktracker.expiry.interval

Tasktracker多长时间没有向JobTracker发送心跳就认为tasktracker失败

默认为10分钟

mapred.user.jobconf.limit

Hadoop能够接受的最多job数量

mapred.tasktracker.map.tasks.maximum

每一个tasktracker能够同时执行的map的个数

默认为2

mapred.tasktracker.reduce.tasks.maximum

每一个tasktracker能够同时执行的reduce的个数

默认为2

下面是Hadoop项目在做一些项目时,对他们的集群所做的配置,在实际工作过程中我们也可以进行参考。

This section lists some non-default configuration parameters which have been used to run the sort benchmark on very large clusters.

l Some non-default configuration values used to run sort900, that is 9TB of data sorted on a cluster with 900 nodes:

Configuration File

Parameter

Value

Notes

conf/hdfs-site.xml

dfs.block.size

134217728

HDFS blocksize of 128MB for large file-systems.

conf/hdfs-site.xml

dfs.namenode.handler.count

40

More NameNode server threads to handle RPCs from large number of DataNodes.

conf/mapred-site.xml

mapred.reduce.parallel.copies

20

Higher number of parallel copies run by reduces to fetch outputs from very large number of maps.

conf/mapred-site.xml

mapred.map.child.java.opts

-Xmx512M

Larger heap-size for child jvms of maps.

conf/mapred-site.xml

mapred.reduce.child.java.opts

-Xmx512M

Larger heap-size for child jvms of reduces.

conf/core-site.xml

fs.inmemory.size.mb

200

Larger amount of memory allocated for the in-memory file-system used to merge map-outputs at the reduces.

conf/core-site.xml

io.sort.factor

100

More streams merged at once while sorting files.

conf/core-site.xml

io.sort.mb

200

Higher memory-limit while sorting data.

conf/core-site.xml

io.file.buffer.size

131072

Size of read/write buffer used in SequenceFiles.

l Updates to some configuration values to run sort1400 and sort2000, that is 14TB of data sorted on 1400 nodes and 20TB of data sorted on 2000 nodes:

Configuration File

Parameter

Value

Notes

conf/mapred-site.xml

mapred.job.tracker.handler.count

60

More JobTracker server threads to handle RPCs from large number of TaskTrackers.

conf/mapred-site.xml

mapred.reduce.parallel.copies

50

conf/mapred-site.xml

tasktracker.http.threads

50

More worker threads for the TaskTracker's http server. The http server is used by reduces to fetch intermediate map-outputs.

conf/mapred-site.xml

mapred.map.child.java.opts

-Xmx512M

Larger heap-size for child jvms of maps.

conf/mapred-site.xml

mapred.reduce.child.java.opts

-Xmx1024M

Larger heap-size for child jvms of reduces.

3. 内存监控

TaskTracker可以通过配置监控task使用内存的情况,通过监控可以防止task由于过度使用内存而导致系统崩溃。通过启用内存监控,可以给每一个task设置一个虚拟内存(virtual memory)使用限值;同时,可以给TaskTracker的虚拟内存使用设置一个限值,防止TaskTracker的虚拟内存被过度使用。如果内存使用超过TaskTracker的使用限值,那么一个或者多个task以及其子进程将被杀死。

Name

Type

Description

mapred.tasktracker.vmem.reserved

long

一个long类型的数字,单位是bytetasktracker虚拟内存的大小减去该数字为该hadoop能够使用该机器虚拟内存的上限

mapred.task.default.maxvmem

long

一个long类型的数字,单位是byte,表示tasktracker一个task能够使用虚拟内存的上限

mapred.task.limit.maxvmem

long

一个long类型的数字,单位是byte,表示tasktracker一个task能够使用虚拟内存的上限。当用户指定一个task可以使用虚拟内存的上限时不应该超过此值

Name

Type

Description

mapred.tasktracker.taskmemorymanager.monitoring-interval

long

TaskTracker监控内存使用情况的时间间隔,单位是毫秒。默认值是5000毫秒,即五秒钟。

内存监控是如何工作的:

1.如果一个或者多个上述属性没有被配置或者配置为-1,那么内存监控是被禁用的

2.如果mapred.task.default.maxvmem大于mapred.task.limit.maxvmem那么内存监控将被禁用,因为此时每一个task默认虚拟内存的大小总是大于用户设定的每个task可以使用内存的上限

3.如果TaskTracker接收到一个task,他的内存使用限值大于mapred.task.limit.maxvmemtask仍然被执行,但是将会在log记录警告

4.TaskTrack会周期性的进行如下检查:

v 如果一个task的虚拟内存使用超过了task虚拟内存使用限值,该task将被kill,并且会将原因记录到日志当中。该task同时被记录为失败(fail)

v 如果所有task使用虚拟内存的总和超过了tasktracker虚拟内存的上限,那么tasktrackerkill足够多的task,知道虚拟内存的使用小于限值。

Name

Type

Description

mapred.tasktracker.pmem.reserved

int

Int类型的数字,单位是byteTaskTracker物理内存的大小减去该值即为该TaskTracker可以使用的物理内存的上限。

4. 集群重启

如果mapred.jobtracker.restart.recover被设置成true,同时JobHistory logging被启用,那么当JobTracker重启时正在被执行的作业能够被恢复。

Job history files被存储在hadoop.job.history.location配置的路径当中,其默认值是${HADOOP_LOG_DIR}/history。同时这些文件还被保存到hadoop.job.history.user.location所配置的文件夹中,默认值是Job的输出路径/_logs/history/。同时我们可以通过设置mapred.jobtracker.job.history.block.size来控制Job history保存到硬盘的频率,该值的默认大小是3145728(3MB)

我们可以通过命令hadoop job -history output-dir或者

hadoop job -history all output-dir来查看Job history文件

5. Secondary NameNode

 Fs.checkpoint.period:secondary NameNode合并fsimageeidts的频率,默认为一个小时

Fs.checkpoint.size:edit文件超过多大时,secondary NameNode就合并fsimageedit文件,默认为64M

6. CheckPoint Node

NameNode通过fsimage保存其命名空间,fsimage也是命名空间的最近检查点。NameNode通过edits来保存相对于该检查点对HDFS做的修改。每当NameNode启动后,其将edits对文件系统的修改作用于fsimage,生成一个全新的检查点。Checkpoint node 周期性生成新的检查点。他从NameNode上下载fsimageedits,将其合并后更新到NameNode

Fs.checkpoint.period:checkpoint node合并fsimageeidts的频率,默认为一个小时

Fs.checkpoint.size:edits文件超过多大时,checkpoint node就合并fsimageedit文件,默认为64M

dfs.backup.address:checkpoint node的地址

dfs.backup.http.address:checkpoint nodewebUI

Checkpoint node启动,通过bin/hdfs namenode -checkpoint命令启动。

7. Backup Node

Backup Node的功能跟Secondary NameNodeCheckPoint Node的功能相似,其不同的地方是他不需要周期性的下载fsimageedits文件,因为其内存和NameNode的内存是一致的。Backup Node的配置与Check Point Node的配置方法一样。

8. Safemode

NameNode启动的时候,NameNode会将editsfsimage进行合并以便生成新的checkpoint。在完成这些工作后,NameNode等待DataNode汇报其保存的block。如果NameNode接收到的汇报比较少,那么很多Block就不知道保存到什么地方,只有接收到足够多的Block汇报后整个文件系统才是可以使用的。在等待DataNode汇报Block过程中称之为Safemode。可以通过命令:

Hadoop dfsadmin -safeMode来查看文件是不是已经脱离了safemode

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值