hadoop配置(5) --启动YARN
新版的 Hadoop 使用了新的 MapReduce 框架(MapReduce V2,也称为 YARN,Yet Another Resource Negotiator)。
YARN 是从 MapReduce 中分离出来的,负责资源管理与任务调度。YARN 运行于 MapReduce 之上,提供了高可用性、高扩展性。
上述通过 ./sbin/start-dfs.sh
启动 Hadoop,仅仅是启动了 MapReduce 环境,我们可以启动 YARN ,让 YARN 来负责资源管理与任务调度。
配置 mapr-site.xml文件
mv ./etc/hadoop/mapred-site.xml.template ./etc/hadoop/mapred-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
修改配置文件 yarn-site.xml:
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
启动yarn(需要先执行过 ./sbin/start-dfs.sh
)
./sbin/start-yarn.sh
启动 YARN 之后,运行实例的方法还是一样的,仅仅是资源管理方式、任务调度不同。
观察日志信息可以发现,不启用 YARN 时,是 “mapred.LocalJobRunner” 在跑任务,启用 YARN 之后,是 “mapred.YARNRunner” 在跑任务。启动 YARN 有个好处是可以通过 Web 界面查看任务的运行情况:http://localhost:8088/cluster
hadoop@Athena:/usr/local/hadoop$ ./sbin/start-dfs.sh
16/06/22 20:28:42 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting namenodes on [localhost]
localhost: starting namenode, logging to /usr/local/hadoop/logs/hadoop-hadoop-namenode-Athena.out
localhost: starting datanode, logging to /usr/local/hadoop/logs/hadoop-hadoop-datanode-Athena.out
Starting secondary namenodes [0.0.0.0]
0.0.0.0: starting secondarynamenode, logging to /usr/local/hadoop/logs/hadoop-hadoop-secondarynamenode-Athena.out
16/06/22 20:29:05 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
hadoop@Athena:/usr/local/hadoop$ ./sbin/start-yarn..sh
-su: ./sbin/start-yarn..sh: No such file or directory
hadoop@Athena:/usr/local/hadoop$ ./sbin/start-yarn.
start-yarn.cmd start-yarn.sh
hadoop@Athena:/usr/local/hadoop$ ./sbin/start-yarn.sh
starting yarn daemons
starting resourcemanager, logging to /usr/local/hadoop/logs/yarn-hadoop-resourcemanager-Athena.out
localhost: starting nodemanager, logging to /usr/local/hadoop/logs/yarn-hadoop-nodemanager-Athena.out
hadoop@Athena:/usr/local/hadoop$ jps
16896 DataNode
17395 NodeManager
17109 SecondaryNameNode
16774 NameNode
17271 ResourceManager
17432 Jps
hadoop@Athena:/usr/local/hadoop$ ./bin/hdfs dfs -rm -r output
16/06/22 20:29:46 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
16/06/22 20:29:47 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 0 minutes, Emptier interval = 0 minutes.
Deleted output
hadoop@Athena:/usr/local/hadoop$ ./bin/hadoop jar ./share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount input/core-site.xml output/RESULT
hadoop fs -lsr /查看所有文件和子目录,
hadoop fs -put example.txt. |
注意上面的这个命令最后一个参数是句点(.)。这意味着我们把文件放入了默认的工作目录。该命令等价于:
|