hadoop@node1:~$ jps
13025 Jps
hadoop@node1:~$ yarn --daemon start resourcemanager
hadoop@node1:~$ jps
13170 ResourceManager
13253 Jps
hadoop@node1:~$ yarn --daemon start nodemanager
hadoop@node1:~$ jps
13170 ResourceManager
15062 Jps
14890 NodeManager
? ? ? ? 此处需要注意,对于有返回值的程序,需要指定程序参数。
/export/server/hadoop/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.3.6.jar
? ? ? ? 对于这些Hadoop内置的程序,他们都存储在hadoop-mapreduce-examples-3.3.6.jar中,如wordcount单词计数程序、pi求圆周率程序。
首先,明确wordcount程序有返回值,所以需要指定程序参数:
[程序参数]:参数1是数据输入路径(hdfs://node1:8020/input/wordcount/)
[程序参数]:参数2是结果输出路径(hdfs://node1:8020/output/wc1),需要确保输出的文件夹不存在,否则会报错
hadoop jar $HADOOP_HOME/share/hadoop/mapreduce/hadoop-mapreduce-examples-3.3.1.jar wordcount hdfs://node1:8020/input/wordcount/ hdfs://node1:8020/output/some
????????执行完成后,查看some文件夹,可以看到some文件夹中存在两个子文件,第一个文件的文件名的最后一个单词,代表了本次程序运行是否成功,第二个文件存放着程序运行之后的结果。
hadoop@node1:~$ hdfs dfs -ls hdfs://node1:8020/output/some
Found 2 items
-rw-r--r-- 3 hadoop supergroup 0 2023-12-16 22:37 hdfs://node1:8020/output/some/_SUCCESS
-rw-r--r-- 3 hadoop supergroup 351 2023-12-16 22:37 hdfs://node1:8020/output/some/part-r-00000
????????程序运行之后的结果为:
hadoop@node1:~$ hdfs dfs -cat hdfs://node1:8020/output/some/part-r-00000
Because 1
Hello,my 1
I 7
I'll 1
If 1
Now 1
XX 1
XXX. 1
a 2
am 1
best 1
bird. 1
blue 1
can 2
chance 1
child. 1
come 1
day 1
do 1
dream 2
everything 1
fly 1
graduatedfrom 1
have 2
i 1
in 1
is 1
it 1
job. 2
like 1
love 1
make 1
my 1
name 1
old.I 1
one 1
since 1
sky 1
some 3
take 1
that 1
the 3
this 2
to 2
true. 1
try 1
was 1
well. 1
years 1
yjbys. 1