P.S.
我为了不打扰我的毕设内容(hadoop101已被毕设占用),重新配置了虚拟机hadoop100,和上文的hadoop101没有区别,只是名字和ip地址不同而已。特此说明。
目录
2.1.1 在hadoop-2.9.2文件夹下创建一个input 文件夹
2.2.1 在hadoop-2.9.2文件夹下创建一个wcinput文件夹
2.2.2 在wcinput文件夹下创建一个wc.input文件
2.2.4 回到Hadoop目录/opt/module/hadoop-2.9.2
2.Hadoop本地运行模式
2.1 官方Grep案例
2.1.1 在hadoop-2.9.2文件夹下创建一个input 文件夹
[atlingtree@hadoop100 ~]$ cd /opt/modules/hadoop-2.9.2
[atlingtree@hadoop100 hadoop-2.9.2]$ mkdir input
2.1.2 将Hadoop的xml配置文件复制到input
[atlingtree@hadoop100 hadoop-2.9.2]$ cp etc/hadoop/*.xml input
[atlingtree@hadoop100 hadoop-2.9.2]$ cd input/
[atlingtree@hadoop100 input]$ ll
total 48
-rw-r--r--. 1 atlingtree atlingtree 7861 May 5 10:04 capacity-scheduler.xml
-rw-r--r--. 1 atlingtree atlingtree 774 May 5 10:04 core-site.xml
-rw-r--r--. 1 atlingtree atlingtree 10206 May 5 10:04 hadoop-policy.xml
-rw-r--r--. 1 atlingtree atlingtree 775 May 5 10:04 hdfs-site.xml
-rw-r--r--. 1 atlingtree atlingtree 620 May 5 10:04 httpfs-site.xml
-rw-r--r--. 1 atlingtree atlingtree 3518 May 5 10:04 kms-acls.xml
-rw-r--r--. 1 atlingtree atlingtree 5939 May 5 10:04 kms-site.xml
-rw-r--r--. 1 atlingtree atlingtree 690 May 5 10:04 yarn-site.xml
2.1.3 执行share目录下的MapReduce程序
[atlingtree@hadoop100 input]$ cd ..
[atlingtree@hadoop100 hadoop-2.9.2]$ bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.9.2.jar grep input output 'dfs[a-z.]+'
2.1.4 查看输出结果
[atlingtree@hadoop100 hadoop-2.9.2]$ cat output/*
1 dfsadmin
2.2 官方WordCount 案例
2.2.1 在hadoop-2.9.2文件夹下创建一个wcinput文件夹
[atlingtree@hadoop100 hadoop-2.9.2]$ mkdir wcinput
2.2.2 在wcinput文件夹下创建一个wc.input文件
[atlingtree@hadoop100 hadoop-2.9.2]$ cd wcinput/
[atlingtree@hadoop100 wcinput]$ touch wc.input
2.2.3 编辑wc.input
[atlingtree@hadoop100 wcinput]$ vi wc.input
在文件中输入如下内容:
hadoop yarn
hadoop mapreduce
ignb
tesnb
ignb
保存退出 :wq
2.2.4 回到Hadoop目录/opt/module/hadoop-2.9.2
[atlingtree@hadoop100 wcinput]$ cd /opt/modules/hadoop-2.9.2/
2.2.5 执行程序
[atlingtree@hadoop100 hadoop-2.9.2]$ hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.9.2.jar wordcount wcinput wcoutput
2.2.6 查看结果
[atlingtree@hadoop100 hadoop-2.9.2]$ cat wcoutput/part-r-00000
hadoop 2
ignb 2
mapreduce 1
tesnb 1
yarn 1