sbin/start-yarn.sh starting yarn daemons starting resourcemanager, logging to /usr/local/hadoop/hadoop-2.6.0-cdh5.7.0/logs/yarn-simon-resourcemanager-localhost.out localhost: starting nodemanager, logging to /usr/local/hadoop/hadoop-2.6.0-cdh5.7.0/logs/yarn-simon-nodemanager-localhost.out
1 2 3
jps 41620 NodeManager 41546 ResourceManager
说明YARN已经成功启动。
通过浏览器访问地址 http://localhost:8088,可见页面如下
提交作业
1 2
bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0-cdh5.7.0.jar wordcount Usage: wordcount <in> [<in>...] <out>
说明需要提供输入文件及输出结果的位置。
我们先创建一个测试文件
1 2 3 4
vi /tmp/input
hello world hello hello world
把input文件上传到hdfs://data/目录下
1
bin/hadoop fs -put /tmp/input /data
再次执行命令
1
bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0-cdh5.7.0.jar wordcount /data/input /data/out
查看执行结果
1 2 3 4 5
bin/hadoop fs -ls /data/out 19/01/09 21:07:44 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable Found 2 items -rw-r--r-- 1 simon supergroup 0 2019-01-29 21:06 /data/out/_SUCCESS -rw-r--r-- 1 simon supergroup 16 2019-01-29 21:06 /data/out/part-r-00000
wordcount的结果在文件/data/out/part-r-00000里面
1 2 3 4
bin/hadoop fs -text /data/out/part-r-00000 19/01/09 21:08:54 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable hello 3 world 2
如果重复提交作业,会出现如下FileAlreadyExistsException异常。
1 2 3 4 5
bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0-cdh5.7.0.jar wordcount /data/input /data/out 19/01/09 21:09:52 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 19/01/09 21:09:53 INFO client.RMProxy: Connecting to ResourceManager at /0.0.0.0:8032 19/01/09 21:09:53 WARN security.UserGroupInformation: PriviledgedActionException as:simon (auth:SIMPLE) cause:org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory hdfs://localhost:8020/data/out already exists org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory hdfs://localhost:8020/data/out already exists