微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Hadoop的单机模式

具体的官网链接为:https://hadoop.apache.org/docs/r2.10.0/hadoop-project-dist/hadoop-common/SingleCluster.html

官方Grep案例

[root@iZbp1efx14jd8471u20gpaZ hadoop-2.7.2]# mkdir input
[root@iZbp1efx14jd8471u20gpaZ hadoop-2.7.2]# cp etc/hadoop/*.xml input
[root@iZbp1efx14jd8471u20gpaZ hadoop-2.7.2]# bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar  grep input output 'dfs[a-z.]+'
20/01/13 21:56:11 INFO Configuration.deprecation: session.id is deprecated. Instead, use dfs.metrics.session-id
20/01/13 21:56:11 INFO jvm.JvmMetrics: Initializing JVM Metrics with processName=JobTracker, sessionId=
20/01/13 21:56:12 INFO input.FileInputFormat: Total input paths to process : 8
20/01/13 21:56:12 INFO mapreduce.JobSubmitter: number of splits:8
20/01/13 21:56:12 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_local1665352450_0001
20/01/13 21:56:12 INFO mapreduce.Job: The url to track the job: http://localhost:8080/
20/01/13 21:56:12 INFO mapreduce.Job: Running job: job_local1665352450_0001
[root@iZbp1efx14jd8471u20gpaZ hadoop-2.7.2]# ll
total 60
drwxr-xr-x 2 root root  4096 May 22  2017 bin
drwxr-xr-x 3 root root  4096 May 22  2017 etc
drwxr-xr-x 2 root root  4096 May 22  2017 include
drwxr-xr-x 2 root root  4096 Jan 13 21:55 input
drwxr-xr-x 3 root root  4096 May 22  2017 lib
drwxr-xr-x 2 root root  4096 May 22  2017 libexec
-rw-r--r-- 1 root root 15429 May 22  2017 LICENSE.txt
-rw-r--r-- 1 root root   101 May 22  2017 NOTICE.txt
drwxr-xr-x 2 root root  4096 Jan 13 21:56 output
-rw-r--r-- 1 root root  1366 May 22  2017 README.txt
drwxr-xr-x 2 root root  4096 May 22  2017 sbin
drwxr-xr-x 4 root root  4096 May 22  2017 share
[root@iZbp1efx14jd8471u20gpaZ hadoop-2.7.2]# cd output/
[root@iZbp1efx14jd8471u20gpaZ output]# ll
total 4
-rw-r--r-- 1 root root 11 Jan 13 21:56 part-r-00000
-rw-r--r-- 1 root root  0 Jan 13 21:56 _SUCCESS
[root@iZbp1efx14jd8471u20gpaZ output]# cat part-r-00000
1       dfsadmin

官方WordCount案例

root@iZbp1efx14jd8471u20gpaZ hadoop-2.7.2]# mkdir wcinput
[root@iZbp1efx14jd8471u20gpaZ hadoop-2.7.2]# cd wcinput
[root@iZbp1efx14jd8471u20gpaZ wcinput]# touch wc.input
[root@iZbp1efx14jd8471u20gpaZ wcinput]# vi wc.input
[root@iZbp1efx14jd8471u20gpaZ wcinput]# cd ..
[root@iZbp1efx14jd8471u20gpaZ hadoop-2.7.2]# ll
total 64
drwxr-xr-x 2 root root  4096 May 22  2017 bin
drwxr-xr-x 3 root root  4096 May 22  2017 etc
drwxr-xr-x 2 root root  4096 May 22  2017 include
drwxr-xr-x 2 root root  4096 Jan 13 21:55 input
drwxr-xr-x 3 root root  4096 May 22  2017 lib
drwxr-xr-x 2 root root  4096 May 22  2017 libexec
-rw-r--r-- 1 root root 15429 May 22  2017 LICENSE.txt
-rw-r--r-- 1 root root   101 May 22  2017 NOTICE.txt
drwxr-xr-x 2 root root  4096 Jan 13 21:56 output
-rw-r--r-- 1 root root  1366 May 22  2017 README.txt
drwxr-xr-x 2 root root  4096 May 22  2017 sbin
drwxr-xr-x 4 root root  4096 May 22  2017 share
drwxr-xr-x 2 root root  4096 Jan 13 22:30 wcinput
[root@iZbp1efx14jd8471u20gpaZ hadoop-2.7.2]# hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount wcinput wcoutput
20/01/13 22:30:43 INFO Configuration.deprecation: session.id is deprecated. Instead, use dfs.metrics.session-id
20/01/13 22:30:43 INFO jvm.JvmMetrics: Initializing JVM Metrics with processName=JobTracker, sessionId=
20/01/13 22:30:44 INFO input.FileInputFormat: Total input paths to process : 1
20/01/13 22:30:44 INFO mapreduce.JobSubmitter: number of splits:1
20/01/13 22:30:44 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_local981224535_0001
[root@iZbp1efx14jd8471u20gpaZ hadoop-2.7.2]# cat wcoutput/part-r-00000
hadoop  2
mapreduce       1
topcheer        2
yarn    1
[root@iZbp1efx14jd8471u20gpaZ hadoop-2.7.2]# cat wcinput/wc.input
bin/         include/     lib/         LICENSE.txt  output/      sbin/        wcinput/
etc/         input/       libexec/     NOTICE.txt   README.txt   share/       wcoutput/
[root@iZbp1efx14jd8471u20gpaZ hadoop-2.7.2]# cat wcinput/wc.input
hadoop yarn
hadoop mapreduce
topcheer
topcheer

[root@iZbp1efx14jd8471u20gpaZ hadoop-2.7.2]#

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐