Hadoop的单机模式

Posted 天宇轩-王

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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]#

以上是关于Hadoop的单机模式的主要内容,如果未能解决你的问题,请参考以下文章

湿货|大数据测试之hadoop单机环境搭建(超级详细版)

hadoop单机模式和伪分布式模式的异同

hadoop单机模式和伪分布式模式的异同

Hadoop基础教程2Hadoop之单机模式搭建(转)

3-1.Hadoop单机模式安装

我把hadoop安装在不能上网的电脑上,请问hadoop的编译运行不联网能操作吗?大谢